class Bio::PolyploidTools::Marker

Attributes

best_hit[RW]
chr[RW]
chr_arm[RW]
contig[W]
coordinates_chr[RW]
distance_cm[RW]
index_90k[RW]
map_order[RW]
original[R]

include Virgola

sequence[RW]
snp[R]

include Virgola

snp_id[RW]
snp_name[RW]
template_sequence[R]

include Virgola

Public Class Methods

new(line) click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 42
def initialize(line)
  line.chomp!
  @template_sequence = nil
  #INDEX_90K,SNP_ID,SNP_NAME,CHR,COORDINATES_CHR,MAP_ORDER,CHR_ARM,DISTANCE_CM,SEQUENCE
  @index_90k, @snp_id, @snp_name, @chr, @coordinates_chr, @map_order, @chr_arm, @distance_cm, @sequence, @contig = line.split(',')
  parse_sequence_snp
end
parse(filename) { |m| ... } click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 50
def self.parse(filename)
  f = File.open(filename, "r").read
  f.each_line do |line|
    m = Marker.new(line)
    yield m if m.template_sequence

  end
end

Public Instance Methods

<=>(anOter) click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 35
def <=>(anOter)
 return 0 if anOter.snp_name == @snp_name 
 return @chr_arm <=> anOter.chr_arm  if anOter.chr_arm != @chr_arm
 return @snp_name  <=> anOter.snp_name if anOter.coordinates_chr == @coordinates_chr
 return @coordinates_chr <=> anOter.coordinates_chr    
end
contig() click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 26
def contig
  @contig = best_hit.target_id.chomp if best_hit
  @contig
end
to_csv() click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 31
def to_csv
  "#{index_90k},#{snp_id},#{snp_name},#{chr},#{coordinates_chr},#{map_order},#{chr_arm},#{distance_cm},#{sequence},#{contig}"
end
to_fasta() click to toggle source

after_map :parse_sequence_snp

# File lib/bio/PolyploidTools/Marker.rb, line 22
def to_fasta
  ">#{self.snp_name}\n#{self.template_sequence}"
end

Protected Instance Methods

parse_sequence_snp() click to toggle source
# File lib/bio/PolyploidTools/Marker.rb, line 60
def parse_sequence_snp
  pos = 0
  @chr.upcase!
  match_data = /(?<pre>\w*)\[(?<org>[ACGT])\/(?<snp>[ACGT])\](?<pos>\w*)/.match(sequence)
  if match_data
    @position = Regexp.last_match(:pre).size + 1
    @original = Regexp.last_match(:org)
    @snp = Regexp.last_match(:snp)
    amb_base = Bio::NucleicAcid.to_IUAPC("#{@original}#{@snp}")
    @template_sequence = "#{Regexp.last_match(:pre)}#{amb_base}#{Regexp.last_match(:pos)}"
    return @template_sequence
  end
  return nil
end