|
70 | 70 | import com.actelion.research.calc.statistics.median.MedianStatisticFunctions; |
71 | 71 | import com.actelion.research.chem.descriptor.DescriptorEncoder; |
72 | 72 | import com.actelion.research.chem.descriptor.DescriptorHandler; |
| 73 | +import com.actelion.research.chem.mcs.ListWithIntVec; |
73 | 74 | import com.actelion.research.util.BurtleHasher; |
| 75 | +import com.actelion.research.util.datamodel.IntegerDouble; |
74 | 76 |
|
75 | 77 | import java.util.*; |
76 | 78 |
|
@@ -1614,4 +1616,108 @@ public static int getAtomicNoRGroup(int r){ |
1614 | 1616 | } |
1615 | 1617 | return arrRGroupsAtomicNo[r-1]; |
1616 | 1618 | } |
| 1619 | + |
| 1620 | + /** |
| 1621 | + * Topological centaer atoms are the atoms with the lowest squared sum of topological distances to all atoms. |
| 1622 | + * @param |
| 1623 | + * @return |
| 1624 | + */ |
| 1625 | + public final static List<Integer> getTopologicalCenter(int [][] arrTopoDist) { |
| 1626 | + List<Integer> liTopoCenterAtoms = new ArrayList<>(); |
| 1627 | + List<IntegerDouble> li = new ArrayList<>(); |
| 1628 | + for (int i = 0; i < arrTopoDist.length; i++) { |
| 1629 | + double sum=0; |
| 1630 | + for (int j = 0; j < arrTopoDist.length; j++) { |
| 1631 | + sum += arrTopoDist[i][j]*arrTopoDist[i][j]; |
| 1632 | + } |
| 1633 | + li.add(new IntegerDouble(i,sum)); |
| 1634 | + } |
| 1635 | + Collections.sort(li, IntegerDouble.getComparatorDouble()); |
| 1636 | + liTopoCenterAtoms.add(li.get(0).getInt()); |
| 1637 | + for (int i = 1; i < li.size(); i++) { |
| 1638 | + if(li.get(i).getDouble()==li.get(0).getDouble()){ |
| 1639 | + liTopoCenterAtoms.add(li.get(i).getInt()); |
| 1640 | + } |
| 1641 | + } |
| 1642 | + return liTopoCenterAtoms; |
| 1643 | + } |
| 1644 | + |
| 1645 | + public final static List<Integer> getTopologicalCenter(int [][] arrTopoDist, ListWithIntVec ilIndexAtoms) { |
| 1646 | + List<Integer> liTopoCenterAtoms = new ArrayList<Integer>(); |
| 1647 | + |
| 1648 | + List<IntegerDouble> li = new ArrayList<IntegerDouble>(); |
| 1649 | + |
| 1650 | + for (int i = 0; i < ilIndexAtoms.size(); i++) { |
| 1651 | + |
| 1652 | + int indexAt1 = ilIndexAtoms.get(i); |
| 1653 | + |
| 1654 | + double sum=0; |
| 1655 | + for (int j = 0; j < ilIndexAtoms.size(); j++) { |
| 1656 | + |
| 1657 | + int indexAt2 = ilIndexAtoms.get(j); |
| 1658 | + |
| 1659 | + sum += arrTopoDist[indexAt1][indexAt2]*arrTopoDist[indexAt1][indexAt2]; |
| 1660 | + } |
| 1661 | + |
| 1662 | + li.add(new IntegerDouble(indexAt1,sum)); |
| 1663 | + } |
| 1664 | + |
| 1665 | + Collections.sort(li, IntegerDouble.getComparatorDouble()); |
| 1666 | + |
| 1667 | + liTopoCenterAtoms.add(li.get(0).getInt()); |
| 1668 | + |
| 1669 | + for (int i = 1; i < li.size(); i++) { |
| 1670 | + if(li.get(i).getDouble()==li.get(0).getDouble()){ |
| 1671 | + liTopoCenterAtoms.add(li.get(i).getInt()); |
| 1672 | + } |
| 1673 | + } |
| 1674 | + |
| 1675 | + return liTopoCenterAtoms; |
| 1676 | + } |
| 1677 | + |
| 1678 | + /** |
| 1679 | + * Gets the points with the maximum sum of squared topological distances to all atoms. |
| 1680 | +
|
| 1681 | + * @param arrTopoDist |
| 1682 | + * @return |
| 1683 | + */ |
| 1684 | + public final static List<Integer> getPeriphericPoints(int [][] arrTopoDist) { |
| 1685 | + List<Integer> liPeripheric = new ArrayList<>(); |
| 1686 | + List<IntegerDouble> li = new ArrayList<>(); |
| 1687 | + for (int i = 0; i < arrTopoDist.length; i++) { |
| 1688 | + double sum=0; |
| 1689 | + for (int j = 0; j < arrTopoDist.length; j++) { |
| 1690 | + sum += arrTopoDist[i][j]*arrTopoDist[i][j]; |
| 1691 | + } |
| 1692 | + li.add(new IntegerDouble(i,sum)); |
| 1693 | + } |
| 1694 | + Collections.sort(li, IntegerDouble.getComparatorDouble()); |
| 1695 | + Collections.reverse(li); |
| 1696 | + liPeripheric.add(li.get(0).getInt()); |
| 1697 | + for (int i = 1; i < li.size(); i++) { |
| 1698 | + if(li.get(i).getDouble()==li.get(0).getDouble()){ |
| 1699 | + liPeripheric.add(li.get(i).getInt()); |
| 1700 | + } |
| 1701 | + } |
| 1702 | + return liPeripheric; |
| 1703 | + } |
| 1704 | + |
| 1705 | + /** |
| 1706 | + * Distance is the sum of squares for every atom index. |
| 1707 | + * Sorted in ascending order. |
| 1708 | + * @param arrTopoDist |
| 1709 | + * @return |
| 1710 | + */ |
| 1711 | + public final static List<IntegerDouble> getAllIndicesSortedByDistance(int [][] arrTopoDist) { |
| 1712 | + List<IntegerDouble> li = new ArrayList<>(); |
| 1713 | + for (int i = 0; i < arrTopoDist.length; i++) { |
| 1714 | + double sum=0; |
| 1715 | + for (int j = 0; j < arrTopoDist.length; j++) { |
| 1716 | + sum += arrTopoDist[i][j]*arrTopoDist[i][j]; |
| 1717 | + } |
| 1718 | + li.add(new IntegerDouble(i,sum)); |
| 1719 | + } |
| 1720 | + Collections.sort(li, IntegerDouble.getComparatorDouble()); |
| 1721 | + return li; |
| 1722 | + } |
1617 | 1723 | } |
0 commit comments