| 1 | // Copyright ©2015 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 gene contains the types and methods to handle the definition of a |
| 6 | // gene. A gene is a union of genomic sequences encoding a coherent set of |
| 7 | // potentially overlapping functional products. Since the package is located |
| 8 | // under the feat namespace, we define gene to correspond to a specific |
| 9 | // genomic region (has genomic coordinates). |
| 10 | // |
| 11 | // The package also contain types to describe gene transcripts. Transcripts |
| 12 | // can be coding and non-coding. Coding transcripts have functional regions |
| 13 | // (5'UTR, CDS and 3'UTR) and consist of exons. |
| 14 | package genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/ |
| 15 | |
| 16 | import ( |
| 17 | "github.com/biogo/biogo/featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/" |
| 18 | |
| 19 | "errorsscip-go gomod github.com/golang/go/src go1.14 errors/" |
| 20 | "sortscip-go gomod github.com/golang/go/src go1.14 sort/" |
| 21 | ) |
| 22 | |
| 23 | const maxIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/maxInt. = int(^uint(0) >> 1) // The maximum int value. |
| 24 | |
| 25 | // Interface defines the gene interface. |
| 26 | type Interfacescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Interface# interface { |
| 27 | featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# |
| 28 | featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orienterscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orienter# |
| 29 | featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Setscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Set# |
| 30 | SetFeaturesscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Interface#SetFeatures.(...featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature#) error |
| 31 | } |
| 32 | |
| 33 | // Transcript is the interface for a gene transcript. |
| 34 | type Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript# interface { |
| 35 | featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# |
| 36 | featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orienterscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orienter# |
| 37 | Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript#Exons.() Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# |
| 38 | Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript#Introns.() Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Introns# |
| 39 | SetExonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript#SetExons.(...Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) error |
| 40 | } |
| 41 | |
| 42 | // TranscriptsOf scans a feat.Set and returns any Transcripts that it finds. |
| 43 | func TranscriptsOfscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptsOf().(s featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Setscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Set#) []Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript# { |
| 44 | var ts []Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript# |
| 45 | for _, f := range s.Featuresscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Set#Features.() { |
| 46 | if t, ok := f.(Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript#); ok { |
| 47 | ts = append(ts, t) |
| 48 | } |
| 49 | } |
| 50 | return ts |
| 51 | } |
| 52 | |
| 53 | // A Gene occupies a specific region on the genome and may have 0 or more |
| 54 | // features, including transcripts, associated with it. The gene is tightly |
| 55 | // coupled with its features in the sense that the gene boundaries are defined |
| 56 | // by the features. By definition one of the features must always start at |
| 57 | // position 0 relative to the gene and this or another one has to end at the |
| 58 | // end of the gene. The former is asserted when features are set and the |
| 59 | // latter is guaranteed by setting the gene end at the largest end of the |
| 60 | // features. |
| 61 | type Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene# struct { |
| 62 | IDscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#ID. string |
| 63 | Chromscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Chrom. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# |
| 64 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Offset. int |
| 65 | Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Orient. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# |
| 66 | Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Desc. string |
| 67 | lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#length. int |
| 68 | featsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#feats. []featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# |
| 69 | } |
| 70 | |
| 71 | // Start returns the gene start on the chromosome. |
| 72 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Start().() int { return g.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Offset. } |
| 73 | |
| 74 | // End returns the gene end on the chromosome. |
| 75 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#End().() int { return g.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Offset. + g.Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Len().() } |
| 76 | |
| 77 | // Len returns the length of the gene. |
| 78 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Len().() int { return g.lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#length. } |
| 79 | |
| 80 | // Name returns the gene name. Currently the same as the id. |
| 81 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Namescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Name().() string { return g.IDscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#ID. } |
| 82 | |
| 83 | // Description returns a description for the gene. |
| 84 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Descriptionscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Description().() string { return g.Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Desc. } |
| 85 | |
| 86 | // Location returns the location of the gene. Namely the chromosome. |
| 87 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return g.Chromscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Chrom. } |
| 88 | |
| 89 | // Orientation returns the orientation of the gene relative to the chromosome. |
| 90 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Orientation().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# { return g.Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Orient. } |
| 91 | |
| 92 | // Features returns all features added to the gene. |
| 93 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) Featuresscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#Features().() []featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return g.featsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#feats. } |
| 94 | |
| 95 | // SetFeatures sets the gene features. Internally, it verifies that their |
| 96 | // Location is the gene and that one of them has zero Start. If an error |
| 97 | // occurs it is returned and the features are not set. |
| 98 | func (g *Genescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#) SetFeaturesscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#SetFeatures().(feats ...featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature#) error { |
| 99 | pos := maxIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/maxInt. |
| 100 | end := 0 |
| 101 | for _, f := range feats { |
| 102 | if f.Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature#Location.() != g { |
| 103 | return errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("transcript location does not match the gene") |
| 104 | } |
| 105 | if f.Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#Start.() < pos { |
| 106 | pos = f.Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#Start.() |
| 107 | } |
| 108 | if f.Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#End.() > end { |
| 109 | end = f.Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#End.() |
| 110 | } |
| 111 | } |
| 112 | if pos != 0 { |
| 113 | return errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("no transcript with 0 start on gene") |
| 114 | } |
| 115 | g.lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#length. = end - pos |
| 116 | g.featsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Gene#feats. = feats |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | // A NonCodingTranscript is a gene transcript that has no coding potential. It |
| 121 | // can be located on any feat.Feature such as a gene or a chromosome. The |
| 122 | // concept of exons is tightly coupled with the NonCodingTranscript in the |
| 123 | // sense that the transcript borders are basically defined by the contained |
| 124 | // exons. By definition one of the exons must always start at position 0 |
| 125 | // relative to the transcript and this or another one must end at the end of |
| 126 | // transcript. The former is asserted when exons are set and the latter is |
| 127 | // guaranteed by setting the transcript end at the end of the last exon. |
| 128 | type NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript# struct { |
| 129 | IDscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#ID. string |
| 130 | Locscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Loc. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# |
| 131 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Offset. int |
| 132 | Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Orient. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# |
| 133 | Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Desc. string |
| 134 | exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#exons. Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# |
| 135 | } |
| 136 | |
| 137 | // Start returns the transcript start relative to Location. |
| 138 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Start().() int { return t.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Offset. } |
| 139 | |
| 140 | // End returns the transcript end relative to Location. |
| 141 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#End().() int { return t.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Offset. + t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#exons..Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#End().() } |
| 142 | |
| 143 | // Len returns the length of the transcript. |
| 144 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Len().() int { return t.Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#End().() - t.Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Start().() } |
| 145 | |
| 146 | // Name returns the transcript name. Currently the same as the id. |
| 147 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Namescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Name().() string { return t.IDscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#ID. } |
| 148 | |
| 149 | // Description returns a description for the transcript. |
| 150 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Descriptionscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Description().() string { return t.Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Desc. } |
| 151 | |
| 152 | // Location returns the location of the transcript. Can be any feat.Feature |
| 153 | // such as a gene or a chromosome. |
| 154 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return t.Locscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Loc. } |
| 155 | |
| 156 | // Orientation returns the orientation of the transcript relative to Location. |
| 157 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Orientation().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# { return t.Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Orient. } |
| 158 | |
| 159 | // Exons returns a typed slice with the transcript exons. |
| 160 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Exons().() Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# { return t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#exons. } |
| 161 | |
| 162 | // Introns returns a typed slice with the transcript introns. |
| 163 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#Introns().() Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Introns# { return t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#exons..Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Introns().() } |
| 164 | |
| 165 | // SetExons sets the transcript exons. Internally, it sorts exons by Start, |
| 166 | // verifies that their Location is the transcript, that they are not |
| 167 | // overlapping and that one has zero Start. If an error occurs it is returned |
| 168 | // and the exons are not set. |
| 169 | func (t *NonCodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#) SetExonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#SetExons().(exons ...Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) error { |
| 170 | exons, err := buildExonsForscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/buildExonsFor().(t, exons...) |
| 171 | if err != nil { |
| 172 | return err |
| 173 | } |
| 174 | t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/NonCodingTranscript#exons. = exons |
| 175 | return nil |
| 176 | } |
| 177 | |
| 178 | // A CodingTranscript is a gene transcript that has coding potential. It can |
| 179 | // be located on any feat.Feature such as a gene or a chromosome. The concept |
| 180 | // of exons is tightly coupled with the CodingTranscript in the sense that |
| 181 | // the transcript borders are basically defined by the contained exons. By |
| 182 | // definition one of the exons must always start at position 0 relative to the |
| 183 | // transcript and this or another one must end at the transcript end. The |
| 184 | // former is asserted when exons are set and the latter is guaranteed by |
| 185 | // setting the transcript end at the end of the last exon. |
| 186 | type CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript# struct { |
| 187 | IDscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#ID. string |
| 188 | Locscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Loc. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# |
| 189 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Offset. int |
| 190 | Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Orient. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# |
| 191 | Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Desc. string |
| 192 | CDSstartscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSstart. int |
| 193 | CDSendscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSend. int |
| 194 | exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#exons. Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# |
| 195 | } |
| 196 | |
| 197 | // Start returns the transcript start relative to Location. |
| 198 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Start().() int { return t.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Offset. } |
| 199 | |
| 200 | // End returns the transcript end relative to Location. |
| 201 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#End().() int { return t.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Offset. + t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#exons..Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#End().() } |
| 202 | |
| 203 | // Len returns the length of the transcript. |
| 204 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Len().() int { return t.Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#End().() - t.Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Start().() } |
| 205 | |
| 206 | // Name returns the transcript name. Currently the same as the id. |
| 207 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Namescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Name().() string { return t.IDscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#ID. } |
| 208 | |
| 209 | // Description returns a description for the transcript. |
| 210 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Descriptionscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Description().() string { return t.Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Desc. } |
| 211 | |
| 212 | // Location returns the location of the transcript. Can be any feat.Feature |
| 213 | // such as a gene or a chromosome. |
| 214 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return t.Locscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Loc. } |
| 215 | |
| 216 | // Orientation returns the orientation of the transcript relative to Location. |
| 217 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Orientation().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# { |
| 218 | return t.Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Orient. |
| 219 | } |
| 220 | |
| 221 | // UTR5 returns a feat.Feature that corresponds to the 5'UTR of the |
| 222 | // transcript. |
| 223 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) UTR5scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR5().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { |
| 224 | tf := &TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#{Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Transcript.: t, Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Orient.: featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward.} |
| 225 | ori, _ := featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.BaseOrientationOfscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/BaseOrientationOf().(t) |
| 226 | switch ori { |
| 227 | case featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward.: |
| 228 | tf.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. = 0 |
| 229 | tf.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. = t.CDSstartscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSstart. |
| 230 | case featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Reversescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Reverse.: |
| 231 | tf.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. = t.CDSendscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSend. |
| 232 | tf.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. = t.Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Len().() - t.CDSendscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSend. |
| 233 | default: |
| 234 | panic("gene: invalid base orientation for transcript") |
| 235 | } |
| 236 | return tf |
| 237 | } |
| 238 | |
| 239 | // CDS returns a feat.Feature that corresponds to the coding region of the |
| 240 | // transcript. |
| 241 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) CDSscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDS().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { |
| 242 | return &TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#{ |
| 243 | Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Transcript.: t, |
| 244 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset.: t.CDSstartscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSstart., |
| 245 | Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length.: t.CDSendscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSend. - t.CDSstartscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSstart., |
| 246 | Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Orient.: featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward., |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // UTR3 returns a feat.Feature that corresponds to the 3'UTR of the |
| 251 | // transcript. |
| 252 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) UTR3scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR3().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { |
| 253 | tf := &TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#{Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Transcript.: t, Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Orient.: featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward.} |
| 254 | ori, _ := featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.BaseOrientationOfscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/BaseOrientationOf().(t) |
| 255 | switch ori { |
| 256 | case featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward.: |
| 257 | tf.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. = t.CDSendscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSend. |
| 258 | tf.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. = t.Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Len().() - t.CDSendscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSend. |
| 259 | case featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Reversescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Reverse.: |
| 260 | tf.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. = 0 |
| 261 | tf.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. = t.CDSstartscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#CDSstart. |
| 262 | default: |
| 263 | panic("gene: invalid base orientation for transcript") |
| 264 | } |
| 265 | return tf |
| 266 | } |
| 267 | |
| 268 | // UTR5start returns the start of the 5'UTR relative to the transcript. |
| 269 | // UTR5start is shorthand for t.UTR5().Start(). |
| 270 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) UTR5startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR5start().() int { |
| 271 | return t.UTR5scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR5().().Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#Start.() |
| 272 | } |
| 273 | |
| 274 | // UTR5end returns the end of the 5'UTR relative to the transcript. |
| 275 | // UTR5end is shorthand for t.UTR5().End(). |
| 276 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) UTR5endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR5end().() int { |
| 277 | return t.UTR5scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR5().().Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#End.() |
| 278 | } |
| 279 | |
| 280 | // UTR3start returns the start of the 3'UTR relative to the transcript. |
| 281 | // UTR3start is shorthand for t.UTR3().Start(). |
| 282 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) UTR3startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR3start().() int { |
| 283 | return t.UTR3scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR3().().Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#Start.() |
| 284 | } |
| 285 | |
| 286 | // UTR3end returns the end of the 3'UTR relative to the transcript. |
| 287 | // UTR3end is shorthand for t.UTR3().End(). |
| 288 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) UTR3endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR3end().() int { |
| 289 | return t.UTR3scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#UTR3().().Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Range#End.() |
| 290 | } |
| 291 | |
| 292 | // Exons returns a typed slice with the transcript exons. |
| 293 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Exons().() Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# { return t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#exons. } |
| 294 | |
| 295 | // Introns returns a typed slice with the transcript introns. |
| 296 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#Introns().() Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Introns# { return t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#exons..Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Introns().() } |
| 297 | |
| 298 | // SetExons sets the transcript exons. Internally, it sorts exons by Start, |
| 299 | // verifies that their Location is the transcript, that they are not |
| 300 | // overlapping and that one has zero Start. If an error occurs it is returned |
| 301 | // and the exons are not set. |
| 302 | func (t *CodingTranscriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#) SetExonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#SetExons().(exons ...Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) error { |
| 303 | newExons, err := buildExonsForscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/buildExonsFor().(t, exons...) |
| 304 | if err != nil { |
| 305 | return err |
| 306 | } |
| 307 | t.exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/CodingTranscript#exons. = newExons |
| 308 | return nil |
| 309 | } |
| 310 | |
| 311 | // TranscriptFeature defines a feature on a transcript. |
| 312 | type TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature# struct { |
| 313 | Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Transcript. Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript# // Transcript is the transcript that the feature is located. |
| 314 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. int // Offset is the position of the feature relative to Transcript. |
| 315 | Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. int // Length is the feature length. |
| 316 | Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Orient. featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# // Orientation is the feature orientation relative to Transcript. |
| 317 | FeatNamescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#FeatName. string // FeatName is the name of the feature. |
| 318 | Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Desc. string // Desc is the description of the feature. |
| 319 | } |
| 320 | |
| 321 | // Start returns the feature start relative to Transcript. |
| 322 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Start().() int { return t.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. } |
| 323 | |
| 324 | // End returns the feature end relative to TranscriptLocation. |
| 325 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#End().() int { return t.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Offset. + t.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. } |
| 326 | |
| 327 | // Len returns the length of the feature. |
| 328 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Len().() int { return t.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Length. } |
| 329 | |
| 330 | // Name returns an empty string. |
| 331 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Namescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Name().() string { return t.FeatNamescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#FeatName. } |
| 332 | |
| 333 | // Description returns the feature description. |
| 334 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Descriptionscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Description().() string { return t.Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Desc. } |
| 335 | |
| 336 | // Location returns the Transcript. |
| 337 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return t.Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Transcript. } |
| 338 | |
| 339 | // Orientation returns the orientation of the feature relative to Transcript. |
| 340 | func (t *TranscriptFeaturescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#) Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Orientation().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# { |
| 341 | return t.Orientscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/TranscriptFeature#Orient. |
| 342 | } |
| 343 | |
| 344 | // Exons is a typed slice of Exon. It guarantees that exons are always sorted |
| 345 | // by Start, are all located on the same feature and are non overlapping. |
| 346 | type Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# []Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon# |
| 347 | |
| 348 | // SplicedLen returns the total length of the exons. |
| 349 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) SplicedLenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#SplicedLen().() int { |
| 350 | length := 0 |
| 351 | for _, e := range s { |
| 352 | length += e.Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Len().() |
| 353 | } |
| 354 | return length |
| 355 | } |
| 356 | |
| 357 | // Add adds exons to the slice and safeguards the types contracts. It returns |
| 358 | // a new slice with the added exons. It checks for sorting, overlap, and |
| 359 | // location match. If and error occurs it returns the old slice (without the |
| 360 | // new exons) and the error. |
| 361 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Addscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Add().(exons ...Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) (Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#, error) { |
| 362 | newSlice := append(s, exons...) |
| 363 | sortscip-go gomod github.com/golang/go/src go1.14 sort/.Sortscip-go gomod github.com/golang/go/src go1.14 sort/Sort().(newSlice) |
| 364 | for i, e := range newSlice { |
| 365 | if i != 0 && e.Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Start().() < newSlice[i-1].Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#End().() { |
| 366 | return s, errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("exons overlap") |
| 367 | } |
| 368 | if i != 0 && e.Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Location().() != newSlice[i-1].Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Location().() { |
| 369 | return s, errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("exons location differ") |
| 370 | } |
| 371 | |
| 372 | } |
| 373 | if s.Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Location().() != nil && s.Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Location().() != newSlice.Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Location().() { |
| 374 | return s, errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("new exons locations differ from old ones") |
| 375 | } |
| 376 | return newSlice, nil |
| 377 | } |
| 378 | |
| 379 | // Location returns the common location of all the exons. |
| 380 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { |
| 381 | if len(s) == 0 { |
| 382 | return nil |
| 383 | } |
| 384 | return s[0].Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Location().() |
| 385 | } |
| 386 | |
| 387 | // Len returns the number of exons in the slice. |
| 388 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Len().() int { |
| 389 | return len(s) |
| 390 | } |
| 391 | |
| 392 | // Less returns whether the exon with index i should sort before |
| 393 | // the exon with index j. |
| 394 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Lessscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Less().(i, j int) bool { |
| 395 | return s[i].Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Start().() < s[j].Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Start().() |
| 396 | } |
| 397 | |
| 398 | // Swap swaps the exons with indexes i and j. |
| 399 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Swapscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Swap().(i, j int) { |
| 400 | s[i], s[j] = s[j], s[i] |
| 401 | } |
| 402 | |
| 403 | // End returns the maximum End of all exons. Since exons are sorted and non |
| 404 | // overlapping this matches the End of the last exon in the slice. |
| 405 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#End().() int { |
| 406 | if len(s) == 0 { |
| 407 | return 0 |
| 408 | } |
| 409 | return s[len(s)-1].Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#End().() |
| 410 | } |
| 411 | |
| 412 | // Start returns the minimum Start of all exons. Since exons are sorted and |
| 413 | // non overlapping this matches the Start of the first exon in the slice. |
| 414 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Start().() int { |
| 415 | if len(s) == 0 { |
| 416 | return 0 |
| 417 | } |
| 418 | return s[0].Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Start().() |
| 419 | } |
| 420 | |
| 421 | // Introns returns a typed slice of Introns. Introns are built dynamically. |
| 422 | func (s Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#) Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Introns().() Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Introns# { |
| 423 | var introns Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Introns# |
| 424 | if s.Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Len().() < 2 { |
| 425 | return introns |
| 426 | } |
| 427 | for i := 1; i < s.Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Len().(); i++ { |
| 428 | intron := Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#{ |
| 429 | Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Transcript.: s[i].Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Transcript., |
| 430 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Offset.: s[i-1].Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#End().(), |
| 431 | Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Length.: s[i].Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Start().() - s[i-1].Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#End().(), |
| 432 | } |
| 433 | introns = append(introns, intron) |
| 434 | } |
| 435 | return introns |
| 436 | } |
| 437 | |
| 438 | // An Exon is the part of a transcript that remains present in the final |
| 439 | // mature RNA product after splicing. |
| 440 | type Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon# struct { |
| 441 | Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Transcript. Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript# |
| 442 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Offset. int |
| 443 | Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Length. int |
| 444 | Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Desc. string |
| 445 | } |
| 446 | |
| 447 | // Start returns the start position of the exon relative to Transcript. |
| 448 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Start().() int { return e.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Offset. } |
| 449 | |
| 450 | // End returns the end position of the exon relative to Transcript. |
| 451 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#End().() int { return e.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Offset. + e.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Length. } |
| 452 | |
| 453 | // Len returns the length of the exon. |
| 454 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Len().() int { return e.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Length. } |
| 455 | |
| 456 | // Location returns the location of the exon - the transcript. |
| 457 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return e.Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Transcript. } |
| 458 | |
| 459 | // Name returns an empty string. |
| 460 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Namescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Name().() string { return "" } |
| 461 | |
| 462 | // Description returns a description for the exon. |
| 463 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Descriptionscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Description().() string { return e.Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Desc. } |
| 464 | |
| 465 | // Orientation always returns Forward. |
| 466 | func (e Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#Orientation().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# { |
| 467 | return featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward. |
| 468 | } |
| 469 | |
| 470 | // Introns corresponds to a collection of introns. |
| 471 | type Intronsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Introns# []Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron# |
| 472 | |
| 473 | // An Intron is the part of a transcript that is removed during splicing |
| 474 | // and is not part of the final mature RNA product. |
| 475 | type Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron# struct { |
| 476 | Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Transcript. Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript# |
| 477 | Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Offset. int |
| 478 | Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Length. int |
| 479 | Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Desc. string |
| 480 | } |
| 481 | |
| 482 | // Start returns the start position of the intron relative to Transcript. |
| 483 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Start().() int { return i.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Offset. } |
| 484 | |
| 485 | // End returns the end position of the intron relative to Transcript. |
| 486 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Endscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#End().() int { return i.Offsetscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Offset. + i.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Length. } |
| 487 | |
| 488 | // Len returns the length of the intron. |
| 489 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Lenscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Len().() int { return i.Lengthscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Length. } |
| 490 | |
| 491 | // Location returns the location of the intron - the transcript. |
| 492 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Location().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Featurescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Feature# { return i.Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Transcript. } |
| 493 | |
| 494 | // Name returns an empty string. |
| 495 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Namescip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Name().() string { return "" } |
| 496 | |
| 497 | // Description returns a description for the intron. |
| 498 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Descriptionscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Description().() string { return i.Descscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Desc. } |
| 499 | |
| 500 | // Orientation always returns Forward. |
| 501 | func (i Intronscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#) Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Intron#Orientation().() featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Orientationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Orientation# { |
| 502 | return featscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/.Forwardscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat`/Forward. |
| 503 | } |
| 504 | |
| 505 | // buildExonsFor is a helper function that will check if exons are compatible |
| 506 | // with a transcript and return a typed slice of exons. If it encounters an |
| 507 | // error or the exons are not compatible with the transcript it will return |
| 508 | // the error and a possibly partially filled slice. It is not safe to use the |
| 509 | // slice if the error is not nil. |
| 510 | func buildExonsForscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/buildExonsFor().(t Transcriptscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Transcript#, exons ...Exonscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exon#) (Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#, error) { |
| 511 | var newExons Exonsscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons# |
| 512 | newExons, err := newExons.Addscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Add().(exons...) |
| 513 | if err != nil { |
| 514 | return newExons, err |
| 515 | } |
| 516 | if newExons.Locationscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Location().() != t { |
| 517 | return newExons, errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("exon location is not the transcript") |
| 518 | } |
| 519 | if newExons.Startscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/feat/gene`/Exons#Start().() != 0 { |
| 520 | return newExons, errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("no exon with a zero start") |
| 521 | } |
| 522 | return newExons, nil |
| 523 | } |