Element Sequence is used to represent a molecular sequence (Protein, DNA, RNA) associated with a node.
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)
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 558 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/db/phyloxml/phyloxml_elements.rb, line 568 def is_aligned? @is_aligned end
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 572 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 |
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 619 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/db/phyloxml/phyloxml_elements.rb, line 581 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
Generated with the Darkfish Rdoc Generator 2.