vcfutils for parsing multiple vcf files
Question: I have multiple VCF files and What I need to achieve is to extract some rows
from VCF file based on the defined filters.. So in order to achieve that I
started off with using

    
    
    import vcf
    import vcf.utils
    

which seems to be to straight forward and neat. but I am getting issues, in
between it would be really great if some one take a look and guide a little
bit to get to the desired output..

VCF file looks like this its has lines starting with # and later information
we needed,(few lines with headers and the rows needed are as follows,)

    
    
    ##fileformat=VCFv4.1
    ##source=V2
    ##INFO=<ID=DP,Number=1,Type=Integer,Description="Total depth of quality bases">
    ##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="Indicates if record is a somatic mutation">
    ##INFO=<ID=SS,Number=1,Type=String,Description="Somatic status of variant (0=Reference,1=Germline,2=Somatic,3=LOH, or 5=Unknown)">
    chr10   197523  .   G   A   .   PASS    DP=26;SS=1;SSC=2;GPV=5.4595E-6;SPV=6.1327E-1    GT:GQ:DP:RD:AD:FREQ:DP4 0/1:.:17:8:9:52.94%:5,3,4,5 0/1:.:9:4:5:55.56%:2,2,2,3
    chr10   198411  .   T   G   .   PASS    DP=37;SS=1;SSC=5;GPV=1.2704E-5;SPV=2.7151E-1    GT:GQ:DP:RD:AD:FREQ:DP4 0/1:.:19:13:6:31.58%:8,5,1,5    0/1:.:18:9:8:47.06%:3,6,5,3
    

and so I used following piece of python code to get the information I need,

The flowing piece of code throws error message,

    
    
    reader_BM_CR_ID = vcf.Reader(filename="sample/sam/sample.vcf", compressed=False)
    writer_CR = vcf.Writer(open('same/sam/sample_filtered.vcf', 'w'), reader_BM_CR_ID)
     for variants in vcf.utils(reader_BM_CR_ID):
    
         for call in variants.samples:
               if call.sample == 'T':
                    if call.data.FREQ >='20%':
                        if call.data.FREQ >'0%':
                             if call.data.FREQ !='100%':
                                    if call.data.DP >=20:
            writer.write_record(id_var)   
    

The error message,

    
    
            TypeError                                 Traceback (most recent call last)
    <ipython-input-471-526e4c3bbab1> in <module>()
    ----> 1 for variants in vcf.utils(reader_BM_CR_ID):
          2 
          3          for call in variants.samples:
          4                if call.sample == 'T':
          5                     if call.data.FREQ >='20%':
    
    TypeError: 'module' object is not callable
    

Any help is really appreciated..!!


Answer: You are trying to call `module` as `function`.

Python carefully reports about it:

    
    
    TypeError: 'module' object is not callable
    

