Sra file to bam file error
1
0
Entering edit mode
4.7 years ago
shrutidabral ▴ 10

Hi ,

I am trying to convert SRA file to bam file and I getting these error for some files :

/opt/sratoolkit.2.9.2-centos_linux64/bin/sam-dump /data/SRR31467.sra | data/samtools/bin/samtools view -bS -o /data/sratobam/SRR31467.bam

[E::sam_hrecs_error] Malformed key:value pair at line 86: "@RG ID:PM164 PL:Illumina LB:GA LNID:L001 FCID:H9CB8ADXX DT:2014-04-21T00:00:00-0400 BCID:AGTACAAG SM:PM164_X1_1_Case"

samtools view: failed to add PG line to the header

samtools RNA-Seq sratoolkit • 2.7k views
ADD COMMENT
0
Entering edit mode

I think you need a dash after -bS because you are piping.

sam-dump /data/SRR31467.sra | data/samtools/bin/samtools view -bS - -o /data/sratobam/SRR31467.bam

or

sam-dump /data/SRR31467.sra | data/samtools/bin/samtools view -b -S - >  /data/sratobam/SRR31467.bam
ADD REPLY
0
Entering edit mode

I have used both of these command and it does not worked for me . The command i post is only one which successfully gives me the required output but for some file it does not worked.

ADD REPLY
0
Entering edit mode
ADD REPLY
0
Entering edit mode

Is SRR31467 a real SRA number?

ADD REPLY
0
Entering edit mode

nope , I didn't mention the correct SRR number.

ADD REPLY
0
Entering edit mode

Unless submitters have submitted aligned data what you will get is an unaligned BAM file. Which is not going to be useful for any downstream analysis.

ADD REPLY
0
Entering edit mode

submitters have submitted bam file . this is reported in their meta level information .

I have also converted sra to sam file for this particular SRR number file ,it converted successfully but It gives same error as above while converting sam to bam .

ADD REPLY
0
Entering edit mode

Try shorting the headers of your sam file. Remove all the unnecessary info from the header and try again with samtools view -b -s input.sam > output.bam

ADD REPLY
0
Entering edit mode

Can you please advise me , how to short the headers from sam file??

ADD REPLY
2
Entering edit mode
4.4 years ago
drquestion ▴ 20

Hello, I've experienced similar problems some weeks ago, then I've opened an issue on GitHub. As they made me notice, the most recent version of samtools (1.10) has a more strict behavior with header standards, which means that keys must not exceed two characters in length. To solve it I just shortened the malformed key with the following command:

samtools reheader -c "sed '/^@RG/ s/\([A-Z][A-Z]\)ID/\1/g'" example.bam > example.RGcorrected.bam

Which, inserted in your context, since it looks like you are receiving a sam file from stdin:

/opt/sratoolkit.2.9.2-centos_linux64/bin/sam-dump /data/SRR31467.sra | sed '/^@RG/ s/\([A-Z][A-Z]\)ID/\1/g' | data/samtools/bin/samtools view -bS - -o /data/sratobam/SRR31467.bam

Hope this helps :)

ADD COMMENT

Login before adding your answer.

Traffic: 1916 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6