Debian Codegraph @

seq/annotation.go

raw symbols SCIP
1 // Copyright ©2011-2013 The bíogo Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package seq
6
7 import (
8 "github.com/biogo/biogo/alphabet"
9 "github.com/biogo/biogo/feat"
10 )
11
12 // Strand stores linear sequence strand information.
13 type Strand int8
14
15 const (
16 Minus Strand = iota - 1
17 None
18 Plus
19 )
20
21 func (s Strand) String() string {
22 switch s {
23 case Plus:
24 return "+"
25 case None:
26 return "."
27 case Minus:
28 return "-"
29 }
30 return "undefined"
31 }
32
33 // An Annotation is a basic linear sequence annotation type.
34 type Annotation struct {
35 ID string
36 Desc string
37 Loc feat.Feature
38 Strand Strand
39 Conform feat.Conformation
40 Alpha alphabet.Alphabet
41 Offset int
42 }
43
44 // Name returns the ID string of the sequence.
45 func (a *Annotation) Name() string { return a.ID }
46
47 // SetName sets the ID string of the sequence.
48 func (a *Annotation) SetName(id string) error { a.ID = id; return nil }
49
50 // Description returns the Desc string of the sequence.
51 func (a *Annotation) Description() string { return a.Desc }
52
53 // SetDescription sets the Desc string of the sequence.
54 func (a *Annotation) SetDescription(d string) error { a.Desc = d; return nil }
55
56 // Conformation returns the sequence conformation.
57 func (a *Annotation) Conformation() feat.Conformation { return a.Conform }
58
59 // SetConformation sets the sequence conformation.
60 func (a *Annotation) SetConformation(c feat.Conformation) error { a.Conform = c; return nil }
61
62 // Orientation returns the sequence's strand as a feat.Orientation.
63 func (a *Annotation) Orientation() feat.Orientation { return feat.Orientation(a.Strand) }
64
65 // SetOrientation sets the sequence'a strand from a feat.Orientation.
66 func (a *Annotation) SetOrientation(o feat.Orientation) error { a.Strand = Strand(o); return nil }
67
68 // Location returns the Loc field of the sequence.
69 func (a *Annotation) Location() feat.Feature { return a.Loc }
70
71 // SetLocation sets the Loc field of the sequence.
72 func (a *Annotation) SetLocation(f feat.Feature) error { a.Loc = f; return nil }
73
74 // Alphabet return the alphabet.Alphabet used by the sequence.
75 func (a *Annotation) Alphabet() alphabet.Alphabet { return a.Alpha }
76
77 // SetAlphabet the sets the alphabet.Alphabet used by the sequence.
78 func (a *Annotation) SetAlphabet(n alphabet.Alphabet) error { a.Alpha = n; return nil }
79
80 // SetOffset sets the global offset of the sequence to o.
81 func (a *Annotation) SetOffset(o int) error { a.Offset = o; return nil }
82
83 // Moltype returns the molecule type of the sequence.
84 func (a *Annotation) Moltype() feat.Moltype { return a.Alpha.Moltype() }
85
86 // CloneAnnotation returns a pointer to a copy of the receiver.
87 func (a *Annotation) CloneAnnotation() *Annotation { ca := *a; return &ca }