@@ -78,7 +78,7 @@ public class PPNodeSimilarity implements IPPNodeSimilarity {
7878
7979 A similarity thresh of 0.99 allows 58 pairwise interactions.
8080 */
81- public static final double THRESH_SIMILARITY_HARD_MATCH = 0.9 ;
81+ public static final double THRESH_SIMILARITY_HARD_MATCH = 0.89 ;
8282
8383 public static final double HARD_MATCH_OPTIMISTIC_PERCENTILE = 0.75 ;
8484
@@ -105,13 +105,9 @@ public class PPNodeSimilarity implements IPPNodeSimilarity {
105105 * This constructor is used for parallel mode.
106106 */
107107 public PPNodeSimilarity (int versionInteractionTable , int modePPNodeSimilarity ){
108-
109108 maSimilarity = new Matrix (SIZE_SIM_MATRIX , SIZE_SIM_MATRIX );
110-
111109 interactionSimilarityTable = InteractionSimilarityTable .getInstance ();
112-
113110 similarityMode = modePPNodeSimilarity ;
114-
115111 threshSimilarityHardMatch = THRESH_SIMILARITY_HARD_MATCH ;
116112 }
117113
@@ -204,28 +200,19 @@ public double getSimilarity(IPPNode query, IPPNode base) {
204200 * @throws Exception
205201 */
206202 public double getSimilaritySimple (PPNode query , PPNode base ) {
207-
208203 maSimilarity .set (0 );
209-
210204 for (int i = 0 ; i < query .getInteractionTypeCount (); i ++) {
211-
212205 int interactionTypeQuery = query .getInteractionType (i );
213-
214206 for (int j = 0 ; j < base .getInteractionTypeCount (); j ++) {
215-
216207 int interactionTypeBase = base .getInteractionType (j );
217-
218208 double similarity = 1.0 - interactionSimilarityTable .getDistance (interactionTypeQuery , interactionTypeBase );
219-
220209 maSimilarity .set (i ,j ,similarity );
221210 }
222211 }
223212
224213 if (verbose ) {
225214 System .out .println ("PPNodeSimilarityMultiplicative" );
226-
227215 TableModelString tableModelString = new TableModelString (query .getInteractionTypeCount (), base .getInteractionTypeCount ());
228-
229216 for (int i = 0 ; i < query .getInteractionTypeCount (); i ++) {
230217 int interactionType = query .getInteractionType (i );
231218 String s = InteractionAtomTypeCalculator .getString (interactionType );
@@ -237,34 +224,25 @@ public double getSimilaritySimple(PPNode query, PPNode base) {
237224 String s = InteractionAtomTypeCalculator .getString (interactionType );
238225 tableModelString .setColName (i , s );
239226 }
240-
241227 tableModelString .set (maSimilarity , 2 );
242-
243228 System .out .println (tableModelString .toString ());
244-
245229 }
246230
247231
248232 List <Double > liSimilarities = new ArrayList <>();
249-
250233 if (base .getInteractionTypeCount () > query .getInteractionTypeCount ()) {
251-
252234 for (int col = 0 ; col < base .getInteractionTypeCount (); col ++) {
253-
254235 double maxSimInCol = 0 ;
255236 for (int row = 0 ; row < query .getInteractionTypeCount (); row ++) {
256237 if (maSimilarity .get (row ,col )>maxSimInCol ){
257238 maxSimInCol = maSimilarity .get (row ,col );
258239 }
259240 }
260-
261241 liSimilarities .add (maxSimInCol );
262-
263242 // System.out.println("Sim maxSimInCol " + Formatter.format2(maxSimInCol) + "\t" + InteractionAtomTypeCalculator.getString(interactionTypeBase) + "\t" + InteractionAtomTypeCalculator.getString(interactionTypeQuery));
264243 }
265244 } else {
266245 for (int row = 0 ; row < query .getInteractionTypeCount (); row ++) {
267-
268246 double maxSimInRow = 0 ;
269247 for (int col = 0 ; col < base .getInteractionTypeCount (); col ++) {
270248 if (maSimilarity .get (row ,col ) > maxSimInRow ){
@@ -285,7 +263,6 @@ public double getSimilaritySimple(PPNode query, PPNode base) {
285263 }
286264 }
287265
288-
289266 if (verbose ) {
290267 System .out .println ("Sim " + Formatter .format2 (sim ));
291268 System .out .println ();
@@ -294,23 +271,15 @@ public double getSimilaritySimple(PPNode query, PPNode base) {
294271 return sim ;
295272 }
296273 public double getSimilarityHardMatchMultiplicative (PPNode query , PPNode base ) {
297-
298274 IPPNode queryCmp = query ;
299-
300275 PPNode baseCmp = base ;
301-
302276 if (base .hasHeteroAtom () && query .hasHeteroAtom ()){
303-
304277 queryCmp = PPNode .getHeteroOnlyNode (query );
305-
306278 baseCmp = PPNode .getHeteroOnlyNode (base );
307-
308279 }
309280
310281 List <Double > liSimilarities = getSimilarityList ((PPNode )queryCmp , baseCmp );
311-
312282 double sim = 0 ;
313-
314283 if (liSimilarities .size ()>0 ) {
315284 sim = 1 ;
316285 for (double simPart : liSimilarities ) {
@@ -379,9 +348,7 @@ public List<Double> getSimilarityList(PPNode query, PPNode base) {
379348
380349
381350 private static double [] getTopValues (Matrix maSimilarity , int rows , int cols , double thresh ){
382-
383351 double [] arrTopSim = new double [Math .max (rows , cols )];
384-
385352 if (rows ==1 && cols ==1 ){
386353 arrTopSim [0 ]=maSimilarity .get (0 ,0 );
387354 return arrTopSim ;
@@ -477,11 +444,8 @@ public List<Double> getSimilarityList(PPNode query, PPNode base) {
477444
478445 public double getSimilarityHardMatchAverage (PPNode query , PPNode base ) {
479446 List <Double > liSimilarities = getSimilarityList (query , base );
480-
481447 double sumSim = 0 ;
482-
483448 if (liSimilarities .size ()>0 ) {
484-
485449 for (double simPart : liSimilarities ) {
486450 if (simPart < threshSimilarityHardMatch ){
487451 sumSim = 0 ;
@@ -492,7 +456,6 @@ public double getSimilarityHardMatchAverage(PPNode query, PPNode base) {
492456 }
493457
494458 double sim = sumSim /liSimilarities .size ();
495-
496459 if (verbose ) {
497460 System .out .println ("Sim " + Formatter .format2 (sim ));
498461 System .out .println ();
@@ -525,11 +488,8 @@ public double getSimilarityHardMatchOptimistic(PPNode query, PPNode base) {
525488 }
526489
527490 public double getSimilarityExtraCarbonConsideration (PPNode query , PPNode base ) {
528-
529491 maSimilarity .set (0 );
530-
531492 final double valNoInteraction = -1 ;
532-
533493 boolean lowCarbonFractionQuery = (query .getFractionCarbonInteractions ()< THRESH_CARBON_INTERACTIONS )?true :false ;
534494 boolean lowCarbonFractionBase = (base .getFractionCarbonInteractions ()< THRESH_CARBON_INTERACTIONS )?true :false ;
535495
@@ -540,7 +500,6 @@ public double getSimilarityExtraCarbonConsideration(PPNode query, PPNode base) {
540500// }
541501// }
542502
543-
544503 for (int i = 0 ; i < query .getInteractionTypeCount (); i ++) {
545504
546505 int interactionTypeQuery = query .getInteractionType (i );
@@ -598,38 +557,27 @@ public double getSimilarityExtraCarbonConsideration(PPNode query, PPNode base) {
598557
599558 }
600559
601-
602560 List <Double > liSimilarities = new ArrayList <>();
603-
604561 if (base .getInteractionTypeCount () > query .getInteractionTypeCount ()) {
605-
606562 for (int col = 0 ; col < base .getInteractionTypeCount (); col ++) {
607-
608563 int interactionTypeQuery =-1 ;
609564 int interactionTypeBase =-1 ;
610-
611565 double maxSimInCol = valNoInteraction ;
612566 for (int row = 0 ; row < query .getInteractionTypeCount (); row ++) {
613567 if (maSimilarity .get (row ,col )>maxSimInCol ){
614568 maxSimInCol = maSimilarity .get (row ,col );
615-
616569 interactionTypeBase = base .getInteractionType (col );
617570 interactionTypeQuery = query .getInteractionType (row );
618571 }
619572 }
620-
621-
622573 if (Math .abs (maxSimInCol -valNoInteraction )<TINY ){
623574 continue ;
624575 }
625-
626576 liSimilarities .add (maxSimInCol );
627-
628577 // System.out.println("Sim maxSimInCol " + Formatter.format2(maxSimInCol) + "\t" + InteractionAtomTypeCalculator.getString(interactionTypeBase) + "\t" + InteractionAtomTypeCalculator.getString(interactionTypeQuery));
629578 }
630579 } else {
631580 for (int row = 0 ; row < query .getInteractionTypeCount (); row ++) {
632-
633581 int interactionTypeQuery =-1 ;
634582 int interactionTypeBase =-1 ;
635583
@@ -643,45 +591,35 @@ public double getSimilarityExtraCarbonConsideration(PPNode query, PPNode base) {
643591 }
644592 }
645593 // System.out.println("Sim maxSimInRow " + Formatter.format2(maxSimInRow) + "\t" + InteractionAtomTypeCalculator.getString(interactionTypeBase) + "\t" + InteractionAtomTypeCalculator.getString(interactionTypeQuery));
646-
647-
648594 if (Math .abs (maxSimInRow -valNoInteraction )<TINY ){
649595 continue ;
650596 }
651-
652- liSimilarities . add ( maxSimInRow ); }
597+ liSimilarities . add ( maxSimInRow );
598+ }
653599 }
654-
655-
656600 double sim = 0 ;
657-
658601 if (liSimilarities .size ()>0 ) {
659602 sim = 1 ;
660603 for (Double simPart : liSimilarities ) {
661604 sim *= simPart ;
662605 }
663606 }
664-
665-
666607 if (verbose ) {
667608 System .out .println ("Sim " + Formatter .format2 (sim ));
668609 System .out .println ();
669610 }
670-
671611 return sim ;
672612 }
673613
674614
675615 public boolean isValidType (int type ){
676616 boolean valid = true ;
677-
678617 try {
679618 int key = InteractionDistanceStatistics .getInstance ().getKey (type );
680619 interactionSimilarityTable .getDistance (key , key );
681620 } catch (Exception e ) {
682621 valid = false ;
683622 }
684-
685623 return valid ;
686624 }
687625
0 commit comments