1
2
3
4
5
6
7 """Bio.SeqIO support for the "ace" file format.
8
9 You are expected to use this module via the Bio.SeqIO functions.
10 See also the Bio.Sequencing.Ace module which offers more than just accessing
11 the contig consensus sequences in an ACE file as SeqRecord objects."""
12
13 from Bio.Seq import Seq
14 from Bio.SeqRecord import SeqRecord
15 from Bio.Alphabet import generic_nucleotide, Gapped
16 from Bio.Sequencing import Ace
17
18
20 """Returns SeqRecord objects from an ACE file.
21
22 This uses the Bio.Sequencing.Ace module to do the hard work. Note that
23 by iterating over the file in a single pass, we are forced to ignore any
24 WA, CT, RT or WR footer tags."""
25
26 for ace_contig in Ace.Iterator(handle, Ace.RecordParser()) :
27
28 consensus_seq_str = ace_contig.sequence
29 if "*" in consensus_seq_str :
30
31
32 assert "-" not in consensus_seq_str
33 consensus_seq = Seq(consensus_seq_str.replace("*","-"),
34 Gapped(generic_nucleotide, gap_char="-"))
35 else :
36 consensus_seq = Seq(consensus_seq_str, generic_nucleotide)
37
38
39
40
41
42
43
44
45
46
47
48
49 seq_record = SeqRecord(consensus_seq,
50 id = ace_contig.name,
51 name = ace_contig.name)
52 yield seq_record
53
54