Menu

#50 vcf-subset tries to read dir in the working directory that has the same name as the column given to the -c option

v1.0_(example)
open
nobody
None
1
2014-08-05
2014-08-05
No

Hi,

I am using vcf-subset and the -c option to specify the column of the vcf file I would like to keep. It is not filtering the columns at all. It is coincidental that there is also a directory in my working directory with the same name as the column I would like to keep and therefore the read_columns subroutine tries to read the directory as a file (containing the columns to keep).

Here is the directory and example outputs corresponding to the changes below.

~~~~~~

14:43 davidb@blaneyvm vcf-subset-test $ ls -asl
total 24
4 drwxr-xr-x 3 davidb users 4096 Aug 5 14:43 .
12 drwxrwxrwx 134 davidb users 12288 Aug 5 14:42 ..
4 drwxr-xr-x 2 davidb users 4096 Aug 5 14:43 19316A
4 -rw-r--r-- 1 davidb users 325 Aug 5 14:43 19316A.vcf
14:43 davidb@blaneyvm vcf-subset-test $ perl ~/vcftools_0.1.12b/perl/vcf-subset -e -c 19316A ./19316A.vcf

fileformat=VCFv4.1

source_20140705.1=vcf-subset(r797) -e -c 19316A ./19316A.vcf

CHROM POS ID REF ALT QUAL FILTER INFO FORMAT 19316A

1 777122 . A T 940.90 PASS AC=2;AF=1.00;AN=2;DP=24;Dels=0.00;FS=0.000;HRun=0;HaplotypeScore=0.0000;MQ0=0;MQ=60.00;QD=39.20;SB=-0.01;set=variant2 GT:AD:DP:GQ:PL 1/1:0,10:10:30.10:401,30,0
14:43 davidb@blaneyvm vcf-subset-test $ perl ~/vcftools_0.1.12b/perl/vcf-subset-old -e -c 19316A ./19316A.vcf

fileformat=VCFv4.1

source_20140705.1=vcf-subset-old(r797) -e -c 19316A ./19316A.vcf

CHROM POS ID REF ALT QUAL FILTER INFO FORMAT 19316A 21823 21824

1 777122 . A T 940.90 PASS AC=6;AF=1.00;AN=6;DP=24;Dels=0.00;FS=0.000;HRun=0;HaplotypeScore=0.0000;MQ0=0;MQ=60.00;QD=39.20;SB=-0.01;set=variant2 GT:AD:DP:GQ:PL 1/1:0,10:10:30.10:401,30,0 1/1:0,10:10:30.10:411,30,0 1/1:0,4:4:12.04:166,12,0

~~~~

The following patch prevents this behaviour:

--- vcf-subset-old      2014-08-05 14:19:08.428440000 +0100
+++ vcf-subset  2014-08-05 14:11:09.901430000 +0100
@@ -78,7 +78,7 @@
 {
     my ($fname) = @_;
     my @columns;

-    if ( !-e $fname )
+    if ( !-e $fname || -d $fname )
     {
         @columns = split(/,/,$fname);
         return \@columns;

Cheers,
David

Discussion


Log in to post a comment.

MongoDB Logo MongoDB