2424
2525import org .biojava .nbio .structure .Structure ;
2626import org .biojava .nbio .structure .symmetry .utils .CombinationGenerator ;
27- import org .biojava .nbio .structure .symmetry .utils .ComponentFinder ;
28- import org .biojava .nbio .structure .symmetry .utils .Graph ;
27+ import org .jgrapht .UndirectedGraph ;
28+ import org .jgrapht .alg .ConnectivityInspector ;
29+ import org .jgrapht .graph .DefaultEdge ;
30+ import org .jgrapht .graph .UndirectedSubgraph ;
31+ import org .slf4j .Logger ;
32+ import org .slf4j .LoggerFactory ;
2933
3034import javax .vecmath .Point3d ;
35+
3136import java .math .BigInteger ;
3237import java .util .*;
3338
4045 *
4146 */
4247public class QuatSymmetryDetector {
48+
49+ private static final Logger logger = LoggerFactory
50+ .getLogger (QuatSymmetryDetector .class );
51+
4352 private Structure structure = null ;
4453 private QuatSymmetryParameters parameters = null ;
4554
@@ -136,8 +145,8 @@ private void run() {
136145
137146 double time = (System .nanoTime ()- start )/1000000000 ;
138147 if (time > parameters .getLocalTimeLimit ()) {
139- System . out . println ( "Warning: QuatSymmetryDetector: Exceeded time limit for local symmetry calculations: " + time +
140- " seconds. Results may be incomplete" );
148+ logger . warn ( " Exceeded time limit for local symmetry calculations: " + time +
149+ " seconds. Quat symmetry results may be incomplete" );
141150 break ;
142151 }
143152 }
@@ -387,8 +396,8 @@ private List<List<Integer>> decomposeClusters(List<Point3d[]> caCoords, List<Int
387396 }
388397
389398 SubunitGraph subunitGraph = new SubunitGraph (subList );
390- Graph <Integer > graph = subunitGraph .getProteinGraph ();
391- // System.out.println ("Graph: " + graph);
399+ UndirectedGraph <Integer , DefaultEdge > graph = subunitGraph .getProteinGraph ();
400+ logger . debug ("Graph: {}" , graph . toString () );
392401
393402 for (int i = last ; i > 1 ; i --) {
394403 CombinationGenerator generator = new CombinationGenerator (last , i );
@@ -397,8 +406,9 @@ private List<List<Integer>> decomposeClusters(List<Point3d[]> caCoords, List<Int
397406
398407 // avoid combinatorial explosion, i.e. for 1FNT
399408 BigInteger maxCombinations = BigInteger .valueOf (parameters .getMaximumLocalCombinations ());
400- // System.out.println("maxCombinations: " + generator.getTotal());
409+ logger . debug ( "Number of combinations: {}" , generator .getTotal ());
401410 if (generator .getTotal ().compareTo (maxCombinations ) > 0 ) {
411+ logger .warn ("Number of combinations exceeds limit for biounit with {} subunits in groups of {} subunits. Will not check local symmetry for them" , last , i );
402412 continue ;
403413 }
404414
@@ -424,8 +434,8 @@ private List<List<Integer>> decomposeClusters(List<Point3d[]> caCoords, List<Int
424434 }
425435
426436 // check if this subset of subunits interact with each other
427- Graph <Integer > subGraph = graph . extractSubGraph (subSet );
428- if (isConnectedGraph (subGraph )) {
437+ UndirectedGraph <Integer , DefaultEdge > subGraph = new UndirectedSubgraph < Integer , DefaultEdge >( graph , new HashSet < Integer > (subSet ), null );
438+ if (isConnectedGraph (subGraph )) {
429439 subClusters .add (subSet );
430440 if (subClusters .size () > parameters .getMaximumLocalResults ()) {
431441 return subClusters ;
@@ -454,10 +464,9 @@ private static int getLastMultiSubunit(List<Integer> clusterIds) {
454464 return clusterIds .size ();
455465 }
456466
457- private static boolean isConnectedGraph (Graph <Integer > graph ) {
458- ComponentFinder <Integer > finder = new ComponentFinder <Integer >();
459- finder .setGraph (graph );
460- return finder .getComponentCount () == 1 ;
467+ private static boolean isConnectedGraph (UndirectedGraph <Integer , DefaultEdge > graph ) {
468+ ConnectivityInspector <Integer , DefaultEdge > inspector = new ConnectivityInspector <Integer , DefaultEdge >(graph );
469+ return inspector .isGraphConnected ();
461470 }
462471
463472 private static List <Integer > getFolds (Integer [] subCluster , int size ) {
0 commit comments