Question: Sra file to bam file error
0
gravatar for shrutidabral
7 months ago by
shrutidabral10
shrutidabral10 wrote:

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

rna-seq samtools sratoolkit • 492 views
ADD COMMENTlink modified 3 months ago by drquestion20 • written 7 months ago by shrutidabral10

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 REPLYlink modified 7 months ago • written 7 months ago by Fatima630

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 REPLYlink written 7 months ago by shrutidabral10

This might help: https://github.com/samtools/samtools/issues/698

ADD REPLYlink written 7 months ago by Fatima630

Is SRR31467 a real SRA number?

ADD REPLYlink written 7 months ago by genomax91k

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

ADD REPLYlink written 7 months ago by shrutidabral10

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 REPLYlink written 7 months ago by genomax91k

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 REPLYlink written 7 months ago by shrutidabral10

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 REPLYlink written 7 months ago by kartikayprasad10

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

ADD REPLYlink written 6 months ago by shrutidabral10
2
gravatar for drquestion
3 months ago by
drquestion20
Rome
drquestion20 wrote:

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 COMMENTlink modified 3 months ago • written 3 months ago by drquestion20
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: 2034 users visited in the last hour