Skip to content

Commit

Permalink
[MODIF] correct merge request
Browse files Browse the repository at this point in the history
  • Loading branch information
nservant committed Mar 24, 2020
1 parent 7f064d8 commit 9a0bdcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 97 deletions.
88 changes: 4 additions & 84 deletions bin/HiC-Pro
Original file line number Diff line number Diff line change
Expand Up @@ -248,96 +248,16 @@ fi
## Check rawdata structure
if [[ $NEED_FASTQ == 1 ]]; then
nbin=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fastq" -o -name "*.fastq.gz" -o -name "*.fq" -o -name "*.fq.gz" | wc -l) #!
nbin_r1a=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fastq*" -and -name "*${PAIR1_EXT}*" | wc -l)
nbin_r1b=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq*" -and -name "*${PAIR1_EXT}*" | wc -l)
nbin_r2a=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fastq*" -and -name "*${PAIR2_EXT}*" | wc -l)
nbin_r2b=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq*" -and -name "*${PAIR2_EXT}*" | wc -l)
nbin_r1=0
nbin_r2=0
let "nbin_r1 = nbin_r1a + nbin_r1b"
let "nbin_r2 = nbin_r2a + nbin_r2b"
#echo "nbin_r1b = $nbin_r1b"
#echo "nbin_r1a = $nbin_r1a"
#echo "nbin_r1 = $nbin_r1"
#echo "nbin_r2b = $nbin_r2b"
#echo "nbin_r2a = $nbin_r2a"
#echo "nbin_r2 = $nbin_r2"
nbin_r1=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fastq*" -o -name ".fq*" -and -name "*${PAIR1_EXT}*" | wc -l)
nbin_r2=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fastq*" -o -name ".fq*" -and -name "*${PAIR2_EXT}*" | wc -l)

if [ $nbin == 0 ]; then
die "Error: Directory Hierarchy of rawdata '$INPUT' is not correct. No '.fastq(.gz)' files detected"
fi
if [[ $nbin_r1 == 0 || $nbin_r2 == 0 || $nbin_r1 != $nbin_r2 ]]; then
die "Error: Directory Hierarchy of rawdata '$INPUT' is not correct. Paired '.fastq' files with ${PAIR1_EXT}/${PAIR2_EXT} are required !"
fi
if [[ $nbin_r1b != $nbin_r2b || $nbin_r1a != $nbin_r2a ]] #! Intra sample
then
echo "Your fastq files doesn't have the same extension !"
if [[ $nbin_r1b == 1 && $nbin_r1a == 0 ]]
then
with_gz_name=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq.gz" -and -name "*${PAIR1_EXT}*")
without_gz_name=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq" -and -name "*${PAIR1_EXT}*")
#echo "with_gz_name: $with_gz_name"
#echo "without_gz_name: $without_gz_name"
if [[ -z $with_gz_name && -r $without_gz_name ]] #if nbin_r1b doesn't have gz extension, so if it is a .fq
then
new_name=$(echo $without_gz_name | sed -e "s/\.fq$/.fastq/") #!
echo "Renaming $old_name in $new_name"
mv $without_gz_name $new_name
elif [[ -z $without_gz_name && -r $with_gz_name ]]
then
new_name=$(echo $with_gz_name | sed -e "s/\.fq.gz$/.fastq.gz/") #!
echo "Renaming $old_name in $new_name"
mv $with_gz_name $new_name
fi
elif [[ $nbin_r2b == 1 && $nbin_r2a == 0 ]]
then
with_gz_name=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq.gz" -and -name "*${PAIR2_EXT}*")
without_gz_name=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq" -and -name "*${PAIR2_EXT}*")
#echo "with_gz_name: $with_gz_name"
#echo "without_gz_name: $without_gz_name"
if [[ -z $with_gz_name && -r $without_gz_name ]]
then
new_name=$(echo $without_gz_name | sed -e "s/\.fq$/.fastq/") #!
echo "Renaming $old_name in $new_name"
mv $without_gz_name $new_name
elif [[ -z $without_gz_name && -r $with_gz_name ]]
then
new_name=$(echo $with_gz_name | sed -e "s/\.fq.gz$/.fastq.gz/") #!
echo "Renaming $old_name in $new_name"
mv $with_gz_name $new_name
fi
fi
elif [[ $nbin_r1b == $nbin_r2b && $nbin_r1a == $nbin_r2a ]] #! Inter Sample
then
if [[ $nbin_r1 -gt 1 && $nbin_r2 -gt 1 ]] #If we really have multiple samples
then
tab_ext=(${PAIR1_EXT} ${PAIR2_EXT})
for i in `seq 0 1`;
do
with_gz_name=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq.gz" -and -name "*${tab_ext[$i]}*")
without_gz_name=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.fq" -and -name "*${tab_ext[$i]}*")
#echo "with_gz_name_r1: $with_gz_name"
#echo "without_gz_name_r1: $without_gz_name"
if [[ -z $with_gz_name && -r $without_gz_name ]]
then
for i in $without_gz_name
do
new_name=$(echo $i | sed -e "s/\.fq$/.fastq/") #!
echo "Renaming $i in $new_name"
mv $i $new_name
done
elif [[ -z $without_gz_name && -r $with_gz_name ]]
then
for i in $with_gz_name
do
new_name=$(echo $i | sed -e "s/\.fq.gz$/.fastq.gz/") #!
echo "Renaming $i in $new_name"
mv $i $new_name
done
fi
done
fi
fi


elif [[ $NEED_BAM == 1 ]]; then
nbin=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.bam" | wc -l)
nbin_r1=$(find -L $INPUT -mindepth 2 -maxdepth 2 -name "*.bam" -and -name "*${PAIR1_EXT}* | wc -l")
Expand Down
18 changes: 5 additions & 13 deletions scripts/hic.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ filter_pairs()
get_data_type()
{
## return the highest possible input files type
nb_fqa=$(find -L $RAW_DIR -mindepth 2 -maxdepth 2 -name "*.fastq" -o -name "*.fastq.gz" | wc -l)
nb_fqb=$(find -L $RAW_DIR -mindepth 2 -maxdepth 2 -name "*.fq" -o -name "*.fq.gz" | wc -l) #!
nb_fq=$(find -L $RAW_DIR -mindepth 2 -maxdepth 2 -name "*.fastq" -o -name "*.fastq.gz" -o -name ".fq" -o -name ".fq.gz"| wc -l)
nb_bam=$(find -L $RAW_DIR -mindepth 2 -maxdepth 2 -name "*.bam" -o -name "*.sam" | wc -l)
nb_vpairs=$(find -L $RAW_DIR -mindepth 2 -maxdepth 2 -name "*.validPairs" | wc -l)
nb_allvpairs=$(find -L $RAW_DIR -mindepth 2 -maxdepth 2 -name "*.allValidPairs" | wc -l)
Expand All @@ -149,10 +148,8 @@ get_data_type()
INPUT_DATA_TYPE="valid"
elif (( $nb_bam > 0 )); then
INPUT_DATA_TYPE="bam"
elif (( $nb_fqa > 0 )); then
elif (( $nb_fq > 0 )); then
INPUT_DATA_TYPE="fastq"
elif (( $nb_fqb > 0 )); then
INPUT_DATA_TYPE="fq"
else
die "Error in input type.'.fastq|.fq|.bam|.validPairs|.allValidPairs|.matrix' files are expected." #!
fi
Expand Down Expand Up @@ -225,15 +222,13 @@ get_sample_dir()

get_fastq_for_bowtie_global()
{
local input_data_type=$(get_data_type)
local input_data_type=$(get_data_type)
if [[ $input_data_type == "fastq" ]]
then
ifastq=$(get_hic_files $RAW_DIR .fastq | grep "$PAIR1_EXT")
elif [[ $input_data_type == "fq" ]]
then
ifastq=$(get_hic_files $RAW_DIR .fq | grep "$PAIR1_EXT") #!
ifq=$(get_hic_files $RAW_DIR .fq | grep "$PAIR1_EXT")
fi
echo $ifastq
echo "$ifastq $ifq"
}

get_fastq_for_bowtie_local()
Expand Down Expand Up @@ -281,9 +276,6 @@ get_sam_for_merge()
if [[ $input_data_type == "fastq" ]]
then
bam=$(get_hic_files ${BOWTIE2_FINAL_OUTPUT_DIR} _${REFERENCE_GENOME}.bwt2merged.bam)
elif [[ $input_data_type == "fq" ]]
then
bam=$(get_hic_files ${BOWTIE2_FINAL_OUTPUT_DIR} _${REFERENCE_GENOME}.bwt2merged.bam)
elif [[ $input_data_type == "bam" ]]
then
bam=$(get_bam_from_raw_dir)
Expand Down

0 comments on commit 9a0bdcd

Please sign in to comment.