1
2
3
4
6 """A SeqRecord object holds a sequence and information about it.
7
8 Main attributes:
9 id - Identifier such as a locus tag (string)
10 seq - The sequence itself (Seq object)
11
12 Additional attributes:
13 name - Sequence name, e.g. gene name (string)
14 description - Additional text (string)
15 dbxrefs - List of database cross references (list of strings)
16 features - Any (sub)features defined (list of SeqFeature objects)
17 annotations - Further information about the whole sequence (dictionary)
18 """
19 - def __init__(self, seq, id = "<unknown id>", name = "<unknown name>",
20 description = "<unknown description>", dbxrefs = None,
21 features = None):
22 """Create a SeqRecord
23
24 Arguments:
25 seq - Sequence, required (Seq object)
26 id - Sequence identifier, recommended (string)
27 name - Seqeuence name, optional (string)
28 description - Seqeuence description, optional (string)
29 dbxrefs - Database cross references, optional (list of strings)
30 features - Any (sub)features, optional (list of SeqFeature objects)
31
32 Note that while an id is optional, we strongly recommend you supply a
33 unique id string for each record. This is especially important
34 if you wish to write your sequences to a file.
35
36 You can create a 'blank' SeqRecord object can then populated the
37 attributes later. Note that currently the annotations dictionary
38 cannot be specified when creating the SeqRecord."""
39 self.seq = seq
40 self.id = id
41 self.name = name
42 self.description = description
43 if dbxrefs is None:
44 dbxrefs = []
45 self.dbxrefs = dbxrefs
46
47 self.annotations = {}
48
49
50 if features is None:
51 features = []
52 self.features = features
53
65
67 return "SeqRecord(seq=%s, id=%s, name=%s, description=%s, dbxrefs=%s)" \
68 % tuple(map(repr, (self.seq, self.id, self.name,
69 self.description, self.dbxrefs)))
70
71 if __name__ == "__main__" :
72
73 from Bio.Seq import Seq
74 from Bio.Alphabet import generic_protein
75 record = SeqRecord(Seq("MASRGVNKVILVGNLGQDPEVRYMPNGGAVANITLATSESWRDKAT" \
76 +"GEMKEQTEWHRVVLFGKLAEVASEYLRKGSQVYIEGQLRTRKWTDQ" \
77 +"SGQDRYTTEVVVNVGGTMQMLGGRQGGGAPAGGNIGGGQPQGGWGQ" \
78 +"PQQPQGGNQFSGGAQSRPQQSAPAAPSNEPPMDFDDDIPF",
79 generic_protein),
80 id="NP_418483.1", name="b4059",
81 description="ssDNA-binding protein",
82 dbxrefs=["ASAP:13298", "GI:16131885", "GeneID:948570"])
83
84
85 record.annotations["note"] = "This annotation was added later"
86
87 print record
88
89
90 record2 = SeqRecord(Seq(""))
91