Class: Bio::PolyploidTools::ArmMap
- Inherits:
-
Object
- Object
- Bio::PolyploidTools::ArmMap
- Defined in:
- lib/bio/PolyploidTools/Marker.rb
Overview
The map hast to come sorted.
Instance Attribute Summary collapse
-
#chromosome ⇒ Object
Returns the value of attribute chromosome.
-
#global_reference(reference) ⇒ Object
readonly
Returns the value of attribute global_reference.
-
#markers ⇒ Object
readonly
Returns the value of attribute markers.
-
#reference(reference) ⇒ Object
readonly
Returns the value of attribute reference.
Instance Method Summary collapse
- #align_markers(output) ⇒ Object
-
#initialize ⇒ ArmMap
constructor
A new instance of ArmMap.
- #print_fasta_contigs_for_markers(contigs_file) ⇒ Object
- #print_fasta_contigs_from_reference(filename) ⇒ Object
- #print_fasta_markers(filename) ⇒ Object
- #print_map_with_contigs(filename) ⇒ Object
Constructor Details
Instance Attribute Details
#chromosome ⇒ Object
Returns the value of attribute chromosome.
80 81 82 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 80 def chromosome @chromosome end |
#global_reference(reference) ⇒ Object (readonly)
Returns the value of attribute global_reference.
79 80 81 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 79 def global_reference @global_reference end |
#markers ⇒ Object (readonly)
Returns the value of attribute markers.
79 80 81 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 79 def markers @markers end |
#reference(reference) ⇒ Object (readonly)
Returns the value of attribute reference.
79 80 81 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 79 def reference @reference end |
Instance Method Details
#align_markers(output) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 85 def align_markers(output) Bio::Blat.align(@reference.fasta_path, @fasta_markers, output) do |hit| marker = markers[hit.query_id] best = marker.best_hit unless marker.best_hit markers[hit.query_id].best_hit = hit else marker.best_hit = hit if hit.score > marker.best_hit.score end end end |
#print_fasta_contigs_for_markers(contigs_file) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 97 def print_fasta_contigs_for_markers(contigs_file) contigs = Set.new markers.each do |k, marker| if marker.best_hit contigs << marker.best_hit.target_id end end fasta=File.open(contigs_file, "w") contigs.each do |contig_id| reg = @reference.index.region_for_entry(contig_id) fasta.puts ">#{contig_id}\n#{@reference.fetch_sequence(reg.get_full_region)}" end fasta.close end |
#print_fasta_contigs_from_reference(filename) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 138 def print_fasta_contigs_from_reference(filename) if File.exist?(filename) reference(filename) return end #puts "loaded" fasta=File.open(filename, "w") Bio::FlatFile.auto( @global_reference.fasta_path) do |ff| ff.each do |f| chr_reg = arm_selection_embl(f.entry_id) if chr_reg == chromosome fasta.puts f.entry end end end fasta.close reference(filename) end |
#print_fasta_markers(filename) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 118 def print_fasta_markers(filename) @fasta_markers = filename fasta=File.open(filename, "w") markers.each do |k, marker| fasta.puts marker.to_fasta end fasta.close end |
#print_map_with_contigs(filename) ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/bio/PolyploidTools/Marker.rb', line 161 def print_map_with_contigs(filename) file = File.open(filename, "w") markers.values.sort { |x,y| x.map_order <=> y.map_order }.each do | marker | file.puts marker.to_csv end file.close end |