module Exodb::GeneLocationField
Public Instance Methods
get the start position of gene rely on the genome
@return [Integer] start position of gene
# File lib/exodb/datamodel/genelocfield.rb, line 96 def begin self[:strand] == '+' ? self[:start] : self[:stop] end
get the chromosome
@return [Integer] chromosome
# File lib/exodb/datamodel/genelocfield.rb, line 110 def chromosome self[:chr] end
Download sequence from web service please use by caution. NCBI will block scamming sequest
# File lib/exodb/datamodel/genelocfield.rb, line 66 def dl_seq! case self.chrrefseq when /\Aurn:miriam:refseq:/ self.sequence = Bio::FastaFormat.new(Bio::NCBI::REST.efetch(self.chrrefseq.split(':', 4), {"db"=>"nucleotide", "rettype"=>"fasta", "retmode"=>"text", "seq_start"=>self.start, "seq_stop"=>self.end})).seq else self.sequence = Exodb::Ensembl::REST.sequence_region() end self.save! end
get the start position of gene rely on the genome
@return [Integer] start position of gene
# File lib/exodb/datamodel/genelocfield.rb, line 103 def end self[:strand] == '+' ? self[:stop] : self[:start] end
join exon or cds position into a string
@param [Array] input array exon or cds @param [Interger] Position to stop positive value for forward read negative value for complement
@return [String] a string in start..end,start..end,…
# File lib/exodb/datamodel/genelocfield.rb, line 160 def get_splice(arr, strand = nil) strand = strand || self[:strand] reducer = self[:seqlocation]['start'] - 1 str = [] arr.each do |e| str.push("#{e[0] - reducer}..#{e[1] - reducer}") end return strand == '+' ? self.to_seq.splicing("join(#{str.join(',')})") : self.to_seq.splicing("complement(join(#{str.join(',')}))") end
Assign location
@param [String, Hash] location string in chromosome:start..stop or chromosome:start-stop format
# File lib/exodb/datamodel/genelocfield.rb, line 117 def location=(loc) if loc.is_a?(String) begin loc.parse_loc.delete_if {|k, v| k == 'pos'}.each_pair do |k, v| self[k.to_sym] = v end rescue end end end
Return location
@return [String] location string in chromosome:position
# File lib/exodb/datamodel/genelocfield.rb, line 134 def location_str return "#{self.chromosome}:#{[self.start, self.stop].uniq.join('..')}" end
get the start position of gene rely on the genome
@return [Integer] start position of gene
# File lib/exodb/datamodel/genelocfield.rb, line 82 def start self[:start] end
get the end position of gene rely on the genome
@return [Integer] end position of gene
# File lib/exodb/datamodel/genelocfield.rb, line 89 def stop self[:stop] end
Return gene sequence
@return [Bio::Sequence] gene sequence
# File lib/exodb/datamodel/genelocfield.rb, line 143 def to_seq whole_seq.splice("#{self[:start] - self[:seqstart] + 1}..#{self[:stop] - self[:seqstart] + 1}") end
Return whole deposited sequence
@return [Bio::Sequence] gene sequence
# File lib/exodb/datamodel/genelocfield.rb, line 150 def whole_seq Bio::Sequence::NA.new(self[:sequence]) end