Class: Bio::Ngs::Cufflinks::Transcript
- Inherits:
-
Object
- Object
- Bio::Ngs::Cufflinks::Transcript
- Defined in:
- lib/bio/appl/ngs/cufflinks/gtf/transcript.rb
Constant Summary collapse
- Fields =
%w(seqname source feature start stop score strand frame)
- Attr_to_Float =
%w(FPKM frac conf_lo conf_hi cov)
- Attr_to_Integer =
%w(exon_number)
- ChrNotation =
{ensembl:"", ucsc:"chr"}
Instance Attribute Summary collapse
-
#chr_notation ⇒ Object
Returns the value of attribute chr_notation.
-
#feature ⇒ Object
Returns the value of attribute feature.
-
#frame ⇒ Object
Returns the value of attribute frame.
-
#score ⇒ Object
Returns the value of attribute score.
-
#seqname ⇒ Object
Returns the value of attribute seqname.
-
#source ⇒ Object
Returns the value of attribute source.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#strand ⇒ Object
Returns the value of attribute strand.
Instance Method Summary collapse
- #annotated_isoform? ⇒ Boolean
- #attributes ⇒ Object
- #brand_new_isoform? ⇒ Boolean
- #byte_length ⇒ Object
- #clear ⇒ Object
- #exons ⇒ Object
- #exons=(ary) ⇒ Object
-
#initialize ⇒ Transcript
constructor
A new instance of Transcript.
- #mono_exon? ⇒ Boolean
- #multi_exons? ⇒ Boolean
- #new_isoform? ⇒ Boolean
- #set_ensembl_notation ⇒ Object
- #set_ucsc_notation ⇒ Object
- #size ⇒ Object
- #to_bed(only_exons = true) ⇒ Object
-
#to_s ⇒ Object
add last ānā to last row.
- #tra ⇒ Object
- #tra=(line) ⇒ Object
Constructor Details
#initialize ⇒ Transcript
Returns a new instance of Transcript.
13 14 15 16 17 18 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 13 def initialize() @tra = nil @exons = [] @attributes = {} @chr_notation = :ensembl #ensembl/ucsc end |
Instance Attribute Details
#chr_notation ⇒ Object
Returns the value of attribute chr_notation.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def chr_notation @chr_notation end |
#feature ⇒ Object
Returns the value of attribute feature.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def feature @feature end |
#frame ⇒ Object
Returns the value of attribute frame.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def frame @frame end |
#score ⇒ Object
Returns the value of attribute score.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def score @score end |
#seqname ⇒ Object
Returns the value of attribute seqname.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def seqname @seqname end |
#source ⇒ Object
Returns the value of attribute source.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def source @source end |
#start ⇒ Object
Returns the value of attribute start.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def stop @stop end |
#strand ⇒ Object
Returns the value of attribute strand.
11 12 13 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 11 def strand @strand end |
Instance Method Details
#annotated_isoform? ⇒ Boolean
135 136 137 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 135 def annotated_isoform? attributes[:gene_id]!~/CUFF\.\d+/ && attributes[:transcript_id]!~/CUFF\.\d+\.\d+/ end |
#attributes ⇒ Object
38 39 40 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 38 def attributes @attributes end |
#brand_new_isoform? ⇒ Boolean
127 128 129 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 127 def brand_new_isoform? attributes[:gene_id]=~/CUFF\.\d+/ && attributes[:transcript_id]=~/CUFF\.\d+\.\d+/ end |
#byte_length ⇒ Object
139 140 141 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 139 def byte_length exons.map{|e| e.length}.sum + tra.length end |
#clear ⇒ Object
122 123 124 125 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 122 def clear @tra="" @exons.clear end |
#exons ⇒ Object
30 31 32 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 30 def exons @exons end |
#exons=(ary) ⇒ Object
34 35 36 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 34 def exons=(ary) @exons=ary end |
#mono_exon? ⇒ Boolean
68 69 70 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 68 def mono_exon? exons.size == 1 end |
#multi_exons? ⇒ Boolean
64 65 66 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 64 def multi_exons? exons.size > 1 end |
#new_isoform? ⇒ Boolean
131 132 133 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 131 def new_isoform? attributes[:gene_id]=~/CUFF\.\d+/ && attributes[:transcript_id]!~/CUFF\.\d+\.\d+/ end |
#set_ensembl_notation ⇒ Object
147 148 149 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 147 def set_ensembl_notation @chr_notation = :ensembl end |
#set_ucsc_notation ⇒ Object
143 144 145 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 143 def set_ucsc_notation @chr_notation = :ucsc end |
#size ⇒ Object
72 73 74 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 72 def size @stop-@start+1 end |
#to_bed(only_exons = true) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 96 def to_bed(only_exons=true) bed_str="" unless only_exons # puts seqname #TODO fix seqname does not print the right transcript line if @chr_notation == :ensembl && seqname=~/^chr(.*)/ seqname="#{ChrNotation[:ensembl]}#{$1}" elsif @chr_notation == :ucsc && seqname=~/^(.*)/ seqname="#{ChrNotation[:ucsc]}#{$1}" end bed_str<<"#{seqname}\t#{start}\t#{stop}\t#{attributes[:gene_id]}_#{attributes[:transcript_id]}\n" end exons.each do |e| data = e.tr('";','').split if @chr_notation == :ensembl && data[0]=~/^chr(.*)/ data[0]="#{ChrNotation[:ensembl]}#{$1}" elsif @chr_notation == :ucsc && data[0]=~/^(.*)/ data[0]="#{ChrNotation[:ucsc]}#{$1}" end bed_str<<"#{data[0]}\t#{data[3]}\t#{data[4]}\t#{data[9]}_#{data[11]}\n" end bed_str end |
#to_s ⇒ Object
add last ānā to last row.
91 92 93 94 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 91 def to_s s=tra #+"\n" s << exons.join #("\n") #<< "\n" end |
#tra ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 20 def tra if @chr_notation == :ensembl && @tra=~/^chr(.*?)\s/ "#{ChrNotation[:ensembl]}#{$1}" elsif @chr_notation == :ucsc && @tra=~/^(.*?)\s/ "#{ChrNotation[:ucsc]}#{$1}" else @tra end end |
#tra=(line) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bio/appl/ngs/cufflinks/gtf/transcript.rb', line 41 def tra=(line) @tra = line data=line.split @seqname = data[0] @source = data[1] @feature = data[2] @start = data[3].to_i @stop = data[4].to_i @score = data[5] @strand = data[6] @frame = data[7] data[8..-1].join(" ").split(';').each do |attribute| data_attr=attribute.tr('"','').split @attributes[data_attr[0].to_sym]= if Attr_to_Float.include? data_attr[0] data_attr[1].to_f elsif Attr_to_Integer.include? data_attr[0] data_attr[1].to_i else data_attr[1] end end end |