Search in sources :

Example 26 with DefaultEdge

use of org.jgrapht.graph.DefaultEdge in project jstructure by JonStargaryen.

the class ResidueGraphCalculations method shortestPathsPassingThrough.

/**
 * Determines the set of shortest paths passing through 1 particular edge.
 * @param contact
 * @return
 */
private List<GraphPath<AminoAcid, DefaultEdge>> shortestPathsPassingThrough(Pair<AminoAcid, AminoAcid> contact) {
    AminoAcid aminoAcid1 = contact.getLeft();
    AminoAcid aminoAcid2 = contact.getRight();
    return SetOperations.unorderedPairsOf(nodes).map(pair -> shortestPaths.get(pair.getLeft()).getPath(pair.getRight())).filter(graphPath -> {
        int index1 = graphPath.getVertexList().indexOf(aminoAcid1);
        int index2 = graphPath.getVertexList().indexOf(aminoAcid2);
        return index1 != -1 && index2 != -1 && Math.abs(index1 - index2) == 1;
    }).collect(Collectors.toList());
}
Also used : GraphPath(org.jgrapht.GraphPath) java.util(java.util) DefaultEdge(org.jgrapht.graph.DefaultEdge) ShortestPathAlgorithm(org.jgrapht.alg.interfaces.ShortestPathAlgorithm) ResidueIdentifier(de.bioforscher.jstructure.model.identifier.ResidueIdentifier) Group(de.bioforscher.jstructure.model.structure.Group) SetOperations(de.bioforscher.jstructure.mathematics.SetOperations) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid) Collectors(java.util.stream.Collectors) Pair(de.bioforscher.jstructure.mathematics.Pair) DijkstraShortestPath(org.jgrapht.alg.shortestpath.DijkstraShortestPath) AminoAcid(de.bioforscher.jstructure.model.structure.aminoacid.AminoAcid)

Aggregations

DefaultEdge (org.jgrapht.graph.DefaultEdge)26 ClassInfo (com.jopdesign.common.ClassInfo)8 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)6 Set (java.util.Set)5 DefaultDirectedGraph (org.jgrapht.graph.DefaultDirectedGraph)5 BitSet (java.util.BitSet)4 FileWriter (java.io.FileWriter)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 TopologicalOrderIterator (org.jgrapht.traverse.TopologicalOrderIterator)3 File (java.io.File)2 StringWriter (java.io.StringWriter)2 LinkedList (java.util.LinkedList)2 TreeSet (java.util.TreeSet)2 ExportException (org.jgrapht.nio.ExportException)2 GraphExpr (org.matheclipse.core.expression.data.GraphExpr)2 IAST (org.matheclipse.core.interfaces.IAST)2 IASTDataset (org.matheclipse.core.interfaces.IASTDataset)2 IExpr (org.matheclipse.core.interfaces.IExpr)2