I would like to view the chromatogram traces from a few ABI (.ab1) files. I would prefer to use python for this, or a function with python bindings, or at least some open source package such as EMBOSS.

If after viewing a plot I could also extract the plotted data in the form of an array, that would be a huge plus.

I have tried the relevant Biopython parser, but it only returns a list of nucleotides (not th actual chromatogram). I have also tried abiview, but I get plots such as this, which makes absolutely no sense:

enter image description here

Could you help me out?

  • $\begingroup$ Is there anything that you want to do with the file that you can't already do with a free package such as Finch TV? $\endgroup$
    – March Ho
    Commented Jul 7, 2015 at 13:42
  • 1
    $\begingroup$ I think this might explain the .AB1 file format, which would be the first step toward writing your own file parser. If you can get the X and Y data out for each channel, you could plot it however you wanted. Good luck. $\endgroup$
    – user137
    Commented Jul 7, 2015 at 14:02
  • $\begingroup$ Have you looked at abiview from the package EMBOSS? See this Biostars post: biostars.org/p/4097 $\endgroup$ Commented Jul 7, 2015 at 16:15

2 Answers 2


The Biopython 1.65 ABI parser should expose the chromatogram data, as of Biopython 1.66 it should expose everything.

UPDATE: Example using this for plotting here: http://biopython.org/wiki/ABI_traces


I would strongly recommend using Matlab, it does not read ab1 files directly, but it can if Staden tools are installed. The reason being is that the data is presented a lot better and there is documentation. I recently wrote a QQC calculation script in Matlab as proof of principle and I will rewrite it in python (due to server building) using it as a benchmark.

In Biopython the manual says:

from Bio import SeqIO
handle = open("myfile.ab1", "rb")
record=SeqIO.read(handle, "abi")

And that is where it stops. It does have the data. The trace data is stored as annotations:

import json
print(json.dumps(record.annotations, sort_keys=True, indent=4))

Specifically, the actual raw data is:


but wait! The bases are not ATGC. but GATC as found here:


Having played with ab1 files in Matlab using the command:

[Sample, Probability] = scfread('temp_via_matlab.scf');

I know that there is not only raw data (Sample), but also probability data. The latter tells me where the peaks are (e.g. Probability.peak_index(100)) and how good they are. This will be very helpful. That data is saved here:

print('PLOC1 is peak_index in Matlab', record.annotations['abif_raw']['PLOC1']) # tuple of int
print('PBAS1 is what base it is', record.annotations['abif_raw']['PBAS1']) # str

Note that it is a wee bit different from MatLab and there are keys called PLOC2 and PBAS2 which have the same data as their 1 counterparts from what I can tell.
For a more detailed explanation of the many keys present see the vignette for the R package sangerseqR, which does the same and is annotated slightly better than biopython —although scfread in Matlab is a lot more neater (hence my recommendation).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .