Class Bio::PhyloXML::Sequence
In: lib/bio/db/phyloxml/phyloxml_elements.rb
Parent: Object

Description

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

Methods

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

[Source]

     # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 553
553:       def initialize
554:         @annotations = []
555:         @other = []
556:       end

Public Instance methods

[Source]

     # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 558
558:       def is_aligned=(str)
559:         if str=='true'
560:           @is_aligned=true
561:         elsif str=='false'
562:           @is_aligned = false
563:         else
564:           @is_aligned = nil
565:         end
566:       end

[Source]

     # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 568
568:       def is_aligned?
569:         @is_aligned
570:       end

[Source]

     # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 572
572:       def mol_seq=(str)
573:         if str =~ /^[a-zA-Z\.\-\?\*_]+$/
574:           @mol_seq = str
575:         else
576:           raise "mol_seq element of Sequence does not follow the pattern."
577:         end
578:       end

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


Returns:Bio::Sequence

[Source]

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

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

[Source]

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

[Validate]