class Bio::PhyloXML::Sequence
Description¶ ↑
Element Sequence
is used to represent a molecular sequence (Protein, DNA, RNA) associated with a node.
Attributes
Accession
object. Holds source and identifier for the sequence.
Array of Annotation
objects. Annotations of molecular sequence.
DomainArchitecture
object. Describes domain architecture of a protein.
String. One intended use for ‘id_ref’ is to link a sequence to a taxonomy (via the taxonomy’s ‘id_source’) in the case of multiple sequences and taxonomies per node.
String. Used to link with other elements.
Boolean. used to indicated that this molecular sequence is aligned with all other sequences in the same phylogeny for which ‘is aligned’ is true as well (which, in most cases, means that gaps were introduced, and that all sequences for which ‘is aligned’ is true must have the same length)
String. Location of a sequence on a genome/chromosome
String. The actual sequence is stored here.
Full name (e.g. muscle Actin )
short (maximal ten characters) symbol of the sequence (e.g. ‘ACTM’)
Type of sequence (rna, dna, protein)
Uri
object
Public Class Methods
# File lib/bio/phyloxml/elements.rb, line 545 def initialize @annotations = [] @other = [] end
Public Instance Methods
# File lib/bio/phyloxml/elements.rb, line 550 def is_aligned=(str) if str=='true' @is_aligned=true elsif str=='false' @is_aligned = false else @is_aligned = nil end end
# File lib/bio/phyloxml/elements.rb, line 560 def is_aligned? @is_aligned end
# File lib/bio/phyloxml/elements.rb, line 564 def mol_seq=(str) if str =~ /^[a-zA-Z\.\-\?\*_]+$/ @mol_seq = str else raise "mol_seq element of Sequence does not follow the pattern." end end
converts Bio::PhyloXML
:Sequence to Bio::Sequence object.
- Returns
-
Bio::Sequence
# File lib/bio/phyloxml/elements.rb, line 611 def to_biosequence #type is not a required attribute in phyloxml (nor any other Sequence #element) it might not hold any value, so we will not check what type it is. seq = Bio::Sequence.auto(@mol_seq) seq.id_namespace = @accession.source seq.entry_id = @accession.value # seq.primary_accession = @accession.value could be this seq.definition = @name #seq.comments = @name //this one? if @uri != nil h = {'url' => @uri.uri, 'title' => @uri.desc } ref = Bio::Reference.new(h) seq.references << ref end seq.molecule_type = 'RNA' if @type == 'rna' seq.molecule_type = 'DNA' if @type == 'dna' #@todo deal with the properties. There might be properties which look #like bio sequence attributes or features return seq end
Converts elements to xml representation. Called by PhyloXML::Writer
class.
# File lib/bio/phyloxml/elements.rb, line 573 def to_xml seq = LibXML::XML::Node.new('sequence') if @type != nil if ["dna", "rna", "protein"].include?(@type) seq["type"] = @type else raise "Type attribute of Sequence has to be one of dna, rna or a." end end PhyloXML::Writer.generate_xml(seq, self, [ [:attr, 'id_source'], [:attr, 'id_ref'], [:pattern, 'symbol', @symbol, Regexp.new("^\\S{1,10}$")], [:complex, 'accession', @accession], [:simple, 'name', @name], [:simple, 'location', @location]]) if @mol_seq != nil molseq = LibXML::XML::Node.new('mol_seq', @mol_seq) molseq["is_aligned"] = @is_aligned.to_s if @is_aligned != nil seq << molseq end PhyloXML::Writer.generate_xml(seq, self, [ #[:pattern, 'mol_seq', @mol_seq, Regexp.new("^[a-zA-Z\.\-\?\*_]+$")], [:complex, 'uri', @uri], [:objarr, 'annotation', 'annotations'], [:complex, 'domain_architecture', @domain_architecture]]) #@todo test domain_architecture #any return seq end