KCCG / ClinSV

Robust detection of clinically relevant structural and copy number variation from whole genome sequencing data
Other
65 stars 8 forks source link

problem when -p project dir given as relative location #50

Closed EricDeveaud closed 1 month ago

EricDeveaud commented 1 year ago

Hello

running master branch of ClinSV I noticed that when project dir is given as a relative path it fails with followning error

rpm_maker://tmp > clinsv -i /opt/gensoft/tests/datas/ClinSV/NA12878_B37.bam -ref $CLINSV_REF_B37 -p b37_test

with

Failed to open file b37_test/alignments/FR05812606/FR05812606.bam

while

rpm_maker://tmp > clinsv -i /opt/gensoft/tests/datas/ClinSV/NA12878_B37.bam -ref $CLINSV_REF_B37 -p `pwd`/b37_test

does not exhibit same behaviour.

my guess is the problem is due to cd $projdir see

+ cd b37_test/alignments/FR05812606/bw/
+ awk '$2>=100000 {print $1":1-"$2}' /opt/gensoft/data/ClinSV/refdata-b37/genome/human_g1k_v37_decoy.fasta.chrom.sizes
+ xargs -P 15 -t '-i{}' /opt/gensoft/adm/bin/perl /opt/gensoft/exe/ClinSV/libexec/scripts/bam2wig.pl -s 1 -q q0 -r '{}' -o b37_test/alignments/FR05812606/bw/tmp/FR05812606.q0 -f /opt/gensoft/data/ClinSV/refdata-b37/genome/human_g1k_v37_decoy.fasta -b b37_test/alignments/FR05812606/FR05812606.bam

clinsv have this portion of code

                $r_OutDir="$projectDir/alignments/$cSample/bw";
                $rAlnDir="$projectDir/alignments/$cSample";
                $r_TmpDir="$r_OutDir/tmp";
      SNIP//SNAP non relevant code for this issue
                print OUT "cd $r_OutDir/\n";
      SNIP//SNAP non relevant code for this issue
                                print OUT "\n\nawk '\$2>=100000 {print \$1\":1-\"\$2}' $refFasta.chrom.sizes | xargs -P \${ncpus15} -t -i{} $^X $S_SV_scriptDir/bam2wigMQ.pl ";
                                print OUT "-s 1 -r \"{}\" -o $r_TmpDir/$cSample.$cT -f $refFasta -b $rAlnDir/$cSample.bam\n";

as rAlnDir is constructed with same prefix (projectDir) it is logical that it breaks when projectDir is relative.

clinsv works with no project argument given as in this case projectDir is set to cwd() ie absolute.

I would suggest to change preojectDir test https://github.com/KCCG/ClinSV/blob/master/clinsv#L65 to

if (length($projectDir)<1){ $projectDir=cwd();}
else {$projectDir = abs_path $projectDir; }

regards

Eric

drmjc commented 1 year ago

great advice, thanks