@@ -774,10 +774,7 @@ public static final Atom getCentroid(Atom[] atomSet) {
774774 if (atomSet .length ==0 )
775775 throw new IllegalArgumentException ("Atom array has length 0, can't calculate centroid!" );
776776
777- // if we don't catch this case, the centroid returned is (NaN,NaN,NaN), which can cause lots of problems down the line
778- if (atomSet .length ==0 )
779- throw new IllegalArgumentException ("Atom array has length 0, can't calculate centroid!" );
780-
777+
781778 double [] coords = new double [3 ];
782779
783780 coords [0 ] = 0 ;
@@ -805,7 +802,7 @@ public static final Atom getCentroid(Atom[] atomSet) {
805802 * Returns the center of mass of the set of atoms. Atomic masses of the
806803 * Atoms are used.
807804 *
808- * @param atomSet
805+ * @param points
809806 * a set of Atoms
810807 * @return an Atom representing the center of mass
811808 */
@@ -1264,9 +1261,9 @@ public static double rmsd(Atom[] x, Atom[] y) {
12641261 /**
12651262 * Calculate the TM-Score for the superposition.
12661263 *
1267- * <em>Normalizes by the <strong>maximum </strong>-length structure (that is, {@code max \{len1,len2\}}) rather than the minimum .</em>
1264+ * <em>Normalizes by the <strong>minimum </strong>-length structure (that is, {@code min \{len1,len2\}}).</em>
12681265 *
1269- * Atom sets must be superposed .
1266+ * Atom sets must be pre-rotated .
12701267 *
12711268 * <p>
12721269 * Citation:<br/>
@@ -1284,44 +1281,15 @@ public static double rmsd(Atom[] x, Atom[] y) {
12841281 * The full length of the protein supplying atomSet2
12851282 * @return The TM-Score
12861283 * @throws StructureException
1287- * @see {@link #getTMScore(Atom[], Atom[], int, int)}, which normalizes by
1288- * the minimum length
12891284 */
1290- public static double getTMScoreAlternate (Atom [] atomSet1 , Atom [] atomSet2 ,
1291- int len1 , int len2 ) throws StructureException {
1292- if (atomSet1 .length != atomSet2 .length ) {
1293- throw new StructureException (
1294- "The two atom sets are not of same length!" );
1295- }
1296- if (atomSet1 .length > len1 ) {
1297- throw new StructureException (
1298- "len1 must be greater or equal to the alignment length!" );
1299- }
1300- if (atomSet2 .length > len2 ) {
1301- throw new StructureException (
1302- "len2 must be greater or equal to the alignment length!" );
1303- }
1304-
1305- int Lmax = Math .max (len1 , len2 );
1306- int Laln = atomSet1 .length ;
1307-
1308- double d0 = 1.24 * Math .cbrt (Lmax - 15. ) - 1.8 ;
1309- double d0sq = d0 * d0 ;
1310-
1311- double sum = 0 ;
1312- for (int i = 0 ; i < Laln ; i ++) {
1313- double d = Calc .getDistance (atomSet1 [i ], atomSet2 [i ]);
1314- sum += 1. / (1 + d * d / d0sq );
1315- }
1316-
1317- return sum / Lmax ;
1285+ public static double getTMScore (Atom [] atomSet1 , Atom [] atomSet2 ,
1286+ int len1 , int len2 ) throws StructureException {
1287+ return getTMScore (atomSet1 , atomSet2 , len1 , len2 ,true );
13181288 }
13191289
13201290 /**
13211291 * Calculate the TM-Score for the superposition.
13221292 *
1323- * <em>Normalizes by the <strong>minimum</strong>-length structure (that is, {@code min\{len1,len2\}}).</em>
1324- *
13251293 * Atom sets must be pre-rotated.
13261294 *
13271295 * <p>
@@ -1338,11 +1306,15 @@ public static double getTMScoreAlternate(Atom[] atomSet1, Atom[] atomSet2,
13381306 * The full length of the protein supplying atomSet1
13391307 * @param len2
13401308 * The full length of the protein supplying atomSet2
1309+ * @param normalizeMin
1310+ * Whether to normalize by the <strong>minimum</strong>-length structure,
1311+ * that is, {@code min\{len1,len2\}}. If false, normalized by the {@code max\{len1,len2\}}).
1312+ *
13411313 * @return The TM-Score
13421314 * @throws StructureException
13431315 */
13441316 public static double getTMScore (Atom [] atomSet1 , Atom [] atomSet2 , int len1 ,
1345- int len2 ) throws StructureException {
1317+ int len2 , boolean normalizeMin ) throws StructureException {
13461318 if (atomSet1 .length != atomSet2 .length ) {
13471319 throw new StructureException (
13481320 "The two atom sets are not of same length!" );
@@ -1356,10 +1328,16 @@ public static double getTMScore(Atom[] atomSet1, Atom[] atomSet2, int len1,
13561328 "len2 must be greater or equal to the alignment length!" );
13571329 }
13581330
1359- int Lmin = Math .min (len1 , len2 );
1331+ int Lnorm ;
1332+ if (normalizeMin ) {
1333+ Lnorm = Math .min (len1 , len2 );
1334+ } else {
1335+ Lnorm = Math .max (len1 , len2 );
1336+ }
1337+
13601338 int Laln = atomSet1 .length ;
13611339
1362- double d0 = 1.24 * Math .cbrt (Lmin - 15. ) - 1.8 ;
1340+ double d0 = 1.24 * Math .cbrt (Lnorm - 15. ) - 1.8 ;
13631341 double d0sq = d0 * d0 ;
13641342
13651343 double sum = 0 ;
@@ -1368,6 +1346,6 @@ public static double getTMScore(Atom[] atomSet1, Atom[] atomSet2, int len1,
13681346 sum += 1. / (1 + d * d / d0sq );
13691347 }
13701348
1371- return sum / Lmin ;
1349+ return sum / Lnorm ;
13721350 }
13731351}
0 commit comments