![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sorting SAM files | ronaldrcutler | RNA Sequencing | 6 | 07-01-2016 09:08 AM |
Cufflinks refuses to operate on Tophat2 created bam or sam files due to sorting error | amrezans | Bioinformatics | 1 | 06-24-2013 12:54 PM |
sorting sam file | crh | Bioinformatics | 2 | 06-16-2011 06:45 AM |
Sorting SAM output from Bowtie | DrD2009 | Bioinformatics | 9 | 11-10-2010 11:52 AM |
Sorting large files | scami | Bioinformatics | 3 | 09-20-2010 11:45 PM |
![]() |
|
Thread Tools |
![]() |
#1 |
Junior Member
Location: baltimore Join Date: Jul 2016
Posts: 9
|
![]()
Hello All!
I am new to coding. I have written a python script to analyze a bunch of fastq files from RNASeq analysis. I am using the subprocess module to call bowtie2 in order to index the genome and align the unpaired short reads to the genome.My script generates a sam file which needs to be sorted before running the cuffdiff module. The linux sort command works perfectly on my mac, however, in spite of installing the Unxupdates on my windows at work, I am unable to make my script work. I am hoping for some help/advice here to sort my sam file in python. Here is the script I tried. #!/usr/bin/env python2.7 import os, sys inputFile = open(‘Outputfile1.txt’, 'r') lineList = inputFile.readlines() for line in sorted(lineList): print(line.rstrip()); With this script, the stdout is written to the screen. But this recognizes only the text file. Sam files are not recognized. Any help is much appreciated. Thanks in advance. -M |
![]() |
![]() |
![]() |
#2 |
Member
Location: Antwerp, Belgium Join Date: Oct 2015
Posts: 95
|
![]()
No, that's really not how you should sort a sam file. You should either have a look at samtools sort or pysam (python module).
I don't think doing this in plain python is a good idea, there are better alternatives such as bash loops, gnu-parallel, snakemake. |
![]() |
![]() |
![]() |
#3 |
Junior Member
Location: baltimore Join Date: Jul 2016
Posts: 9
|
![]()
Hi wdecoster,
Thanks for your response. Samtools sort function does not work on the windows terminal with either sam or bam files. But the samtools view function converts sam to bam format successfully. Also, the latest version of pysam for windows is not running on my machine. I will try snakemake. Thanks again, -M |
![]() |
![]() |
![]() |
#4 |
Senior Member
Location: East Coast USA Join Date: Feb 2008
Posts: 6,699
|
![]() |
![]() |
![]() |
![]() |
#5 |
Junior Member
Location: baltimore Join Date: Jul 2016
Posts: 9
|
![]()
Thanks GenoMax. Samtools sort sorts only bam files on the windows 10 terminal. With the sam file input, it gives the following error: samtools.exe has stopped working.
Also, does pysam work on windows? From what I saw, there is no pysam version for windows yet. Thanks again, -M |
![]() |
![]() |
![]() |
#6 |
Senior Member
Location: East Coast USA Join Date: Feb 2008
Posts: 6,699
|
![]()
AFAIK the linux version of samtools works with ubuntu bash terminal in windows 10. Are you not using that (I see a reference to samtools.exe)?
|
![]() |
![]() |
![]() |
#7 |
Junior Member
Location: baltimore Join Date: Jul 2016
Posts: 9
|
![]()
That is what I am using. samtools view works fine. The sort function works only on bam input, not on the sam input.
I downloaded unix utilities from http://gnuwin32.sourceforge.net/packages/coreutils.htm. Now the linux sort works on windows. Thanks again. -M |
![]() |
![]() |
![]() |
Tags |
cuffdiff, python, sam file, sort, sorted |
Thread Tools | |
|
|