Class: Bio::Util::SynReport
- Inherits:
-
Object
- Object
- Bio::Util::SynReport
- Defined in:
- lib/bio/utils/bio-synreport.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ SynReport
constructor
attr_accessor :cdshash, :cds_list, :mRNAhash, :seqhash.
-
#is_in_cds?(chr, point) ⇒ Boolean
init end.
-
#mutation_info(chr, pos, alt) ⇒ Object
returns mutation info if point in CDS, if not in CDS returns false.
Constructor Details
#initialize(opts) ⇒ SynReport
attr_accessor :cdshash, :cds_list, :mRNAhash, :seqhash
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/bio/utils/bio-synreport.rb', line 97 def initialize(opts) cdses = [] mrna_list = [] seqs = Hash.new Bio::FastaFormat.open(opts[:fasta]).each { |seq| seqs[seq.entry_id] = seq.to_seq } $stderr.puts "Loaded Seq..." if opts[:verbose] @mrnas = Hash.new {|h,k| h[k] = Hash.new} File.open(opts[:gff], "r").each do |gffline| record = Bio::GFF::GFF3::Record.new(gffline) if record.feature_type == 'mRNA' mrna_list << Bio::Util::MrnaModel.new(gffline) elsif record.feature_type =='CDS' cdses << record end end mrna_list.each do |mrna| mrna_id = mrna.get_attributes("ID") $stderr.puts "No ID for #{cds}" if mrna_id.empty? mrna_id = mrna_id.first @mrnas[mrna.seqname][mrna_id] = mrna @mrnas[mrna.seqname][mrna_id].seq = seqs[mrna_id].seq end cdses.each do |cds| cds_parent = cds.get_attributes("Parent") $stderr.puts "No Parent for #{cds}" if cds_parent.empty? cds_parent = cds_parent.first @mrnas[cds.seqname][cds_parent].cds << [cds.start,cds.end] end $stderr.puts "Loaded GFF..." if opts[:verbose] end |
Instance Method Details
#is_in_cds?(chr, point) ⇒ Boolean
init end
135 136 137 |
# File 'lib/bio/utils/bio-synreport.rb', line 135 def is_in_cds?(chr,point) self.mutation_info(chr,point,"a") ? true : false end |
#mutation_info(chr, pos, alt) ⇒ Object
returns mutation info if point in CDS, if not in CDS returns false
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/bio/utils/bio-synreport.rb', line 140 def mutation_info(chr,pos,alt) pos = pos.to_i #cant do indels ... return nil if alt.length > 1 begin @mrnas[chr].each_pair do |mrna_id, mrna| if mrna.includes?(chr,pos) return mrna.substitution_info(pos,alt) end end false rescue #somthing unpredicatable went wrong and we couldnt do the conversion ... return nil end end |