Skip to content

Commit 7950d60

Browse files
author
Wibowo Arindrarto
committed
major rewrite (methods, attributes) for more flexible data access
1 parent 2af3c73 commit 7950d60

File tree

2 files changed

+168
-120
lines changed

2 files changed

+168
-120
lines changed

README.rst

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Python module for reading .ab1 trace files
88

99
abifpy is a python module that extracts sequence and various other data from
1010
Applied Biosystem's, Inc. format (ABIF) file. The module was written based on
11-
the `official spec`_ released by Applied Biosystem.
11+
the `official spec`_ released by Applied Biosystems.
1212

1313
Usage
1414
=====
@@ -19,43 +19,65 @@ Usage
1919
>>> import abifpy
2020
>>> yummy = abifpy.Trace('tracefile.ab1')
2121

22-
Or if you want to perform trimming directly: ::
22+
Or if you want to perform base trimming directly: ::
2323
2424
>>> yummy = abifpy.Trace('tracefile.ab1', trimming=True)
2525

26-
By default, only these data are extracted: ::
26+
The module can be used with Biopython if it is installed. It provides the
27+
following methods: ::
28+
29+
yummy.write(out_file="", qual=0)
30+
# writes a fasta (qual=0), qual (qual=1), or fastq (qual=1) file from the trace file
31+
# default output is tracefile.fa
32+
33+
yummy.seq()
34+
# returns a string of nucleotide sequence as called by the basecaller
35+
36+
yummy.qual(char=True)
37+
# returns a list of ascii characters of phred quality values (offset 33)
38+
# if char=False, the phred quality values is returned instead
39+
40+
yummy.trim()
41+
# trims the sequence using Richard Mott's algorithm (used in phred)
42+
# can be used for trimming quality values returned by yummy.qual() as well
43+
44+
yummy.seqrecord()
45+
# returns a SeqRecord object of the trace file
46+
47+
yummy.get_dir()
48+
# returns a metadata stored in the file, accepts keys from yummy.tags (see below)
49+
# half-cooked method, not yet capable of extracting the entire file metadata
50+
51+
The file metadata (e.g. sample well, sequencing instrument) can be looked up in
52+
the ``self.meta`` dictionary: ::
2753

28-
yummy.seq # string of untrimmed sequence as called by the basecaller
29-
yummy.qual # list of quality values after basecalling
30-
yummy.sampleid # string of sample ID entered before the run
31-
yummy.well # string of well ID
32-
yummy.instrument # string of sequencing machine model
33-
yummy.id # string of trace file name
54+
yummy.meta['sampleid'] # string of sample ID entered before the run
55+
yummy.meta['well'] # string of well ID
56+
yummy.meta['instrument'] # string of sequencing machine model
57+
yummy.meta['id'] # string of trace file name
58+
59+
Keys for ``yummy.meta`` are the values of ``abifpy.TAGS``, except for ``'id'``.
3460

3561
Additionally, these attributes can also be accessed: ::
3662

3763
yummy.tags # dictionary of tags with values of directory contents
38-
yummy.score # scores used for trimming, accessible after trim() is invoked
3964
yummy._header # tuple of extracted header values
40-
yummy._data # string representation of file contents
65+
yummy._raw # string representation of file contents
4166

42-
You can invoke the ``all_tags=True`` option when instantiating the class to get
43-
all tags available. These tags can then be viewed with the ``yummy.tags``
44-
attribute. Be warned that the module can only read data from the extracted tags
45-
above. If you want to make sense of the extra tags, refer to the `official
46-
spec`_.
67+
You can get the metadata not contained in ``yummy.meta`` by using ``yummy.get_dir()``
68+
with one of the keys in ``yummy.tags`` as the argument, e.g.::
4769

48-
The module can be used with Biopython if it is installed. It provides the
49-
following methods::
70+
>>> yummy.get_dir('GTyp1')
71+
'POP7'
5072

51-
yummy.write() # writes a fasta file of the trace file
52-
yummy.trim() # trims the sequence using Richard Mott's algorithm (used in phred)
53-
yummy.seqrecord() # returns a SeqRecord object of the trace file
73+
Be warned though that this method is half-cooked. Sometimes it returns the value you want,
74+
other times it will only return ``None``. For more info on the file metadata, refer to
75+
the `official spec`_.
5476

5577
Installation
5678
============
5779

58-
Just add the abifpy directory to your ``$PYTHONPATH`` (in .bashrc to make it persistent)
80+
Just add the abifpy directory to your ``$PYTHONPATH`` (in ``.bashrc`` to make it persistent).
5981

6082
License
6183
=======

0 commit comments

Comments
 (0)