Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thsa committed Feb 27, 2024
2 parents 40a6074 + 941bb9c commit 62c34bb
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>2024.2.3-SNAPSHOT</version>
<version>2024.2.4-SNAPSHOT</version>

<name>OpenChemLib</name>
<description>Open Source Chemistry Library</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,7 @@ public static boolean isSulfoxyGroup(StereoMolecule mol, int atom) {
public static boolean isIsolatedCarbon(StereoMolecule mol, int indexAtCentral, int [] arrIndexAt){

boolean isolated=true;

int nConnected = mol.getConnAtoms(indexAtCentral);

boolean [] arrConnected = new boolean[mol.getAtoms()];

for (int i = 0; i < nConnected; i++) {
Expand All @@ -1176,7 +1174,6 @@ public static boolean isIsolatedCarbon(StereoMolecule mol, int indexAtCentral, i
if(!arrConnected[indexAt]){
continue;
}

if(mol.getAtomicNo(indexAt)==6){
isolated=false;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,13 @@

import com.actelion.research.calc.ThreadMaster;
import com.actelion.research.chem.*;
import com.actelion.research.chem.conf.Conformer;
import com.actelion.research.chem.descriptor.DescriptorHandlerFlexophore;
import com.actelion.research.chem.descriptor.flexophore.*;
import com.actelion.research.chem.descriptor.flexophore.redgraph.SubGraphExtractor;
import com.actelion.research.chem.descriptor.flexophore.redgraph.SubGraphIndices;
import com.actelion.research.chem.interactionstatistics.InteractionAtomTypeCalculator;
import com.actelion.research.util.TimeDelta;
import org.openmolecules.chem.conf.gen.ConformerGenerator;
import org.openmolecules.chem.conf.gen.RigidFragmentCache;

import java.util.*;
import java.util.concurrent.TimeoutException;

/**
* CreatorMolDistHistViz
Expand All @@ -58,6 +53,18 @@ public class CreatorMolDistHistViz {
private static final boolean DEBUG = DescriptorHandlerFlexophore.DEBUG;


/**
* Aromatic imide structure with an exocyclic N. Two N in the aromatic ring. Results in an extreme electron poor
* exocyclic N. which is not making any interactions. Consequently, it is removed from the subgraph lists.
* The electron poor N is the non-aromatic N in the fragment definitions!
*/
public static final String IDCODE_EXO_N_AROM_IMIDE = "eMPARVCjK|X`";

// Imide structure separated by one bond in the aromatic ring
public static final String IDCODE_EXO_N_AROM_IMIDE_ALPHA = "gO|@AfeJih@PA@";

public static String [] ARR_EXO_N_AROM_IMIDE = {IDCODE_EXO_N_AROM_IMIDE, IDCODE_EXO_N_AROM_IMIDE_ALPHA};


/**
* Similarity 0.977, similarity for identical molecule and a timeout of 5 min. So timeout of 6 min should be fine.
Expand Down Expand Up @@ -95,9 +102,10 @@ public class CreatorMolDistHistViz {
private boolean onlyOneConformer;

private Exception recentException = null;
// Calling SSSearcher frequently generates errors.
// private SSSearcher ssSearcher;

private int [] arrIndexAtomNewTmp;

private StereoMolecule [] arrElectronPoorN;
private ConformerGeneratorStageTries conformerGeneratorStageTries;

public CreatorMolDistHistViz() {
Expand All @@ -106,10 +114,18 @@ public CreatorMolDistHistViz() {

conformationMode = CONF_GEN_TS;

arrIndexAtomNewTmp = new int[MAX_NUM_ATOMS];

conformerGeneratorStageTries = new ConformerGeneratorStageTries();

IDCodeParser parser = new IDCodeParser();

arrElectronPoorN = new StereoMolecule[ARR_EXO_N_AROM_IMIDE.length];

for (int i = 0; i < ARR_EXO_N_AROM_IMIDE.length; i++) {
StereoMolecule frag = parser.getCompactMolecule(ARR_EXO_N_AROM_IMIDE[i]);
frag.ensureHelperArrays(Molecule.cHelperRings);
arrElectronPoorN[i]=frag;
}

}

public void setThreadMaster(ThreadMaster threadMaster) {
Expand Down Expand Up @@ -177,6 +193,8 @@ public MolDistHistViz createMultipleConformations(StereoMolecule molOrig, int nC
//
List<SubGraphIndices> liSubGraphIndices = subGraphExtractor.extract(molInPlace);
liSubGraphIndices = handleCarbonConnected2Hetero(liSubGraphIndices, molInPlace);
liSubGraphIndices = removeExoCyclicElectronPoorN(liSubGraphIndices, molInPlace);


List<MultCoordFragIndex> liMultCoordFragIndex = new ArrayList<>();
for (SubGraphIndices subGraphIndices : liSubGraphIndices) {
Expand Down Expand Up @@ -334,6 +352,85 @@ public static List<SubGraphIndices> handleCarbonConnected2Hetero(List<SubGraphI
return liSubGraphIndicesProcessed;
}

public List<SubGraphIndices> removeExoCyclicElectronPoorN(List<SubGraphIndices> liSubGraphIndices, StereoMolecule molInPlace){

List<Integer> liElectronPoorN = getElectronPoorN(molInPlace);

// if(liElectronPoorN.size()>0)
// System.out.println("CreatorMolDistHistViz removeExoCyclicElectronPoorN found " + liElectronPoorN.size() + " electron poor atoms in " + molInPlace.getIDCode());

boolean [] arrMatchAtom = new boolean[molInPlace.getAtoms()];

for (int indexAt : liElectronPoorN) {
arrMatchAtom[indexAt]=true;
}

List<SubGraphIndices> liSubGraphIndicesProcessed = new ArrayList<>();
for (SubGraphIndices sgi : liSubGraphIndices) {
int[] arrIndexAtomFragment = sgi.getAtomIndices();
HashSet<Integer> hsIndexAtom2Remove = new HashSet<>();
for (int indexAtFrag : arrIndexAtomFragment) {
if (arrMatchAtom[indexAtFrag]) {
hsIndexAtom2Remove.add(indexAtFrag);
}
}

SubGraphIndices sgiProcessed = new SubGraphIndices();
if (hsIndexAtom2Remove.size() > 0) {
for (int indexAtFrag : arrIndexAtomFragment) {
if (!hsIndexAtom2Remove.contains(indexAtFrag)) {
sgiProcessed.addIndex(indexAtFrag);
}
}
} else {
sgiProcessed.addIndex(arrIndexAtomFragment);
}
if (sgiProcessed.getNumIndices() > 0)
liSubGraphIndicesProcessed.add(sgiProcessed);
}
return liSubGraphIndicesProcessed;



}

/**
* The electron poor N is the non-aromatic N!
* @param molInPlace
* @return
*/
private List<Integer> getElectronPoorN(StereoMolecule molInPlace){
List<Integer> liElectronPoorN = new ArrayList<>();

// Calling SSSearcher frequently generates errors.
SSSearcher ssSearcher = new SSSearcher();
ssSearcher.setMolecule(molInPlace);
for (int i = 0; i < arrElectronPoorN.length; i++) {

ssSearcher.setFragment(arrElectronPoorN[i]);
int numFrags = ssSearcher.findFragmentInMolecule(
SSSearcher.cCountModeOverlapping,
SSSearcher.cMatchDBondToDelocalized | SSSearcher.cMatchAromDBondToDelocalized );
if(numFrags>0) {
// System.out.println("Found!");
List<int[]> li = ssSearcher.getMatchList();
for (int[] arrIndex : li) {
for (int j = 0; j < arrIndex.length; j++) {
int indAt = arrIndex[j];
int atNo = molInPlace.getAtomicNo(indAt);
if(atNo==7){
if(!molInPlace.isAromaticAtom(indAt)){
liElectronPoorN.add(indAt);
}
}
}
}
}
}
return liElectronPoorN;
}


/**
* Creates the descriptor from the coordinates.
* @param liMultCoordFragIndex contains the coordinates and the related atom indices of the molecule
Expand Down

0 comments on commit 62c34bb

Please sign in to comment.