This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Reading Ab1 Files With Python

I'm looking for a way to convert a batch of AB1 trace files into FASTA using python. I've tried looking in the BioPython website but failed to find any reference on how to do it so far. For Perl folks, I know there might be a way to it with Bioperl, but as I'm much more familiar with Python, I prefer to do it that way.

So, any pointers? Help is much appreciated :)!

EDIT: Just as an additional info for people who might stumble on this page, I had some extra time for myself and decided to write a Python module for reading AB1 files. You can find it here.

python conversion

was that enough of an answer? ... if so please mark a correct answer to help people who come on this question later :)

from Bio import SeqIO
handle = open("test.ab1", "rb")
for record in SeqIO.parse(handle, "abi"):
    print(record)
#from here on, you can extract the data and go to any file format you want.

3 answers

I had this same issue not too long ago: Converting Ab1 Trace Files Into Scf Trace Files

I couldn't find a reasonable python method so I ended up using Staden ... the docs are here

You could certainly use python's submodules to do it but convert_trace has a "directory" option to process everything in a directory.

Hope that helps,
Will

PS. I also tried abiparser.py (available by google-search) but that turned out to be a waste of ~3 hours trying to get it to work.

Ah yes, I tried abiparser.py and it's a pain to understand :/. Staden isn't a walk in the park, too. I haven't been able to install it on Lucid. Probably you have some pointers on how to do it?

actually its available from the Package Repository ... Its under bio-linux-staden, staden-io-lib-utils ... That's how I got it installed on my Lucid system

Is it from the official repo? I could install 'staden-io-lib-utils but not 'bio-linux-staden

bio-linux-staden is from the Bio-Linux repository, which has lots of useful packages. Add deb http://nebc.nox.ac.uk/bio-linux/ unstable bio-linux to your /etc/apt/sources.list and do an apt-get update.

Thanks Brad, I always forget that I added the BioLnux repository

Thanks guys :)! I think I got it working now. I ended up making a bash script to iterate through the ab1 files.

I've always converted to Fasta (and qual) with Phred. Don't know how it compares to Staden, but at least with old equipment, you don't want to extract just the sequence data embedded in the trace file, as Phred does (did?) a better job.

There are other options, TraceTuner and PeakTrace, I don't know how well they fare.

Using Biopython:

from Bio import SeqIO
handle = open("test.ab1", "rb")
for record in SeqIO.parse(handle, "abi"):
    print(record)

From here on, you can extract the data and go to any file format you want.

The code Biopython uses to read ABI files was contributed by Bow himself (after this question was written). See the comments on the question itself.

Log in to answer this question.