SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Soap Output File Error: Can't write rahul.m.dhodapkar Bioinformatics 11 07-06-2015 05:34 AM
Easy library to read and write genomic files xApple Bioinformatics 5 02-14-2012 08:06 AM
GATK: unable to write data to BAM schedule file bjchen Bioinformatics 5 02-13-2012 12:21 AM
Re-write strand information in BAM file droog_22 Bioinformatics 1 11-07-2011 03:25 AM
python dror Bioinformatics 0 11-29-2010 03:22 AM

Reply
 
Thread Tools
Old 06-29-2012, 05:30 AM   #1
neni
Junior Member
 
Location: CH

Join Date: Feb 2010
Posts: 3
Default write fastq with Python

Hello. My problem seems so super basic, I haven't found an answer in this forum... I'm really brand new in this field..

I want to convert a .sff into a .fastq according the Biopython manual:

>>> from Bio import SeqIO
>>> from StringIO import StringIO
>>> out_handle = StringIO()
>>> count = SeqIO.convert("c:HPISTN001.sff", "sff",
... out_handle, "fastq")

But how do i GET the .fastq file, stored on c:?
neni is offline   Reply With Quote
Old 06-29-2012, 06:37 AM   #2
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

You've asked Biopython to write the FASTQ file to a string in memory, actually a special object called StringIO which mimics a file in memory.

All you need to do is this:

Code:
from Bio import SeqIO
count = SeqIO.convert(r"c:\HPISTN001.sff", "sff", r"C:\HPSITN001.fastq", "fastq")
print "Converted %i records" % count
Also note the use of r"xxxxx" to mean a raw string where \ is just a slash. Otherwise by default Python treats \n as a new line, and \t as a tab etc - which can be unhelpful with Windows style paths.

Which bit of the tutorial did you find unclear? I'd like to clarify it if possible.

Last edited by maubp; 06-29-2012 at 06:38 AM. Reason: Formating
maubp is offline   Reply With Quote
Old 06-29-2012, 08:49 AM   #3
kopardev
Member
 
Location: VA, USA

Join Date: Oct 2011
Posts: 18
Default

Sff_extract.py script
kopardev 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 12:45 PM.


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