/** * @return the allBondMCS */ public synchronized List<Map<IBond, IBond>> getAllBondMaps() { if (!getMCSList().isEmpty()) { return makeBondMapsOfAtomMaps(getQuery(), getTarget(), getMCSList()); } return new ArrayList<>(); }
private static BaseMapping runSubstructure( IAtomContainer query, IAtomContainer target, int filter, boolean matchBonds, boolean matchRings, boolean matchAtomTypes) throws CDKException { // XXX - if clean and configure is 'true', is that not duplicate configuring? BaseMapping smsd = new Substructure(query, target, matchBonds, matchRings, matchAtomTypes, true); if (smsd.isSubgraph()) { if (filter == 0) { smsd.setChemFilters(false, false, false); } if (filter == 1) { smsd.setChemFilters(true, false, false); } if (filter == 2) { smsd.setChemFilters(true, true, false); } if (filter == 3) { smsd.setChemFilters(true, true, true); } } return smsd; }
@Override public synchronized void setChemFilters(boolean stereoFilter, boolean fragmentFilter, boolean energyFilter) { if (getMappingCount() > 0) { if (energyFilter) { try { sortResultsByEnergies(); this.bondEnergiesList = getSortedEnergy(); } catch (CDKException ex) { Logger.error(Level.SEVERE, null, ex); } } if (fragmentFilter) { sortResultsByFragments(); this.fragmentSizeList = getSortedFragment(); } if (stereoFilter) { try { sortResultsByStereoAndBondMatch(); this.stereoScoreList = getStereoMatches(); } catch (CDKException ex) { Logger.error(Level.SEVERE, null, ex); } } } }
/** * {@inheritDoc} * * @return */ @Override public synchronized AtomAtomMapping getFirstAtomMapping() { return getMCSList().isEmpty() ? new AtomAtomMapping(getQuery(), getTarget()) : getMCSList().iterator().next(); }
outputHandler.writeTargetMol(smsd.getTarget()); IAtomContainer queryLocal = query.getBuilder().newInstance(IAtomContainer.class, smsd.getFirstAtomMapping().getQuery()); IAtomContainer targetLocal = target.getBuilder().newInstance(IAtomContainer.class, smsd.getFirstAtomMapping().getTarget()); Map<IAtom, IAtom> mcs = smsd.getFirstAtomMapping().getMappingsByAtoms(); int nAtomsMatched = (mcs == null) ? 0 : mcs.size(); double tanimotoSimilarity = smsd.getTanimotoSimilarity(); for (AtomAtomMapping aam : smsd.getAllAtomMapping()) { Map<Integer, Integer> mapping = aam.getMappingsByIndex(); if (argumentHandler.isImage() && !mapping.isEmpty()) { double stereoScore = smsd.getStereoScore(counter); String label = outputHandler.makeLabel(tanimotoSimilarity, stereoScore); outputHandler.addImage(queryLocal, targetLocal, label, mapping); Map<Integer, Integer> mcsNumber = smsd.getFirstAtomMapping().getMappingsByIndex(); double stereoScore = smsd.getStereoScore(0); outputHandler.printHeader(queryPath, targetPath, nAtomsMatched); String qrefName = inputHandler.getQRefName(); double tanimotoGraph = smsd.getTanimotoSimilarity(); double euclidianGraph = smsd.getEuclideanDistance(); outputHandler.writeResults(queryLocal, targetLocal, tanimotoGraph, euclidianGraph, nAtomsMatched, executionTime, smsd.getFirstAtomMapping());
public synchronized boolean isStereoMisMatch() { boolean flag = false; IAtomContainer reactant = getQuery(); IAtomContainer product = getTarget(); int stereoMisMatchScore = 0; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); for (IAtom indexI : firstAtomMCS.getMappingsByAtoms().keySet()) { IAtom indexJ = firstAtomMCS.getMappingsByAtoms().get(indexI);
comparison.setChemFilters(true, true, true); fragmentsFomMCS = getMCSS(comparison); + " unique matches of size " + comparison.getFirstAtomMapping().getCount()); LOGGER.debug("MCSS for task " + taskNumber + " has " + querySeed.getAtomCount() + " atoms, and " + querySeed.getBondCount() + " bonds"); LOGGER.debug("Target for task " + taskNumber + " has " + target.getAtomCount() + " atoms, and " + target.getBondCount() + " bonds");
super(query, target, bondTypeFlag, matchRings, matchAtomType); this.algorithmType = algorithmType; if (super.isMatchRings()) { try { MoleculeInitializer.initializeMolecule(super.getQuery()); MoleculeInitializer.initializeMolecule(super.getTarget()); } catch (CDKException ex) { mcsBuilder(super.getQuery(), super.getTarget()); super.setSubgraph(isSubgraph());
synchronized void printMatch(BaseMapping isomorphism) { int overlap = isomorphism.getFirstAtomMapping().isEmpty() ? 0 : isomorphism.getFirstAtomMapping().getCount(); try { System.out.println("Q: " + isomorphism.getQuery().getID() + " T: " + isomorphism.getTarget().getID() + " atoms: " + isomorphism.getQuery().getAtomCount() + " atoms: " + isomorphism.getTarget().getAtomCount() + " overlaps: " + overlap + " mcs " + isomorphism.getFirstAtomMapping().getCommonFragmentAsSMILES()); } catch (CloneNotSupportedException | CDKException ex) { LOGGER.error(Level.SEVERE, "Print MCS ", ex.getMessage()); } }
super(query, target, am, bm); this.algorithmType = algorithmType; mcsBuilder(super.getQuery(), super.getTarget()); super.setSubgraph(isSubgraph());
/** * {@inheritDoc} */ @Override public synchronized double getTanimotoSimilarity() { int decimalPlaces = 4; double rAtomCount; double pAtomCount; double tanimotoAtom = 0.0; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { rAtomCount = (double) this.getMCSList().iterator().next().getQuery().getAtomCount(); pAtomCount = (double) this.getMCSList().iterator().next().getTarget().getAtomCount(); double matchCount = (double) firstAtomMCS.getCount(); tanimotoAtom = (matchCount) / (rAtomCount + pAtomCount - matchCount); BigDecimal tan = new BigDecimal(tanimotoAtom); tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); tanimotoAtom = tan.doubleValue(); } } return tanimotoAtom; }
@Override public synchronized int getMappingCount() { return this.getMCSList().isEmpty() ? 0 : this.getMCSList().size(); }
private synchronized Collection<Fragment> getMCSS(BaseMapping comparison) { Set<Fragment> matchList = new HashSet<>(); comparison.getAllAtomMapping().stream().forEach((mapping) -> { IAtomContainer match; try { match = mapping.getCommonFragment(); try { matchList.add(new Fragment(match)); } catch (CDKException ex) { LOGGER.error("ERROR IN MCS Thread: ", ex); } } catch (CloneNotSupportedException ex) { LOGGER.error("ERROR IN MCS Thread: ", ex); } }); return matchList; }
private static BaseMapping run( IAtomContainer query, IAtomContainer target, int filter, boolean matchBonds, boolean matchRings, boolean matchAtomType) throws CDKException { // XXX - if clean and configure is 'true', is that not duplicate configuring? BaseMapping smsd = new Isomorphism(query, target, Algorithm.DEFAULT, matchBonds, matchRings, matchAtomType); if (filter == 0) { smsd.setChemFilters(false, false, false); } if (filter == 1) { smsd.setChemFilters(true, false, false); } if (filter == 2) { smsd.setChemFilters(true, true, false); } if (filter == 3) { smsd.setChemFilters(true, true, true); } return smsd; }
for (IAtomContainer target : atomContainerSet) { BaseMapping smsd = run(mcsAtomContainer, target, filter, matchBonds, matchRings, matchBonds); mappings.add(getIndexMapping(smsd.getFirstAtomMapping())); secondRoundTargets.add( builder.newInstance(IAtomContainer.class, smsd.getFirstAtomMapping().getTarget()));
query = query.getBuilder().newInstance(IAtomContainer.class, smsd.getFirstAtomMapping().getQuery()); target = target.getBuilder().newInstance(IAtomContainer.class, smsd.getFirstAtomMapping().getTarget()); long endTime = System.currentTimeMillis(); long executionTime = endTime - startTime; outputHandler.writeQueryMol(smsd.getFirstAtomMapping().getQuery()); outputHandler.writeTargetMol(smsd.getFirstAtomMapping().getTarget()); Map<IAtom, IAtom> mcs = smsd.getFirstAtomMapping().getMappingsByAtoms(); int nAtomsMatched = (mcs == null) ? 0 : mcs.size(); double tanimotoSimilarity = smsd.getTanimotoSimilarity(); outputHandler.printHeader(queryPath, targetPath, nAtomsMatched); int counter = 0; for (AtomAtomMapping aam : smsd.getAllAtomMapping()) { Map<Integer, Integer> mapping = aam.getMappingsByIndex(); if (argumentHandler.isImage() && !mapping.isEmpty()) { double stereoScore = smsd.getStereoScore(counter); String label = outputHandler.makeLabel(tanimotoSimilarity, stereoScore); outputHandler.addImage(query, target, label, mapping); Map<Integer, Integer> mcsNumber = smsd.getFirstAtomMapping().getMappingsByIndex(); double stereoScore = smsd.getStereoScore(0); outputHandler.printHeader(queryPath, targetPath, nAtomsMatched); String qrefName = inputHandler.getQRefName(); double tanimotoGraph = smsd.getTanimotoSimilarity(); double euclidianGraph = smsd.getEuclideanDistance();
public synchronized boolean isStereoMisMatch() { boolean flag = false; IAtomContainer reactant = getQuery(); IAtomContainer product = getTarget(); int stereoMisMatchScore = 0; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); for (IAtom indexI : firstAtomMCS.getMappingsByAtoms().keySet()) { IAtom indexJ = firstAtomMCS.getMappingsByAtoms().get(indexI);
comparison.setChemFilters(true, true, true); fragmentsFomMCS = getMCSS(comparison); + " unique matches of size " + comparison.getFirstAtomMapping().getCount()); logger.debug("MCSS for task " + taskNumber + " has " + querySeed.getAtomCount() + " atoms, and " + querySeed.getBondCount() + " bonds"); logger.debug("Target for task " + taskNumber + " has " + target.getAtomCount() + " atoms, and " + target.getBondCount() + " bonds");
/** * {@inheritDoc} * * @return */ @Override public synchronized AtomAtomMapping getFirstAtomMapping() { return getMCSList().isEmpty() ? new AtomAtomMapping(getQuery(), getTarget()) : getMCSList().iterator().next(); }
super(query, target, bondTypeFlag, matchRings, matchAtomType); this.algorithmType = algorithmType; if (super.isMatchRings()) { try { MoleculeInitializer.initializeMolecule(super.getQuery()); MoleculeInitializer.initializeMolecule(super.getTarget()); } catch (CDKException ex) { mcsBuilder(super.getQuery(), super.getTarget()); super.setSubgraph(isSubgraph());