[Git][java-team/openchemlib][upstream] New upstream version 2021.1.1+dfsg

Andrius Merkys gitlab at salsa.debian.org
Tue Jan 19 11:25:20 GMT 2021



Andrius Merkys pushed to branch upstream at Debian Java Maintainers / openchemlib


Commits:
3d4bbf95 by Andrius Merkys at 2021-01-19T03:37:17-05:00
New upstream version 2021.1.1+dfsg
- - - - -


12 changed files:

- pom.xml
- src/main/java/com/actelion/research/calc/ArrayUtilsCalc.java
- src/main/java/com/actelion/research/calc/Matrix.java
- src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerHashedCFp.java
- − src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerHashedPharmSphere.java
- − src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerPharmPath.java
- src/main/java/com/actelion/research/chem/descriptor/FingerPrintGenerator.java
- − src/main/java/com/actelion/research/chem/descriptor/FingerPrintGeneratorPharmGraph.java
- src/main/java/com/actelion/research/chem/io/pdb/converter/BondsCalculator.java
- src/main/java/com/actelion/research/chem/io/pdb/parser/PDBFileParser.java
- src/main/java/com/actelion/research/chem/io/pdb/parser/Residue.java
- src/main/java/com/actelion/research/gui/JChemistryView.java


Changes:

=====================================
pom.xml
=====================================
@@ -8,7 +8,7 @@
     Please follow the naming scheme YEAR.MONTH.RELEASE_NO_OF_MONTH
     (eg. 2016.4.1 for second release in Apr 2016)
     -->
-    <version>2021.1.0</version>
+    <version>2021.1.1</version>
 
     <name>OpenChemLib</name>
     <description>Open Source Chemistry Library</description>
@@ -195,7 +195,7 @@
         <connection>scm:git:git at github.com:Actelion/openchemlib.git</connection>
         <developerConnection>scm:git:git at github.com:Actelion/openchemlib.git</developerConnection>
         <url>https://github.com/Actelion/openchemlib</url>
-      <tag>openchemlib-2021.1.0</tag>
+      <tag>openchemlib-2021.1.1</tag>
   </scm>
 
     <distributionManagement>


=====================================
src/main/java/com/actelion/research/calc/ArrayUtilsCalc.java
=====================================
@@ -178,33 +178,42 @@ public class ArrayUtilsCalc {
     	
     	return var;
 	}
-	
+	public static final double getVariance(int [] arr) {
+		double sum=0;
+		final double mean = getMean(arr);
+    	for (int i = 0; i < arr.length; i++) {
+    		sum += (arr[i]-mean)*(arr[i]-mean);
+		}
+    	final double var = sum / (arr.length - 1);
+    	return var;
+	}
+
 	public static final double getStandardDeviation(double [] arr) {
-		
 		double sum=0;
-		
 		double mean = getMean(arr);
-		
     	for (int i = 0; i < arr.length; i++) {
     		sum += (arr[i]-mean)*(arr[i]-mean);
 		}
-    	
     	double sdv = Math.sqrt(sum / (arr.length - 1));
-    	
     	return sdv;
 	}
 	
 	public static final double getMean(double [] arr) {
-		
 		double sum = 0;
-		
 		for (int i = 0; i < arr.length; i++) {
 			sum += arr[i];
 		}
-		
 		return sum/arr.length;
 	}
-	
+
+	public static final double getMean(int [] arr) {
+		double sum = 0;
+		for (int i = 0; i < arr.length; i++) {
+			sum += arr[i];
+		}
+		return sum/arr.length;
+	}
+
 	public static ModelMedianDouble getMedian(double [] arr) {
 		
 		Arrays.sort(arr);
@@ -705,6 +714,7 @@ public class ArrayUtilsCalc {
 		return res;
 	}
 
+
 	public final static String [] toArray(List<String> list) {
 		String [] res = new String[list.size()];
 		for (int i = 0; i < list.size(); i++) {
@@ -750,6 +760,7 @@ public class ArrayUtilsCalc {
 		return res;
 	}
 
+
 	public final static List<Integer> toList(int [] a) {
 		if(a==null)
 			return null;


=====================================
src/main/java/com/actelion/research/calc/Matrix.java
=====================================
@@ -35,6 +35,7 @@ package com.actelion.research.calc;
 
 import com.actelion.research.util.DoubleVec;
 import com.actelion.research.util.convert.String2DoubleArray;
+import com.actelion.research.util.datamodel.IntegerDouble;
 import com.actelion.research.util.datamodel.ScorePoint;
 
 import java.awt.*;
@@ -538,12 +539,20 @@ public class Matrix {
 
     public float [] getColAsFloat(int iCol) {
         float [] arr = new float [rows()];
-        for(int ii=0; ii < rows(); ii++){
-            arr[ii] = (float)data[ii][iCol];
+        for(int i=0; i < rows(); i++){
+            arr[i] = (float)data[i][iCol];
         }
         return arr;
     }
     
+    public int [] getColAsInt(int iCol) {
+        int [] arr = new int [rows()];
+        for(int i=0; i < rows(); i++){
+            arr[i] = (int)(data[i][iCol]+0.5);
+        }
+        return arr;
+    }
+
     /**
      * 
      * @param vecIndices
@@ -3031,6 +3040,35 @@ public class Matrix {
         OUT_SEPARATOR_ROW = s;
     }
 
+
+    public void shuffleRows() {
+        Random rnd = new Random();
+        int r = rows();
+        for(int i = r; i > 1; --i) {
+            swapRows(i, rnd.nextInt(i));
+        }
+    }
+
+    public void swapRows(int a, int b) {
+        double [] t = data[a];
+        data[a]=data[b];
+        data[b]=t;
+    }
+
+    public void sortRows(int col){
+        int r= rows();
+        List<IntegerDouble> li = new ArrayList<>(r);
+        for (int i = 0; i < r; i++) {
+            li.add(new IntegerDouble(i, get(i, col)));
+        }
+        Collections.sort(li, IntegerDouble.getComparatorDouble());
+        double [][] dataSorted = new double[r][];
+        for (int i = 0; i < r; i++) {
+            dataSorted[i]=data[li.get(i).getInt()];
+        }
+        data = dataSorted;
+    }
+
     /**
      * Get the standard scores, also known as z-scores.
      * @return matrux with standardized values.


=====================================
src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerHashedCFp.java
=====================================
@@ -104,7 +104,7 @@ public class DescriptorHandlerHashedCFp extends AbstractDescriptorHandlerFP<Ster
                     int newMax = max;
                     for (int i=min; i<max; i++) {
                         int atom = atomList[i];
-                        for (int j=0; j<mol.getConnAtoms(atom); j++) {
+                        for (int j=0; j<mol.getConnAtoms(atom) + mol.getMetalBondedConnAtoms(atom); j++) {
                             int connAtom = mol.getConnAtom(atom, j);
                             if (!atomMask[connAtom]) {
                                 atomMask[connAtom] = true;


=====================================
src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerHashedPharmSphere.java deleted
=====================================
@@ -1,152 +0,0 @@
-/*
-* Copyright (c) 1997 - 2016
-* Actelion Pharmaceuticals Ltd.
-* Gewerbestrasse 16
-* CH-4123 Allschwil, Switzerland
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice, this
-*    list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright notice,
-*    this list of conditions and the following disclaimer in the documentation
-*    and/or other materials provided with the distribution.
-* 3. Neither the name of the the copyright holder nor the
-*    names of its contributors may be used to endorse or promote products
-*    derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-package com.actelion.research.chem.descriptor;
-
-import com.actelion.research.chem.Canonizer;
-import com.actelion.research.chem.Molecule;
-import com.actelion.research.chem.SSSearcherWithIndex;
-import com.actelion.research.chem.StereoMolecule;
-import com.actelion.research.util.BurtleHasher;
-import com.actelion.research.util.datamodel.IntVec;
-
-import java.util.Arrays;
-
-public class DescriptorHandlerHashedPharmSphere extends AbstractDescriptorHandlerFP<StereoMolecule> {
-    private static final double CORRECTION_FACTOR = 0.6;
-
-    private static DescriptorHandlerHashedPharmSphere sDefaultInstance;
-    
-    private static final int SPHERE_COUNT = 5;
-    private static final int HASH_BITS = 10;
-    private static final int HASH_INIT = 13;
-    private static final int DESCRIPTOR_SIZE = (1 << HASH_BITS);
-
-    public static DescriptorHandlerHashedPharmSphere getDefaultInstance() {
-    	synchronized(DescriptorHandlerHashedPharmSphere.class) {
-    		if (sDefaultInstance == null) {
-                sDefaultInstance = new DescriptorHandlerHashedPharmSphere();
-        	}
-        }
-        return sDefaultInstance;
-    }
-
-    public DescriptorInfo getInfo() {
-        return DescriptorConstants.DESCRIPTOR_HashedCFp;
-    }
-
-    public String getVersion() {
-        return DescriptorConstants.DESCRIPTOR_HashedCFp.version;
-    }
-
-    /**
-     * This descriptor requires proper up/down bonds, because it encodes stereo parities.
-     * If a passed molecule is generated from idcode parsing, make sure that coordinates
-     * and up/down/bonds are available, i.e. that the IDCodeParser was instantiated with
-     * the respective option.
-     */
-    public int[] createDescriptor(StereoMolecule mol) {
-        if (mol ==null)
-            return null;
-
-        mol.ensureHelperArrays(Molecule.cHelperRings);
-        StereoMolecule fragment = new StereoMolecule(mol.getAllAtoms(), mol.getAllBonds());
-
-        // byte[] descriptor = new byte[DESCRIPTOR_SIZE];
-        int len = DESCRIPTOR_SIZE / Integer.SIZE;
-        IntVec iv = new IntVec(len); 
-
-		int[] atomList = new int[mol.getAtoms()];
-        boolean[] atomMask = new boolean[mol.getAtoms()];
-        for (int rootAtom=0; rootAtom<mol.getAllAtoms(); rootAtom++) {
-            if (rootAtom != 0)
-                Arrays.fill(atomMask, false);
-
-            int min = 0;
-            int max = 0;
-            for (int sphere=0; sphere<SPHERE_COUNT && max<mol.getAllAtoms(); sphere++) {
-                if (max == 0) {
-                    atomList[0] = rootAtom;
-                    atomMask[rootAtom] = true;
-                    max = 1;
-                    }
-                else {
-                    int newMax = max;
-                    for (int i=min; i<max; i++) {
-                        int atom = atomList[i];
-                        for (int j=0; j<mol.getAllConnAtoms(atom)+mol.getMetalBondedConnAtoms(atom); j++) {
-                            int connAtom = mol.getConnAtom(atom, j);
-                            if (!atomMask[connAtom]) {
-                                atomMask[connAtom] = true;
-                                atomList[newMax++] = connAtom;
-                                }
-                            }
-                        }
-                    min = max;
-                    max = newMax;
-                    }
-
-                mol.copyMoleculeByAtoms(fragment, atomMask, true, null);
-
-                // take fragment as it is
-                String idcode = new Canonizer(fragment).getIDCode();
-                int h = BurtleHasher.hashlittle(idcode, HASH_INIT);
-                h = (h & BurtleHasher.hashmask(HASH_BITS));
-                iv.setBit(h);
-
-//System.out.println("atom:"+rootAtom+"\tsphere:"+sphere+"\thash:"+h+"\t"+idcode);
-                }
-            }
-
-        return iv.get();
-        }
-
-    public float getSimilarity(int[] o1, int[] o2) {
-        return o1 == null
-            || o2 == null
-            || o1.length == 0
-            || o2.length == 0 ? 0.0f
-        : normalizeValue(SSSearcherWithIndex.getSimilarityTanimoto(o1, o2));
-    }
-    
-	private float normalizeValue(double value) {
-		return value <= 0.0f ? 0.0f
-			 : value >= 1.0f ? 1.0f
-			 : (float)(1.0-Math.pow(1-Math.pow(value, CORRECTION_FACTOR) ,1.0/CORRECTION_FACTOR));
-	}
-
-    public DescriptorHandler<int[], StereoMolecule> getThreadSafeCopy() {
-    	return this;
-    }
-
-}


=====================================
src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerPharmPath.java deleted
=====================================
@@ -1,95 +0,0 @@
-/*
-* Copyright (c) 1997 - 2016
-* Actelion Pharmaceuticals Ltd.
-* Gewerbestrasse 16
-* CH-4123 Allschwil, Switzerland
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice, this
-*    list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright notice,
-*    this list of conditions and the following disclaimer in the documentation
-*    and/or other materials provided with the distribution.
-* 3. Neither the name of the the copyright holder nor the
-*    names of its contributors may be used to endorse or promote products
-*    derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-package com.actelion.research.chem.descriptor;
-
-import com.actelion.research.chem.StereoMolecule;
-
-public class DescriptorHandlerPharmPath extends AbstractDescriptorHandlerFP<StereoMolecule> implements DescriptorConstants {
-    private static final double CORRECTION_FACTOR = 0.85;
-
-    private static DescriptorHandlerPharmPath sDefaultInstance;
-
-	public static DescriptorHandlerPharmPath getDefaultInstance() {
-		synchronized (DescriptorHandlerPharmPath.class) {
-			if (sDefaultInstance == null) {
-				sDefaultInstance = new DescriptorHandlerPharmPath();
-			}
-		}
-		return sDefaultInstance;
-	}
-
-	public DescriptorInfo getInfo() {
-		return DESCRIPTOR_PFP512;
-	}
-
-	public String getVersion() {
-		return DescriptorConstants.DESCRIPTOR_PFP512.version;
-	}
-
-	public int[] createDescriptor(StereoMolecule mol) {
-		if (mol ==null)
-			return null;
-
-		java.util.BitSet bitset = new FingerPrintGeneratorPharmGraph().getFingerprint(mol);
-
-		if (bitset == null)
-			return FAILED_OBJECT;
-
-		int[] fp = new int[16];
-		int mask = 1;
-		for (int i = 0; i < 32; i++) {
-			for (int j = 0; j < 16; j++)
-				if (bitset.get(16 * i + j))
-					fp[j] += mask;
-			mask <<= 1;
-		}
-
-		return fp;
-	}
-
-	public DescriptorHandler<int[], StereoMolecule> getThreadSafeCopy() {
-		return this;
-	}
-
-	@Override
-    public float getSimilarity(int[] o1, int[] o2) {
-		return normalizeValue(super.getSimilarity(o1, o2));
-    }
-
-	private float normalizeValue(double value) {
-		return value <= 0.0f ? 0.0f
-			 : value >= 1.0f ? 1.0f
-			 : (float)(1.0-Math.pow(1-Math.pow(value, CORRECTION_FACTOR) ,1.0/CORRECTION_FACTOR));
-	}
-}


=====================================
src/main/java/com/actelion/research/chem/descriptor/FingerPrintGenerator.java
=====================================
@@ -151,7 +151,7 @@ public class FingerPrintGenerator
     {
         paths = new Hashtable();
         debugCounter = 0;
-        int atoms = mol.getAllAtoms();
+        int atoms = mol.getAtoms();
         String s;
         boolean[] flags = new boolean[atoms];
         for (int atom = 0; atom < atoms; atom++) {
@@ -178,7 +178,7 @@ public class FingerPrintGenerator
      */
     private void traverseDFS(StereoMolecule mol, int lastAtom, int rootAtom, String path, int depth, boolean flags[])
     {
-        int connAtoms = mol.getConnAtoms(rootAtom);
+        int connAtoms = mol.getConnAtoms(rootAtom) + mol.getMetalBondedConnAtoms(rootAtom);
         int nextAtom = 0, bond = 0;
         StringBuilder newPath = new StringBuilder();
 
@@ -206,6 +206,8 @@ public class FingerPrintGenerator
                     newPath.append("=");
                 } else if (mol.getBondOrder(bond) == 3) {
                     newPath.append("#");
+                } else if (mol.getBondOrder(bond) == 0) {
+                    newPath.append(".");
                 } else
                     System.out.println(
                         "FingerPrintGenerator.depthFirstSearch() " +


=====================================
src/main/java/com/actelion/research/chem/descriptor/FingerPrintGeneratorPharmGraph.java deleted
=====================================
@@ -1,218 +0,0 @@
-/*
-* Copyright (c) 1997 - 2016
-* Actelion Pharmaceuticals Ltd.
-* Gewerbestrasse 16
-* CH-4123 Allschwil, Switzerland
-*
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* 1. Redistributions of source code must retain the above copyright notice, this
-*    list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright notice,
-*    this list of conditions and the following disclaimer in the documentation
-*    and/or other materials provided with the distribution.
-* 3. Neither the name of the the copyright holder nor the
-*    names of its contributors may be used to endorse or promote products
-*    derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-package com.actelion.research.chem.descriptor;
-
-import com.actelion.research.chem.IDCodeParser;
-import com.actelion.research.chem.Molecule;
-import com.actelion.research.chem.StereoMolecule;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.BitSet;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-
-/**
- * Generator of a path-based Fingerprint
- * Not thread safe!
- */
-public class FingerPrintGeneratorPharmGraph 
-{
-    private static final int MAX_BITS = 512;
-    private static final int MAX_DEPTH = 6;
-    private static final boolean DEBUG = false;
-    private static int debugCounter = 0;
-    private Hashtable paths;
-
-
-    /**
-     * Generates a fingerprint of the default size for the given ExtendedMolecule
-     *
-     * @param mol The ExtendedMolecule for which a Fingerprint is generated
-     * @return The Fingerprint (A one-dimensional bit array)
-     */
-    public BitSet getFingerprint(StereoMolecule mol)
-    {
-        return getFingerprint(mol, MAX_BITS);
-    }
-
-
-    /**
-     * Generates the fingerprint of a molecule
-     *
-     * @param mol  The ExtendedMolecule for which a Fingerprint is generated
-     * @param size The desired size of the fingerprint
-     * @return The Fingerprint (A one-dimensional bit array)
-     */
-    public BitSet getFingerprint(StereoMolecule mol, int size)
-    {
-        String path = null;
-        int index;
-
-        mol.ensureHelperArrays(Molecule.cHelperRings);
-        findAllPaths(mol);
-        BitSet bs = new BitSet(size);
-        for (Enumeration e = paths.elements(); e.hasMoreElements(); ) {
-            path = (String) e.nextElement();
-            index = new java.util.Random(path.hashCode()).nextInt(size);
-            if (DEBUG)
-                System.out.print(this.toString().substring(40) + " ");
-//                System.out.println("Setting bit " + position + " for " + path);
-            bs.set(index);
-        }
-        return bs;
-    }
-
-
-
-
-   
-    /**
-     * Find all paths up to MAX_DEPTH length.
-     * The paths are acquired by a number of depth first searches, one for each atom.
-     *
-     * @param mol The Molecule which is to be searched.
-     */
-    private void findAllPaths(StereoMolecule mol)
-    {
-        paths = new Hashtable();
-        debugCounter = 0;
-        int atoms = mol.getAllAtoms();
-        String s;
-        boolean[] flags = new boolean[atoms];
-        for (int atom = 0; atom < atoms; atom++) {
-            s = mol.getAtomLabel(atom);
-            for (int i = 0; i < atoms; i++)
-                flags[i] = false;
-            addPath(s);
-            if (DEBUG)
-                System.out.println("\t***Starting at atom " + atom + " with symbol " + mol.getAtomLabel(atom));
-            traverseDFS(mol, -1, atom, s, 0, flags);
-        }
-    }
-
-
-    /**
-     * Performs a recursive depth first search
-     *
-     * @param mol          The Molecule to be searched
-     * @param lastAtom     The Atom we came from
-     * @param rootAtom     The Atom to start the search at
-     * @param path         The Path that has been generated so far
-     * @param depth        The current depth in this recursive search
-     * @param flags        Helper flags
-     */
-
-    private void traverseDFS(StereoMolecule mol, int lastAtom, int rootAtom, String path, int depth, boolean flags[])
-    {
-        int connAtoms = mol.getConnAtoms(rootAtom)+mol.getMetalBondedConnAtoms(rootAtom);
-        int nextAtom = 0, bond = 0;
-        StringBuilder newPath = new StringBuilder();
-
-        depth++;
-        // Check all connected atoms
-        for (int i = 0; i < connAtoms; i++) {
-            // Flag starting point
-            flags[rootAtom] = true;
-            nextAtom = mol.getConnAtom(rootAtom, i);
-            if (nextAtom == lastAtom) {
-                continue;
-            }
-
-            // Not yet seen
-            if (!flags[nextAtom]) {
-                bond = mol.getConnBond(rootAtom, i);
-                newPath.setLength(0);
-                newPath.append(path);
-                // Construct a string with Daylight kind of bond encoding
-                if (mol.isDelocalizedBond(bond) || mol.isAromaticBond(bond)) {
-                    newPath.append(":");
-                } else if (mol.getBondOrder(bond) == 1) {
-                    newPath.append("-");
-                } else if (mol.getBondOrder(bond) == 2) {
-                    newPath.append("=");
-                } else if (mol.getBondOrder(bond) == 3) {
-                    newPath.append("#");
-                } else if (mol.getBondOrder(bond) == 0) {
-                    newPath.append(".");
-                } else
-                    System.out.println(
-                        "FingerPrintGenerator.depthFirstSearch() " +
-                            "Error: Invalid Bond order! " + mol.getBondOrder(bond));
-                newPath.append(mol.getAtomLabel(nextAtom));
-
-                // Mark nextAtom as visited
-                flags[nextAtom] = true;
-                addPath(newPath.toString());
-                if (depth == MAX_DEPTH) {
-                    // Unmark nextAtoms so we might visit it again during another run
-                    flags[nextAtom] = false;
-                    // System.out.println("Reached end of depth!!! " + newPath);
-                }
-                if (depth < MAX_DEPTH) {
-                    // System.out.println("Visiting " + rootAtom + " + " + nextAtom + " " + newPath);
-                    traverseDFS(mol, rootAtom, nextAtom, newPath.toString(), depth, flags);
-                    // Unmark nextAtoms so we might visit it again during another run
-                    flags[nextAtom] = false;
-                }
-            }
-        }
-    }
-
-    private boolean addPath(String newPath)
-    {
-        String storePath = newPath;
-        String reversePath = new StringBuilder(storePath).reverse().toString();
-        boolean ok = false;
-        // Find the "smaller" version
-        if (reversePath.compareTo(newPath) < 0) {
-            /* reversePath is smaller than newPath so we keep reversePath */
-            storePath = reversePath;
-        }
-        if (DEBUG)
-            System.out.println("Checking for existence of Path " + storePath);
-        if (!paths.containsKey(storePath)) {
-            paths.put(storePath, storePath);
-            ok = true;
-            if (DEBUG) {
-                debugCounter++;
-                System.out.println("Storing path no. " + debugCounter + ": " + storePath + ", Hash: " + storePath.hashCode());
-            }
-        }
-        return ok;
-    }
-
-
-}


=====================================
src/main/java/com/actelion/research/chem/io/pdb/converter/BondsCalculator.java
=====================================
The diff for this file was not included because it is too large.

=====================================
src/main/java/com/actelion/research/chem/io/pdb/parser/PDBFileParser.java
=====================================
@@ -519,7 +519,7 @@ public class PDBFileParser {
 	        //
 	    }
 	    
-	    indexLine--;
+	    //indexLine--;
         List<AtomRecord> hetAtomRecords = new ArrayList<AtomRecord>();
         List<AtomRecord> protAtomRecords = new ArrayList<AtomRecord>();
         modelParser.parse(liRaw, indexLine,protAtomRecords,hetAtomRecords);


=====================================
src/main/java/com/actelion/research/chem/io/pdb/parser/Residue.java
=====================================
@@ -89,13 +89,16 @@ public class Residue {
 			fragment.setAtomY(atom,record.getY());
 			fragment.setAtomZ(atom,record.getZ());
 		}
+
+		fragment.ensureHelperArrays(Molecule.cHelperCIP);
 		try {
-			BondsCalculator.createBonds(fragment, true);
-			BondsCalculator.calculateBondOrders(fragment);
+			BondsCalculator.createBonds(fragment, true,null);
+			BondsCalculator.calculateBondOrders(fragment,true);
 		} catch (Exception e) {
-			System.err.println("Cannot process structure");
+			// TODO Auto-generated catch block
+			System.err.println();
 		}
-		fragment.ensureHelperArrays(Molecule.cHelperCIP);
+
 		return fragment;
 	}
 	


=====================================
src/main/java/com/actelion/research/gui/JChemistryView.java
=====================================
@@ -34,6 +34,8 @@
 package com.actelion.research.gui;
 
 import com.actelion.research.chem.*;
+import com.actelion.research.chem.io.CompoundFileHelper;
+import com.actelion.research.chem.io.RDFileParser;
 import com.actelion.research.chem.io.RXNFileParser;
 import com.actelion.research.chem.reaction.Reaction;
 import com.actelion.research.gui.clipboard.ClipboardHandler;
@@ -373,11 +375,23 @@ public class JChemistryView extends JComponent
 			}
 
 		if (e.getActionCommand().equals(ITEM_OPEN_RXN) && mIsEditable) {
-			File rxnFile = FileHelper.getFile(this, "Please select a reaction file", FileHelper.cFileTypeRXN);
+			File rxnFile = FileHelper.getFile(this, "Please select a reaction file",
+					FileHelper.cFileTypeRXN | CompoundFileHelper.cFileTypeRD);
 			if (rxnFile != null) {
 				try {
-					Reaction reaction = new RXNFileParser().getReaction(rxnFile);
-					pasteOrDropReaction(reaction);
+					Reaction reaction = null;
+
+					if (FileHelper.getFileType(rxnFile.getName()) == FileHelper.cFileTypeRXN) {
+						reaction = new RXNFileParser().getReaction(rxnFile);
+						}
+					else {
+						RDFileParser rdfParser = new RDFileParser(rxnFile);
+						if (rdfParser.isReactionNext())
+							reaction = rdfParser.getNextReaction();
+						}
+
+					if (reaction != null)
+						pasteOrDropReaction(reaction);
 					}
 				catch (Exception ex) {}
 				}



View it on GitLab: https://salsa.debian.org/java-team/openchemlib/-/commit/3d4bbf950a6711a7db54a882784d78f4ad2eb5dd

-- 
View it on GitLab: https://salsa.debian.org/java-team/openchemlib/-/commit/3d4bbf950a6711a7db54a882784d78f4ad2eb5dd
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210119/c3164ac5/attachment.html>


More information about the pkg-java-commits mailing list