gene

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2021 License: BSD-3-Clause Imports: 3 Imported by: 3

Documentation

Overview

Package gene contains the types and methods to handle the definition of a gene. A gene is a union of genomic sequences encoding a coherent set of potentially overlapping functional products. Since the package is located under the feat namespace, we define gene to correspond to a specific genomic region (has genomic coordinates).

The package also contain types to describe gene transcripts. Transcripts can be coding and non-coding. Coding transcripts have functional regions (5'UTR, CDS and 3'UTR) and consist of exons.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodingTranscript

type CodingTranscript struct {
	ID       string
	Loc      feat.Feature
	Offset   int
	Orient   feat.Orientation
	Desc     string
	CDSstart int
	CDSend   int
	// contains filtered or unexported fields
}

A CodingTranscript is a gene transcript that has coding potential. It can be located on any feat.Feature such as a gene or a chromosome. The concept of exons is tightly coupled with the CodingTranscript in the sense that the transcript borders are basically defined by the contained exons. By definition one of the exons must always start at position 0 relative to the transcript and this or another one must end at the transcript end. The former is asserted when exons are set and the latter is guaranteed by setting the transcript end at the end of the last exon.

func (*CodingTranscript) CDS added in v1.0.1

func (t *CodingTranscript) CDS() feat.Feature

CDS returns a feat.Feature that corresponds to the coding region of the transcript.

func (*CodingTranscript) Description

func (t *CodingTranscript) Description() string

Description returns a description for the transcript.

func (*CodingTranscript) End

func (t *CodingTranscript) End() int

End returns the transcript end relative to Location.

func (*CodingTranscript) Exons

func (t *CodingTranscript) Exons() Exons

Exons returns a typed slice with the transcript exons.

func (*CodingTranscript) Introns

func (t *CodingTranscript) Introns() Introns

Introns returns a typed slice with the transcript introns.

func (*CodingTranscript) Len

func (t *CodingTranscript) Len() int

Len returns the length of the transcript.

func (*CodingTranscript) Location

func (t *CodingTranscript) Location() feat.Feature

Location returns the location of the transcript. Can be any feat.Feature such as a gene or a chromosome.

func (*CodingTranscript) Name

func (t *CodingTranscript) Name() string

Name returns the transcript name. Currently the same as the id.

func (*CodingTranscript) Orientation

func (t *CodingTranscript) Orientation() feat.Orientation

Orientation returns the orientation of the transcript relative to Location.

func (*CodingTranscript) SetExons

func (t *CodingTranscript) SetExons(exons ...Exon) error

SetExons sets the transcript exons. Internally, it sorts exons by Start, verifies that their Location is the transcript, that they are not overlapping and that one has zero Start. If an error occurs it is returned and the exons are not set.

func (*CodingTranscript) Start

func (t *CodingTranscript) Start() int

Start returns the transcript start relative to Location.

func (*CodingTranscript) UTR3 added in v1.0.1

func (t *CodingTranscript) UTR3() feat.Feature

UTR3 returns a feat.Feature that corresponds to the 3'UTR of the transcript.

func (*CodingTranscript) UTR3end

func (t *CodingTranscript) UTR3end() int

UTR3end returns the end of the 3'UTR relative to the transcript. UTR3end is shorthand for t.UTR3().End().

func (*CodingTranscript) UTR3start

func (t *CodingTranscript) UTR3start() int

UTR3start returns the start of the 3'UTR relative to the transcript. UTR3start is shorthand for t.UTR3().Start().

func (*CodingTranscript) UTR5 added in v1.0.1

func (t *CodingTranscript) UTR5() feat.Feature

UTR5 returns a feat.Feature that corresponds to the 5'UTR of the transcript.

func (*CodingTranscript) UTR5end

func (t *CodingTranscript) UTR5end() int

UTR5end returns the end of the 5'UTR relative to the transcript. UTR5end is shorthand for t.UTR5().End().

func (*CodingTranscript) UTR5start

func (t *CodingTranscript) UTR5start() int

UTR5start returns the start of the 5'UTR relative to the transcript. UTR5start is shorthand for t.UTR5().Start().

type Exon

type Exon struct {
	Transcript Transcript
	Offset     int
	Length     int
	Desc       string
}

An Exon is the part of a transcript that remains present in the final mature RNA product after splicing.

func (Exon) Description

func (e Exon) Description() string

Description returns a description for the exon.

func (Exon) End

func (e Exon) End() int

End returns the end position of the exon relative to Transcript.

func (Exon) Len

func (e Exon) Len() int

Len returns the length of the exon.

func (Exon) Location

func (e Exon) Location() feat.Feature

Location returns the location of the exon - the transcript.

func (Exon) Name

func (e Exon) Name() string

Name returns an empty string.

func (Exon) Orientation

func (e Exon) Orientation() feat.Orientation

Orientation always returns Forward.

func (Exon) Start

func (e Exon) Start() int

Start returns the start position of the exon relative to Transcript.

type Exons

type Exons []Exon

Exons is a typed slice of Exon. It guarantees that exons are always sorted by Start, are all located on the same feature and are non overlapping.

func (Exons) Add

func (s Exons) Add(exons ...Exon) (Exons, error)

Add adds exons to the slice and safeguards the types contracts. It returns a new slice with the added exons. It checks for sorting, overlap, and location match. If and error occurs it returns the old slice (without the new exons) and the error.

func (Exons) End

func (s Exons) End() int

End returns the maximum End of all exons. Since exons are sorted and non overlapping this matches the End of the last exon in the slice.

func (Exons) Introns

func (s Exons) Introns() Introns

Introns returns a typed slice of Introns. Introns are built dynamically.

func (Exons) Len

func (s Exons) Len() int

Len returns the number of exons in the slice.

func (Exons) Less

func (s Exons) Less(i, j int) bool

Less returns whether the exon with index i should sort before the exon with index j.

func (Exons) Location

func (s Exons) Location() feat.Feature

Location returns the common location of all the exons.

func (Exons) SplicedLen

func (s Exons) SplicedLen() int

SplicedLen returns the total length of the exons.

func (Exons) Start

func (s Exons) Start() int

Start returns the minimum Start of all exons. Since exons are sorted and non overlapping this matches the Start of the first exon in the slice.

func (Exons) Swap

func (s Exons) Swap(i, j int)

Swap swaps the exons with indexes i and j.

type Gene

type Gene struct {
	ID     string
	Chrom  feat.Feature
	Offset int
	Orient feat.Orientation
	Desc   string
	// contains filtered or unexported fields
}

A Gene occupies a specific region on the genome and may have 0 or more features, including transcripts, associated with it. The gene is tightly coupled with its features in the sense that the gene boundaries are defined by the features. By definition one of the features must always start at position 0 relative to the gene and this or another one has to end at the end of the gene. The former is asserted when features are set and the latter is guaranteed by setting the gene end at the largest end of the features.

func (*Gene) Description

func (g *Gene) Description() string

Description returns a description for the gene.

func (*Gene) End

func (g *Gene) End() int

End returns the gene end on the chromosome.

func (*Gene) Features

func (g *Gene) Features() []feat.Feature

Features returns all features added to the gene.

func (*Gene) Len

func (g *Gene) Len() int

Len returns the length of the gene.

func (*Gene) Location

func (g *Gene) Location() feat.Feature

Location returns the location of the gene. Namely the chromosome.

func (*Gene) Name

func (g *Gene) Name() string

Name returns the gene name. Currently the same as the id.

func (*Gene) Orientation

func (g *Gene) Orientation() feat.Orientation

Orientation returns the orientation of the gene relative to the chromosome.

func (*Gene) SetFeatures

func (g *Gene) SetFeatures(feats ...feat.Feature) error

SetFeatures sets the gene features. Internally, it verifies that their Location is the gene and that one of them has zero Start. If an error occurs it is returned and the features are not set.

func (*Gene) Start

func (g *Gene) Start() int

Start returns the gene start on the chromosome.

type Interface

type Interface interface {
	feat.Feature
	feat.Orienter
	feat.Set
	SetFeatures(...feat.Feature) error
}

Interface defines the gene interface.

type Intron

type Intron struct {
	Transcript Transcript
	Offset     int
	Length     int
	Desc       string
}

An Intron is the part of a transcript that is removed during splicing and is not part of the final mature RNA product.

func (Intron) Description

func (i Intron) Description() string

Description returns a description for the intron.

func (Intron) End

func (i Intron) End() int

End returns the end position of the intron relative to Transcript.

func (Intron) Len

func (i Intron) Len() int

Len returns the length of the intron.

func (Intron) Location

func (i Intron) Location() feat.Feature

Location returns the location of the intron - the transcript.

func (Intron) Name

func (i Intron) Name() string

Name returns an empty string.

func (Intron) Orientation

func (i Intron) Orientation() feat.Orientation

Orientation always returns Forward.

func (Intron) Start

func (i Intron) Start() int

Start returns the start position of the intron relative to Transcript.

type Introns

type Introns []Intron

Introns corresponds to a collection of introns.

type NonCodingTranscript

type NonCodingTranscript struct {
	ID     string
	Loc    feat.Feature
	Offset int
	Orient feat.Orientation
	Desc   string
	// contains filtered or unexported fields
}

A NonCodingTranscript is a gene transcript that has no coding potential. It can be located on any feat.Feature such as a gene or a chromosome. The concept of exons is tightly coupled with the NonCodingTranscript in the sense that the transcript borders are basically defined by the contained exons. By definition one of the exons must always start at position 0 relative to the transcript and this or another one must end at the end of transcript. The former is asserted when exons are set and the latter is guaranteed by setting the transcript end at the end of the last exon.

func (*NonCodingTranscript) Description

func (t *NonCodingTranscript) Description() string

Description returns a description for the transcript.

func (*NonCodingTranscript) End

func (t *NonCodingTranscript) End() int

End returns the transcript end relative to Location.

func (*NonCodingTranscript) Exons

func (t *NonCodingTranscript) Exons() Exons

Exons returns a typed slice with the transcript exons.

func (*NonCodingTranscript) Introns

func (t *NonCodingTranscript) Introns() Introns

Introns returns a typed slice with the transcript introns.

func (*NonCodingTranscript) Len

func (t *NonCodingTranscript) Len() int

Len returns the length of the transcript.

func (*NonCodingTranscript) Location

func (t *NonCodingTranscript) Location() feat.Feature

Location returns the location of the transcript. Can be any feat.Feature such as a gene or a chromosome.

func (*NonCodingTranscript) Name

func (t *NonCodingTranscript) Name() string

Name returns the transcript name. Currently the same as the id.

func (*NonCodingTranscript) Orientation

func (t *NonCodingTranscript) Orientation() feat.Orientation

Orientation returns the orientation of the transcript relative to Location.

func (*NonCodingTranscript) SetExons

func (t *NonCodingTranscript) SetExons(exons ...Exon) error

SetExons sets the transcript exons. Internally, it sorts exons by Start, verifies that their Location is the transcript, that they are not overlapping and that one has zero Start. If an error occurs it is returned and the exons are not set.

func (*NonCodingTranscript) Start

func (t *NonCodingTranscript) Start() int

Start returns the transcript start relative to Location.

type Transcript

type Transcript interface {
	feat.Feature
	feat.Orienter
	Exons() Exons
	Introns() Introns
	SetExons(...Exon) error
}

Transcript is the interface for a gene transcript.

func TranscriptsOf

func TranscriptsOf(s feat.Set) []Transcript

TranscriptsOf scans a feat.Set and returns any Transcripts that it finds.

type TranscriptFeature added in v1.0.1

type TranscriptFeature struct {
	Transcript Transcript       // Transcript is the transcript that the feature is located.
	Offset     int              // Offset is the position of the feature relative to Transcript.
	Length     int              // Length is the feature length.
	Orient     feat.Orientation // Orientation is the feature orientation relative to Transcript.
	FeatName   string           // FeatName is the name of the feature.
	Desc       string           // Desc is the description of the feature.
}

TranscriptFeature defines a feature on a transcript.

func (*TranscriptFeature) Description added in v1.0.1

func (t *TranscriptFeature) Description() string

Description returns the feature description.

func (*TranscriptFeature) End added in v1.0.1

func (t *TranscriptFeature) End() int

End returns the feature end relative to TranscriptLocation.

func (*TranscriptFeature) Len added in v1.0.1

func (t *TranscriptFeature) Len() int

Len returns the length of the feature.

func (*TranscriptFeature) Location added in v1.0.1

func (t *TranscriptFeature) Location() feat.Feature

Location returns the Transcript.

func (*TranscriptFeature) Name added in v1.0.1

func (t *TranscriptFeature) Name() string

Name returns an empty string.

func (*TranscriptFeature) Orientation added in v1.0.1

func (t *TranscriptFeature) Orientation() feat.Orientation

Orientation returns the orientation of the feature relative to Transcript.

func (*TranscriptFeature) Start added in v1.0.1

func (t *TranscriptFeature) Start() int

Start returns the feature start relative to Transcript.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL