| Trees | Indices | Help |
|---|
|
|
1 # Copyright 2006 by Peter Cock. All rights reserved.
2 #
3 # This code is part of the Biopython distribution and governed by its
4 # license. Please see the LICENSE file that should have been included
5 # as part of this package.
6 """Bio.SeqIO support for the "nexus" file format.
7
8 You were expected to use this module via the Bio.SeqIO functions.
9 This module has now been replaced by Bio.AlignIO.NexusIO, and is
10 deprecated."""
11
12 import warnings
13 warnings.warn("Bio.SeqIO.NexusIO is deprecated. You can continue to read" \
14 + " 'nexus' files with Bio.SeqIO, but this is now" \
15 + " handled via Bio.AlignIO internally.",
16 DeprecationWarning)
17
18 from Bio.Seq import Seq
19 from Bio.SeqRecord import SeqRecord
20 from Bio.Nexus import Nexus
21
22 #You can get a couple of example files here:
23 #http://www.molecularevolution.org/resources/fileformats/
24
25 #This is a generator function!
27 """Returns SeqRecord objects from a Nexus file.
28
29 Thus uses the Bio.Nexus module to do the hard work."""
30 n = Nexus.Nexus(handle)
31 for id in n.original_taxon_order :
32 if id in n.matrix :
33 seq = n.matrix[id]
34 else :
35 #Missing the sequence?
36 seq = Seq("", n.alphabet)
37 #ToDo - Can we extract any annotation too?
38 yield SeqRecord(seq, id=id, name=id, description="")
39 #All done
40 return
41
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Mon Sep 15 09:23:01 2008 | http://epydoc.sourceforge.net |