class Bio::PolyploidTools::ArmMap
The map hast to come sorted.
Attributes
chromosome[RW]
global_reference[R]
markers[R]
reference[R]
Public Class Methods
new()
click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 81 def initialize @markers = Hash.new end
Public Instance Methods
align_markers(output)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Protected Instance Methods
arm_selection_embl(contig_name)
click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 170 def arm_selection_embl(contig_name) ret = contig_name.split('_')[2][0,2] return ret end