Class: Scaffolder::AnnotationLocator
- Inherits:
-
Array
- Object
- Array
- Scaffolder::AnnotationLocator
- Defined in:
- lib/scaffolder/annotation_locator.rb
Instance Method Summary collapse
-
#initialize(scaffold_file, sequence_file, gff_file) ⇒ AnnotationLocator
constructor
A new instance of AnnotationLocator.
- #records ⇒ Object
- #scaffold ⇒ Object
Constructor Details
#initialize(scaffold_file, sequence_file, gff_file) ⇒ AnnotationLocator
Returns a new instance of AnnotationLocator.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/scaffolder/annotation_locator.rb', line 10 def initialize(scaffold_file,sequence_file,gff_file) @scaffold_file = scaffold_file @sequence_file = sequence_file @gff_file = gff_file updated_records = Array.new scaffold.inject(0) do |prior_length,entry| if entry.entry_type == :sequence records[entry.source].each do |record| # Don't include this record if it overlaps with an insert next if record.overlap?(entry.inserts.map{|i| (i.open..i.close)}) # Skip this record it lies in the start or stop trimmed regions next if record.start < entry.start next if record.end > entry.stop # Update record location by size differences of prior inserts entry.inserts.select {|i| i.close < record.start }.each do |insert| record.change_position_by insert.size_diff end # Decrease record position by distance contig is trimmed at start record.change_position_by(1 - entry.start) # Reverse complement record positions if contig is reversed record.reverse_complement_by entry.sequence.length if entry.reverse # Increase record position by length of prior contigs record.change_position_by prior_length record.seqname = "scaffold" updated_records << record end end prior_length + entry.sequence.length end super updated_records end |
Instance Method Details
#records ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/scaffolder/annotation_locator.rb', line 59 def records gff3 = Bio::GFF::GFF3.new(File.read(@gff_file)).records gff3.inject(Hash.new{|h,k| h[k] = Array.new }) do |hash,record| hash[record.seqname] << record hash end end |
#scaffold ⇒ Object
54 55 56 57 |
# File 'lib/scaffolder/annotation_locator.rb', line 54 def scaffold YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE Scaffolder.new(YAML.load(File.read(@scaffold_file)),@sequence_file) end |