Question: Read Vcf file using htsjdk library
0
gravatar for shahbazmunir11
11 days ago by
shahbazmunir1110 wrote:

Hi, I am using htsjdk library and want to read vcf file. I tried the following code but it gives error "Exception in thread "main" htsjdk.tribble.TribbleException$InvalidHeader: Your input file has a malformed header: We never saw the required CHROM header line (starting with one #) for the input VCF file". I checked the file and created the sample file but same error. Any suggestion? Thanks for your time and consideration.

VCFCodec codec = new VCFCodec();

LineReader r= LineReaderUtil.fromBufferedStreamSystem.in);

LineIteratorImpl t= new LineIteratorImpl(r);

codec.readActualHeader(t);

while(t.hasNext()){

    VariantContext ctx = codec.decode(t.next());

}

r.close();

t.close();
ngs • 131 views
ADD COMMENTlink modified 11 days ago • written 11 days ago by shahbazmunir1110

I checked the file and created the sample file but same error. Any suggestion?

show us the header.

ADD REPLYlink written 11 days ago by Pierre Lindenbaum96k

Case 1: The file "Sample2_Working" is working but the file "Sample_Error" gives an error. Both files are same but with the different header. Case 2: The file "Sample2_Working" is working but with another error. "An index is required, but none found". How can I generate the index file?

Thanks

ADD REPLYlink modified 11 days ago • written 11 days ago by shahbazmunir1110

Case1: Sample_Error header 3rd line

##HANDS2CommandLine<ID=assign,CommandLine="assign -s example/brassica/napus.bam -g example/brassica/rapa.fa.gff -hsp example/brassica/napus.hsp -snp1 example/brassica/rapa.snp -snp2 example/brassica/oleracea.snp -bc example/brassica/napus_test.bc -bc1 example/brassica/rapa.bc -bc2 example/brassica/oleracea.bc -out1 example/brassica/napus-a.vcf -out2 example/brassica/napus-c.vcf -m true">
ADD REPLYlink modified 11 days ago by Pierre Lindenbaum96k • written 11 days ago by shahbazmunir1110

this is not a valid header line. A VCF header line is

##KEY=VALUE
ADD REPLYlink written 11 days ago by Pierre Lindenbaum96k
##fileformat=VCFv4.1
##source=HANDS2v1.0
##Genome=1
#CHROM  POS ID  REF ALT QUAL    FILTER  INFO
Bra1.27 3355    .   T   .   100 .   HSP=K;FC=Y;DB=T
Bra1.27 3527    .   G   A   100 .   HSP=R;FC=Y;DB=G
Bra1.27 3538    .   A   T   100 .   HSP=W;FC=Y;DB=A
Bra1.27 3543    .   T   C   100 .   HSP=Y;FC=N;DB=*
Bra1.27 3549    .   C   .   100 .   HSP=Y;FC=Y;DB=C

Okay i will remove those lines. This sample file is working but with another error "An index is required, but none found." I have created the .tbi index file but its not working. How we can resolve this error? Thanks

ADD REPLYlink modified 11 days ago by Pierre Lindenbaum96k • written 11 days ago by shahbazmunir1110
1
gravatar for Pierre Lindenbaum
11 days ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum96k wrote:

something like:

VCFFileReader r=new VCFFileReader(new File("your.vcf") );
CloseableIterator<VariantContext> t=r.iterator();
while(t.hasNext()){
    VariantContext ctx =t.next();
}
t.close();
r.close();
ADD COMMENTlink written 11 days ago by Pierre Lindenbaum96k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1527 users visited in the last hour