class Bio::PhyloXML::Sequence

Description

Element Sequence is used to represent a molecular sequence (Protein, DNA, RNA) associated with a node.

Attributes

accession[RW]

Accession object. Holds source and identifier for the sequence.

annotations[RW]

Array of Annotation objects. Annotations of molecular sequence.

domain_architecture[RW]

DomainArchitecture object. Describes domain architecture of a protein.

id_ref[RW]

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.

id_source[RW]

String. Used to link with other elements.

is_aligned[R]

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)

location[RW]

String. Location of a sequence on a genome/chromosome

mol_seq[R]

String. The actual sequence is stored here.

name[RW]

Full name (e.g. muscle Actin )

other[RW]

Array of Other objects. Used to save additional information from other than PhyloXML namspace.

symbol[RW]

short (maximal ten characters) symbol of the sequence (e.g. ‘ACTM’)

type[RW]

Type of sequence (rna, dna, protein)

uri[RW]

Uri object

Public Class Methods

new() click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
551 def initialize
552   @annotations = []
553   @other = []
554 end

Public Instance Methods

is_aligned=(str) click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
556 def is_aligned=(str)
557   if str=='true'
558     @is_aligned=true
559   elsif str=='false'
560     @is_aligned = false
561   else
562     @is_aligned = nil
563   end
564 end
is_aligned?() click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
566 def is_aligned?
567   @is_aligned
568 end
mol_seq=(str) click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
570 def mol_seq=(str)
571   if str =~ /^[a-zA-Z\.\-\?\*_]+$/
572     @mol_seq = str
573   else
574     raise "mol_seq element of Sequence does not follow the pattern."
575   end
576 end
to_biosequence() click to toggle source

converts Bio::PhyloXML:Sequence to Bio::Sequence object.


Returns

Bio::Sequence

    # File lib/bio-phyloxml/phyloxml_elements.rb
617 def to_biosequence
618   #type is not a required attribute in phyloxml (nor any other Sequence
619   #element) it might not hold any value, so we will not check what type it is.
620   seq = Bio::Sequence.auto(@mol_seq)
621 
622   seq.id_namespace = @accession.source
623   seq.entry_id = @accession.value
624   # seq.primary_accession = @accession.value could be this
625   seq.definition = @name
626   #seq.comments = @name //this one?
627   if (defined? @uri) && @uri
628     h = {'url' => @uri.uri,
629       'title' => @uri.desc }
630     ref = Bio::Reference.new(h)
631     seq.references << ref
632   end
633   seq.molecule_type = 'RNA' if @type == 'rna'
634   seq.molecule_type = 'DNA' if @type == 'dna'
635 
636   #@todo deal with the properties. There might be properties which look
637   #like bio sequence attributes or features
638   return seq
639 end
to_xml() click to toggle source

Converts elements to xml representation. Called by PhyloXML::Writer class.

    # File lib/bio-phyloxml/phyloxml_elements.rb
579 def to_xml
580   
581   seq = LibXML::XML::Node.new('sequence')
582   if (defined? @type) && @type
583     if ["dna", "rna", "protein"].include?(@type)
584       seq["type"] = @type
585     else 
586       raise "Type attribute of Sequence has to be one of dna, rna or a."
587     end
588   end
589   
590   PhyloXML::Writer.generate_xml(seq, self, [
591       [:attr, 'id_source'],
592       [:attr, 'id_ref'],
593       [:pattern, 'symbol', (defined? @symbol) ? @symbol : nil, Regexp.new("^\\S{1,10}$")],
594       [:complex, 'accession', (defined? @accession) ? @accession : nil],
595       [:simple, 'name', (defined? @name) ? @name : nil],
596       [:simple, 'location', (defined? @location) ? @location : nil]])
597 
598   if (defined? @mol_seq) && @mol_seq
599     molseq = LibXML::XML::Node.new('mol_seq', @mol_seq)
600     molseq["is_aligned"] = @is_aligned.to_s if (defined? @is_aligned) && @is_aligned != nil
601     seq << molseq
602   end
603 
604   PhyloXML::Writer.generate_xml(seq, self, [
605       #[:pattern, 'mol_seq', @mol_seq, Regexp.new("^[a-zA-Z\.\-\?\*_]+$")],
606       [:complex, 'uri', (defined? @uri) ? @uri : nil],
607       [:objarr, 'annotation', 'annotations'],
608       [:complex, 'domain_architecture', (defined? @domain_architecture) ? @domain_architecture : nil]])
609       #@todo test domain_architecture
610   #any
611   return seq
612 end