data.complexes
Class Complex

java.lang.Object
  extended by data.complexes.Complex
All Implemented Interfaces:
ProteinSet, Iterable<Integer>

public class Complex
extends Object
implements Iterable<Integer>, ProteinSet

Represents a complex of proteins. This class provides various manipulation, retrieval and and analysis methods.

Proteins are represented as internal integer IDs (see also: ProteinManager)

Author:
Jan Krumsiek
See Also:
ComplexSet

Constructor Summary
Complex()
          Creates an empty complex.
Complex(Collection<Integer> complex)
          Intializes the complex with a given list of proteins.
Complex(Integer... elements)
          Intializes the complex with a given integer array provided as a c onvenient parameter list.
 
Method Summary
 void addProtein(int protein)
          Adds a protein to the complex.
 void addProteins(Collection<Integer> proteins)
          Adds a list of proteins to the complex.
 boolean contains(int protein)
          Checks whether a given protein is contained in this complex.
 Complex copy()
          Creates a copy of this complex
 boolean equals(Object obj)
          Returns true if and only if the specified object is also a Complex and both complexes have identical members.
 List<Integer> getComplex()
          Returns the list backing this complex.
 ArrayList<ProteinLabel> getComplexAsLabels()
          Convenience and debugging method which translates this complex into a list of protein labels
 int getMember(int index)
          Returns the protein at a given index of in the complex.
 ProteinNetwork getMinimalSpanningTree(ProteinNetwork scores)
          Returns the minimal spanning tree of this complex as a network object.
 Set<Integer> getProteins()
          Returns the set of internal IDs which are involved in this complex.
 int indexOf(int protein)
          Returns the index of a given protein in the complex.
 Complex intersection(Complex other)
          Returns the intersection of both complexes.
 Iterator<Integer> iterator()
          Returns an iterator over the interal protein IDs in this complex.
 boolean removeProtein(Integer protein)
          Removes a given protein from the complex.
 void removeProteinIndex(int index)
          Removes the protein at a given index from the complex.
 int size()
          Returns the size of the complex.
 String toString()
          Returns the string representation of this complex as the string representation of the backing list of internal IDs
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex(Collection<Integer> complex)
Intializes the complex with a given list of proteins. Note:The original Collection object is copied and will not be altered.

Parameters:
complex - Collection with proteins IDs for initialization

Complex

public Complex(Integer... elements)
Intializes the complex with a given integer array provided as a c onvenient parameter list.

Parameters:
elements - Array with proteins IDs for initialization

Complex

public Complex()
Creates an empty complex.

Method Detail

addProtein

public void addProtein(int protein)
Adds a protein to the complex.

Parameters:
protein - internal ID of the protein to be added

addProteins

public void addProteins(Collection<Integer> proteins)
Adds a list of proteins to the complex.

Parameters:
proteins - Collection of internal IDs of proteins to be added to the complex

removeProteinIndex

public void removeProteinIndex(int index)
                        throws IndexOutOfBoundsException
Removes the protein at a given index from the complex.

Parameters:
index - index of protein to be removed (zero-based)
Throws:
IndexOutOfBoundsException - if the index is out of range for this complex

removeProtein

public boolean removeProtein(Integer protein)
Removes a given protein from the complex. Be careful not to confuse this method with removeProteinIndex(int).

Parameters:
protein - internal protein ID of member to be removed
Returns:
true if the protein was contained in the complex and could be removed, false otherwise

iterator

public Iterator<Integer> iterator()
Returns an iterator over the interal protein IDs in this complex.

Specified by:
iterator in interface Iterable<Integer>
Returns:
iterater over internal Ids

getProteins

public Set<Integer> getProteins()
Returns the set of internal IDs which are involved in this complex.

Specified by:
getProteins in interface ProteinSet
Returns:
a set of internal IDs

size

public int size()
Returns the size of the complex.

Returns:
Size of this complex, that is the number of proteins contained in the complex.

getMember

public int getMember(int index)
              throws IndexOutOfBoundsException
Returns the protein at a given index of in the complex.

Parameters:
index - index of protein to retrieve
Returns:
internal ID of protein at given index.
Throws:
IndexOutOfBoundsException - if the index is out of range for this complex

getComplex

public List<Integer> getComplex()
Returns the list backing this complex. Attention: changes to this object will also affect the complex.

Returns:
List of internal IDs backing this complex

toString

public String toString()
Returns the string representation of this complex as the string representation of the backing list of internal IDs

Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Returns true if and only if the specified object is also a Complex and both complexes have identical members.

Overrides:
equals in class Object

contains

public boolean contains(int protein)
Checks whether a given protein is contained in this complex.

Parameters:
protein - internal ID of protein to be checked for
Returns:
true if the protein is contained in this complex, false otherwise

indexOf

public int indexOf(int protein)
Returns the index of a given protein in the complex. If there are multiple occurences of this protein in the complex, only the first position will be returned.

Parameters:
protein - internal ID of protein to be checked for
Returns:
Index of the protein or -1 if the protein is not contained in the complex

copy

public Complex copy()
Creates a copy of this complex

Returns:
Exact copy of the complex

getMinimalSpanningTree

public ProteinNetwork getMinimalSpanningTree(ProteinNetwork scores)
Returns the minimal spanning tree of this complex as a network object. The method uses Kruskal's algorithm for efficient MST calculation. Note: This implementation is based on similarity values, not distances. Thus the result will be the maximum-weight spanning tree of the complex graph. If the graph consists of multiple components due to missing edges, no MST can be calculated.

Parameters:
scores - Scores network to be used for weighting the complex edges
Returns:
Minimal spanning tree of the complex or null if no spanning tree exists due to missing edges.

getComplexAsLabels

public ArrayList<ProteinLabel> getComplexAsLabels()
Convenience and debugging method which translates this complex into a list of protein labels

Returns:
list of protein labels for this complex
See Also:
ProteinManager

intersection

public Complex intersection(Complex other)
Returns the intersection of both complexes. The intersection means the list of proteins which are contained in both complexes. When working with complexes containing certain proteins more than once, this method will only returnthe intersecting subset of this complex, not the other.

Parameters:
other - Complex to calculate intersection with
Returns:
intersecting set of proteins