SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting a BAM produces a smaller file than the original oiiio Bioinformatics 18 09-28-2015 12:57 PM
GATK: sorting vcf file given a reference file jorge Bioinformatics 4 01-14-2015 01:16 PM
Sorting and removing MIDs from fastq file (Roche 454) ewilbanks Bioinformatics 25 01-10-2012 05:29 AM
Sorting SAM output from Bowtie DrD2009 Bioinformatics 9 11-10-2010 12:52 PM
Tool for Sorting PRB file foolishbrat Bioinformatics 1 01-26-2009 01:29 PM

Reply
 
Thread Tools
Old 06-15-2011, 09:11 PM   #1
crh
Member
 
Location: tx

Join Date: Dec 2009
Posts: 46
Default sorting sam file

Hi All,

I've read the archives and see where this problem has been addressed previously, but I've been unable to sort a sam file to feed into cufflinks.
Here is an excerpt from the sam file:



@SQ SN:chromosome_1 LN:9982135
@SQ SN:chromosome_2 LN:9975745
@SQ SN:chromosome_3 LN:7773333
@SQ SN:chromosome_4 LN:3005669
@SQ SN:chromosome_5 LN:3366352
@SQ SN:chromosome_6 LN:7695193
@SQ SN:chromosome_7 LN:6170768
@SQ SN:chromosome_8 LN:4189090
@SQ SN:chromosome_9 LN:4733070
@SQ SN:chromosome_10 LN:6579462
@SQ SN:chromosome_11 LN:2734619
@SQ SN:chromosome_12 LN:9355449
@SQ SN:chromosome_13 LN:6588689
@SQ SN:chromosome_14 LN:4114342
@SQ SN:chromosome_15 LN:3066274
@SQ SN:chromosome_16 LN:6617689
@SQ SN:chromosome_17 LN:6673064
@SQ SN:scaffold_18 LN:1287285
@SQ SN:scaffold_19 LN:814470
@SQ SN:scaffold_20 LN:598575
@SQ SN:scaffold_21 LN:558747
@SQ SN:scaffold_22 LN:430403
@SQ SN:scaffold_23 LN:373397
@SQ SN:scaffold_24 LN:339605
@SQ SN:scaffold_25 LN:333029
@SQ SN:scaffold_26 LN:317769
@SQ SN:scaffold_27 LN:256895
@SQ SN:scaffold_28 LN:253209
@SQ SN:scaffold_29 LN:245379
@SQ SN:scaffold_30 LN:238238
@SQ SN:scaffold_31 LN:222931
@SQ SN:scaffold_32 LN:217100
@SQ SN:scaffold_33 LN:214180
@SQ SN:scaffold_34 LN:186456
@SQ SN:scaffold_35 LN:179663
@SQ SN:scaffold_36 LN:154127
@SQ SN:scaffold_37 LN:123055
@SQ SN:scaffold_38 LN:120767
@SQ SN:scaffold_39 LN:119177
@SQ SN:scaffold_40 LN:116725
@SQ SN:scaffold_41 LN:99905
@SQ SN:scaffold_42 LN:98780
@SQ SN:scaffold_43 LN:80533
@SQ SN:scaffold_44 LN:80252
@SQ SN:scaffold_45 LN:79195
@SQ SN:scaffold_46 LN:72145
@SQ SN:scaffold_47 LN:67355
@SQ SN:scaffold_48 LN:66577
@SQ SN:scaffold_49 LN:65629
@SQ SN:scaffold_50 LN:63401
@SQ SN:scaffold_51 LN:63266
@SQ SN:scaffold_52 LN:59018
@SQ SN:scaffold_53 LN:55340
@SQ SN:scaffold_54 LN:54374
@SQ SN:scaffold_55 LN:50490
@SQ SN:scaffold_56 LN:47028
@SQ SN:scaffold_57 LN:46469
@SQ SN:scaffold_58 LN:45221
@SQ SN:scaffold_59 LN:43590
@SQ SN:scaffold_60 LN:43313
@SQ SN:scaffold_61 LN:39687
@SQ SN:scaffold_62 LN:38880
@SQ SN:scaffold_63 LN:36644
@SQ SN:scaffold_64 LN:36299
@SQ SN:scaffold_65 LN:36037
@SQ SN:scaffold_66 LN:32450
@SQ SN:scaffold_67 LN:30996
@SQ SN:scaffold_68 LN:29908
@SQ SN:scaffold_69 LN:29423
@SQ SN:scaffold_70 LN:28937
@SQ SN:scaffold_71 LN:28038
@SQ SN:scaffold_72 LN:26265
@SQ SN:scaffold_73 LN:25979
@SQ SN:scaffold_74 LN:25574
@SQ SN:scaffold_75 LN:25288
@SQ SN:scaffold_76 LN:23213
@SQ SN:scaffold_77 LN:22385
@SQ SN:scaffold_78 LN:21742
@SQ SN:scaffold_79 LN:21191
@SQ SN:scaffold_80 LN:20468
@SQ SN:scaffold_81 LN:20314
@SQ SN:scaffold_82 LN:20067
@SQ SN:scaffold_83 LN:18413
@SQ SN:scaffold_84 LN:15458
@SQ SN:scaffold_85 LN:13564
@SQ SN:scaffold_86 LN:12875
@SQ SN:scaffold_87 LN:12675
@SQ SN:scaffold_88 LN:8671
USI-EAS39:1:1:2:1362#0/1_3[0] 65 chromosome_2 28825 30 35M * 0 0 CTGGGTTCCACAGGCACATAGCCAAACCGGTGCCT ``]XD\a``b`b`^aa`aaaa`a]^aaa\UZ^^a^ NM:i:1 MD:Z:4T30
USI-EAS39:1:1:2:1276#0/1_3[0] 65 chromosome_12 6073621 30 35M * 0 0 GTTCGCTTTACACCGTAACATATTCAGCCAAATGC ]_aWDK\bbaaba_Y]ababbaaa`ba`abbab]` NM:i:0 MD:Z:35
USI-EAS39:1:1:2:1649#0/1_3[0] 81 chromosome_17 6301050 30 35M * 0 0 GCTCCAACAACAAGACCTCCTGACATAAGACTCAC ^`_a`a`P__Xaaa]_X^``aa`bbbbba^D[a^a NM:i:1 MD:Z:30G4


I generated the sam file using:
samtools view -h -S -t ~/binf/seq/genome/chlre4/Chlre4_genomic_scaffolds.fasta.fai -o test_sorted.sam soap_mapped_reads.sam

If I run cufflinks, I get the error:

cufflinks -G ~/binf/sto1/models.gtf test_sorted.sam

[bam_header_read] EOF marker is absent.
[bam_header_read] invalid BAM binary header (this is not a BAM file).
File test_sorted.sam doesn't appear to be a valid BAM file, trying SAM...
[23:01:46] Loading reference annotation.
[23:01:51] Inspecting reads and determining fragment length distribution.
> Processing Locus chromosome_17:6295360-62958 [**** ] 18%
Error: this SAM file doesn't appear to be correctly sorted!
current hit is at chromosome_15:2745584, last one was at chromosome_17:6301049
Cufflinks requires that if your file has SQ records in
the SAM header that they appear in the same order as the chromosomes names
in the alignments.
If there are no SQ records in the header, or if the header is missing,
the alignments must be sorted lexicographically by chromsome
name and by position.


So, the sam file is not correctly sorted.
If I sort using:
sort -k 3,3 -k 4,4n test_sorted.sam > test2_sorted.sam

I loose the header, and get the same error when attempting to run cufflinks:
[23:08:38] Loading reference annotation.
[23:08:43] Inspecting reads and determining fragment length distribution.
> Processing Locus scaffold_88:8392-8579 [************************ ] 98%
Error: this SAM file doesn't appear to be correctly sorted!
current hit is at scaffold_82:5078, last one was at scaffold_81:18777
Cufflinks requires that if your file has SQ records in


I guess the question is how to sort 'chromosome_1'?

charles
crh is offline   Reply With Quote
Old 06-15-2011, 09:37 PM   #2
peromhc
Senior Member
 
Location: Durham, NH

Join Date: Sep 2009
Posts: 108
Default

I had a, identical error message when I had colons ":" in my original fasta file.. I'd check that if I were you!
peromhc is offline   Reply With Quote
Old 06-16-2011, 07:45 AM   #3
crh
Member
 
Location: tx

Join Date: Dec 2009
Posts: 46
Default

I've checked, and there are no colons within the genomic fasta file
charles
crh is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 10:53 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO