fr.orsay.lri.varna.models.templates
Class RNATemplate

java.lang.Object
  extended by fr.orsay.lri.varna.models.templates.RNATemplate

public class RNATemplate
extends Object

A model for RNA templates. A template is a way to display an RNA secondary structure.

Author:
Raphael Champeimont

Nested Class Summary
private  class RNATemplate.ConvertToTree
           
private  class RNATemplate.ConvertToXml
           
static class RNATemplate.EdgeEndPointPosition
          Position of an endpoint on an endpoint.
static class RNATemplate.In1Is
          For an helix, tells us whether IN1/OUT1 is the 5' strand (the first strand we meet if we follow the RNA sequence) or the 3' strand (the second we meet if we follow the RNA sequence).
private  class RNATemplate.LoadFromXml
           
private  class RNATemplate.MakeEdgeList
           
private  class RNATemplate.RemovePseudoKnots
           
private  class RNATemplate.RNAIterator
          To get an iterator of this class, use rnaIterator().
 class RNATemplate.RNATemplateElement
          An endpoint of an RNA template, it can be an helix or a sequence of non-paired bases.
 class RNATemplate.RNATemplateHelix
          An helix in an RNA template.
 class RNATemplate.RNATemplateUnpairedSequence
          A sequence of non-paired bases in an RNA template.
private  class RNATemplate.VertexIterator
           
 
Field Summary
private  Collection<RNATemplate.RNATemplateElement> elements
          The list of template elements.
private static int NEXT_ID
           
private  RNATemplate template
          Variable containing "this", used by the internal class to access this object.
 
Constructor Summary
RNATemplate()
           
 
Method Summary
 void checkIsValidTemplate()
          Checks whether this template is a valid RNA template, ie.
 Iterator<RNATemplate.RNATemplateElement> classicIterator()
          Iterates over all elements (each endpoint is given only once) in an arbitrary order.
 void computeIn1Is()
          For each helix, compute the in1Is field.
 boolean connectedComponentIsCyclic(RNATemplate.RNATemplateElement.EdgeEndPoint endPoint)
          Tells whether the connected component to which endPoint belongs to is cyclic.
static RNATemplate fromXMLDocument(Document xmlDocument)
           
static RNATemplate fromXMLFile(File file)
           
 RNATemplate.RNATemplateElement getAny()
          Return an arbitrary element of the template, null if empty.
 RNATemplate.RNATemplateElement.EdgeEndPoint getAnyEndPoint()
          Return an arbitrary endpoint of the template, null if empty.
 RNATemplate.RNATemplateElement getFirst()
          The first endpoint (in sequence order) of the template.
 RNATemplate.RNATemplateElement.EdgeEndPoint getFirstEndPoint()
          The first endpoint edge endpoint (in sequence order) of the template.
 boolean isConnected()
          Tells whether the template elements are all connected, ie.
 boolean isEmpty()
          Tells whether the template contains elements.
 List<RNATemplate.RNATemplateElement.EdgeEndPoint> makeEdgeList()
          Return over all edges in an arbitrary order.
 boolean removeElement(RNATemplate.RNATemplateElement element)
          Remove the element from the template.
 Iterator<RNATemplate.RNATemplateElement> rnaIterator()
          Iterates over the elements of the template, in the sequence order.
 RNA toRNA()
          Generate an RNA sequence that exactly matches the template.
 Tree<RNANodeValueTemplate> toTree()
          Make a tree of the template.
 Document toXMLDocument()
           
 void toXMLFile(File file)
           
 Iterator<RNATemplate.RNATemplateElement.EdgeEndPoint> vertexIterator()
          Iterates over the elements edge endpoints of the template, in the sequence order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elements

private Collection<RNATemplate.RNATemplateElement> elements
The list of template elements.


template

private final RNATemplate template
Variable containing "this", used by the internal class to access this object.


NEXT_ID

private static int NEXT_ID
Constructor Detail

RNATemplate

public RNATemplate()
Method Detail

isEmpty

public boolean isEmpty()
Tells whether the template contains elements.


getFirst

public RNATemplate.RNATemplateElement getFirst()
The first endpoint (in sequence order) of the template. If there are multiple connected components, the first elements of one connected component will be returned. If the template contains no elements, null is returned. If there is a cycle, an arbitrary endpoint will be returned (as it then does not make sense to define the first endpoint). Time: O(n)


getFirstEndPoint

public RNATemplate.RNATemplateElement.EdgeEndPoint getFirstEndPoint()
The first endpoint edge endpoint (in sequence order) of the template. If there are multiple connected components, the first elements of one connected component will be returned. If the template contains no elements, null is returned. If there is a cycle, an arbitrary endpoint will be returned (as it then does not make sense to define the first endpoint). Time: O(n)


getAny

public RNATemplate.RNATemplateElement getAny()
Return an arbitrary element of the template, null if empty. Time: O(1)


getAnyEndPoint

public RNATemplate.RNATemplateElement.EdgeEndPoint getAnyEndPoint()
Return an arbitrary endpoint of the template, null if empty. Time: O(1)


rnaIterator

public Iterator<RNATemplate.RNATemplateElement> rnaIterator()
Iterates over the elements of the template, in the sequence order. Helixes will be given twice. Only one connected component will be iterated on. Note that if there is a cycle, the iterator may return a infinite number of elements.


classicIterator

public Iterator<RNATemplate.RNATemplateElement> classicIterator()
Iterates over all elements (each endpoint is given only once) in an arbitrary order.


vertexIterator

public Iterator<RNATemplate.RNATemplateElement.EdgeEndPoint> vertexIterator()
Iterates over the elements edge endpoints of the template, in the sequence order. Only one connected component will be iterated on. Note that if there is a cycle, the iterator may return a infinite number of elements.


makeEdgeList

public List<RNATemplate.RNATemplateElement.EdgeEndPoint> makeEdgeList()
Return over all edges in an arbitrary order. For each edge, the first (5' side) endpoint will be given.


connectedComponentIsCyclic

public boolean connectedComponentIsCyclic(RNATemplate.RNATemplateElement.EdgeEndPoint endPoint)
Tells whether the connected component to which endPoint belongs to is cyclic.


isConnected

public boolean isConnected()
Tells whether the template elements are all connected, ie. if the graph (edge endpoints being vertices) is connected.


checkIsValidTemplate

public void checkIsValidTemplate()
                          throws fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
Checks whether this template is a valid RNA template, ie. it is non-empty, it does not contain a cycle and all elements are in one connected component.

Throws:
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate

toTree

public Tree<RNANodeValueTemplate> toTree()
                                  throws fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
Make a tree of the template. For this, we will remove pseudoknots, taking care to remove as few base pair links as possible. Requires the template to be valid and will check the validity (will call checkIsValidTemplate()). Calling this method will automatically call computeIn1Is().

Throws:
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate

toRNA

public RNA toRNA()
          throws fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
Generate an RNA sequence that exactly matches the template. Requires the template to be valid and will check the validity (will call checkIsValidTemplate()).

Throws:
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate

toXMLFile

public void toXMLFile(File file)
               throws fr.orsay.lri.varna.exceptions.ExceptionXMLGeneration,
                      fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
Throws:
fr.orsay.lri.varna.exceptions.ExceptionXMLGeneration
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate

toXMLDocument

public Document toXMLDocument()
                       throws fr.orsay.lri.varna.exceptions.ExceptionXMLGeneration,
                              fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
Throws:
fr.orsay.lri.varna.exceptions.ExceptionXMLGeneration
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate

fromXMLFile

public static RNATemplate fromXMLFile(File file)
                               throws fr.orsay.lri.varna.exceptions.ExceptionXmlLoading
Throws:
fr.orsay.lri.varna.exceptions.ExceptionXmlLoading

fromXMLDocument

public static RNATemplate fromXMLDocument(Document xmlDocument)
                                   throws fr.orsay.lri.varna.exceptions.ExceptionXmlLoading
Throws:
fr.orsay.lri.varna.exceptions.ExceptionXmlLoading

computeIn1Is

public void computeIn1Is()
                  throws fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
For each helix, compute the in1Is field. If helices connections are changed, the value may become obsolete, so you need to call this method again before accessing the in1Is fields if you have modified connections in the template. Requires the template to be valid and will check the validity (will call checkIsValidTemplate()).

Throws:
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate

removeElement

public boolean removeElement(RNATemplate.RNATemplateElement element)
                      throws fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate
Remove the element from the template. The element is automatically disconnected from any other element. Returns true if and only if the element was present in the template, otherwise nothing was done.

Throws:
fr.orsay.lri.varna.exceptions.ExceptionInvalidRNATemplate