use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class RadicalSiteInitiationReaction method initiate.
/**
* Initiate process.
*
*@exception CDKException Description of the Exception
*
* @param reactants reactants of the reaction.
* @param agents agents of the reaction (Must be in this case null).
*/
@Override
public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agents) throws CDKException {
logger.debug("initiate reaction: RadicalSiteInitiationReaction");
if (reactants.getAtomContainerCount() != 1) {
throw new CDKException("RadicalSiteInitiationReaction only expects one reactant");
}
if (agents != null) {
throw new CDKException("RadicalSiteInitiationReaction don't expects agents");
}
IReactionSet setOfReactions = reactants.getBuilder().newInstance(IReactionSet.class);
IAtomContainer reactant = reactants.getAtomContainer(0);
/*
* if the parameter hasActiveCenter is not fixed yet, set the active
* centers
*/
IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
if (ipr != null && !ipr.isSetParameter())
setActiveCenters(reactant);
for (IAtom atomi : reactants.getAtomContainer(0).atoms()) {
if (atomi.getFlag(CDKConstants.REACTIVE_CENTER) && reactant.getConnectedSingleElectronsCount(atomi) == 1 && atomi.getFormalCharge() == 0) {
for (IBond bondi : reactant.getConnectedBondsList(atomi)) {
if (bondi.getFlag(CDKConstants.REACTIVE_CENTER) && bondi.getOrder() == IBond.Order.SINGLE) {
IAtom atomj = bondi.getOther(atomi);
if (atomj.getFlag(CDKConstants.REACTIVE_CENTER) && atomj.getFormalCharge() == 0) {
for (IBond bondj : reactant.getConnectedBondsList(atomj)) {
if (bondj.equals(bondi))
continue;
if (bondj.getFlag(CDKConstants.REACTIVE_CENTER) && bondj.getOrder() == IBond.Order.SINGLE) {
IAtom atomk = bondj.getOther(atomj);
if (atomk.getFlag(CDKConstants.REACTIVE_CENTER) && atomk.getAtomicNumber() == IElement.C && atomk.getFormalCharge() == 0) {
ArrayList<IAtom> atomList = new ArrayList<>();
atomList.add(atomi);
atomList.add(atomj);
atomList.add(atomk);
ArrayList<IBond> bondList = new ArrayList<>();
bondList.add(bondi);
bondList.add(bondj);
IAtomContainerSet moleculeSet = reactant.getBuilder().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(reactant);
IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
if (reaction == null)
continue;
else
setOfReactions.addReaction(reaction);
}
}
}
}
}
}
}
}
return setOfReactions;
}
use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class CarbonylEliminationReaction method initiate.
/**
* Initiate process.
*
*@exception CDKException Description of the Exception
*
* @param reactants reactants of the reaction
* @param agents agents of the reaction (Must be in this case null)
*/
@Override
public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agents) throws CDKException {
logger.debug("initiate reaction: CarbonylEliminationReaction");
if (reactants.getAtomContainerCount() != 1) {
throw new CDKException("CarbonylEliminationReaction only expects one reactant");
}
if (agents != null) {
throw new CDKException("CarbonylEliminationReaction don't expects agents");
}
IReactionSet setOfReactions = reactants.getBuilder().newInstance(IReactionSet.class);
IAtomContainer reactant = reactants.getAtomContainer(0);
/*
* if the parameter hasActiveCenter is not fixed yet, set the active
* centers
*/
IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
if (ipr != null && !ipr.isSetParameter())
setActiveCenters(reactant);
for (IAtom atomi : reactant.atoms()) {
if (atomi.getFlag(CDKConstants.REACTIVE_CENTER) && atomi.getAtomicNumber() == IElement.O && atomi.getFormalCharge() == 1) {
for (IBond bondi : reactant.getConnectedBondsList(atomi)) {
if (bondi.getFlag(CDKConstants.REACTIVE_CENTER) && bondi.getOrder() == IBond.Order.TRIPLE) {
IAtom atomj = bondi.getOther(atomi);
if (atomj.getFlag(CDKConstants.REACTIVE_CENTER)) {
for (IBond bondj : reactant.getConnectedBondsList(atomj)) {
if (bondj.equals(bondi))
continue;
if (bondj.getFlag(CDKConstants.REACTIVE_CENTER) && bondj.getOrder() == IBond.Order.SINGLE) {
IAtom atomk = bondj.getOther(atomj);
if (atomk.getFlag(CDKConstants.REACTIVE_CENTER) && atomk.getFormalCharge() == 0) {
ArrayList<IAtom> atomList = new ArrayList<>();
atomList.add(atomk);
atomList.add(atomj);
ArrayList<IBond> bondList = new ArrayList<>();
bondList.add(bondj);
IAtomContainerSet moleculeSet = reactant.getBuilder().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(reactant);
IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
if (reaction == null)
continue;
else
setOfReactions.addReaction(reaction);
}
}
}
}
}
}
}
}
return setOfReactions;
}
use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class ElectronImpactSDBReaction method initiate.
/**
* Initiate process.
* It is needed to call the addExplicitHydrogensToSatisfyValency
* from the class tools.HydrogenAdder.
*
*@exception CDKException Description of the Exception
*
* @param reactants reactants of the reaction.
* @param agents agents of the reaction (Must be in this case null).
*/
@Override
public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agents) throws CDKException {
logger.debug("initiate reaction: ElectronImpactSDBReaction");
if (reactants.getAtomContainerCount() != 1) {
throw new CDKException("ElectronImpactSDBReaction only expects one reactant");
}
if (agents != null) {
throw new CDKException("ElectronImpactSDBReaction don't expects agents");
}
IReactionSet setOfReactions = reactants.getBuilder().newInstance(IReactionSet.class);
IAtomContainer reactant = reactants.getAtomContainer(0);
/*
* if the parameter hasActiveCenter is not fixed yet, set the active
* centers
*/
IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
if (ipr != null && !ipr.isSetParameter())
setActiveCenters(reactant);
for (IBond bondi : reactant.bonds()) {
IAtom atom1 = bondi.getBegin();
IAtom atom2 = bondi.getEnd();
if (bondi.getFlag(CDKConstants.REACTIVE_CENTER) && bondi.getOrder() == IBond.Order.SINGLE && atom1.getFlag(CDKConstants.REACTIVE_CENTER) && atom2.getFlag(CDKConstants.REACTIVE_CENTER) && (atom1.getFormalCharge() == CDKConstants.UNSET ? 0 : atom1.getFormalCharge()) == 0 && (atom2.getFormalCharge() == CDKConstants.UNSET ? 0 : atom2.getFormalCharge()) == 0 && reactant.getConnectedSingleElectronsCount(atom1) == 0 && reactant.getConnectedSingleElectronsCount(atom2) == 0) {
/**/
for (int j = 0; j < 2; j++) {
ArrayList<IAtom> atomList = new ArrayList<>();
if (j == 0) {
atomList.add(atom1);
atomList.add(atom2);
} else {
atomList.add(atom2);
atomList.add(atom1);
}
ArrayList<IBond> bondList = new ArrayList<>();
bondList.add(bondi);
IAtomContainerSet moleculeSet = reactant.getBuilder().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(reactant);
IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
if (reaction == null)
continue;
else
setOfReactions.addReaction(reaction);
}
}
}
return setOfReactions;
}
use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class HeterolyticCleavagePBReaction method initiate.
/**
* Initiate process.
* It is needed to call the addExplicitHydrogensToSatisfyValency
* from the class tools.HydrogenAdder.
*
*@exception CDKException Description of the Exception
*
* @param reactants reactants of the reaction
* @param agents agents of the reaction (Must be in this case null)
*/
@Override
public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agents) throws CDKException {
logger.debug("initiate reaction: HeterolyticCleavagePBReaction");
if (reactants.getAtomContainerCount() != 1) {
throw new CDKException("HeterolyticCleavagePBReaction only expects one reactant");
}
if (agents != null) {
throw new CDKException("HeterolyticCleavagePBReaction don't expects agents");
}
IReactionSet setOfReactions = reactants.getBuilder().newInstance(IReactionSet.class);
IAtomContainer reactant = reactants.getAtomContainer(0);
/*
* if the parameter hasActiveCenter is not fixed yet, set the active
* centers
*/
IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
if (ipr != null && !ipr.isSetParameter())
setActiveCenters(reactant);
for (IBond bondi : reactant.bonds()) {
IAtom atom1 = bondi.getBegin();
IAtom atom2 = bondi.getEnd();
if (bondi.getFlag(CDKConstants.REACTIVE_CENTER) && bondi.getOrder() != IBond.Order.SINGLE && atom1.getFlag(CDKConstants.REACTIVE_CENTER) && atom2.getFlag(CDKConstants.REACTIVE_CENTER) && (atom1.getFormalCharge() == CDKConstants.UNSET ? 0 : atom1.getFormalCharge()) == 0 && (atom2.getFormalCharge() == CDKConstants.UNSET ? 0 : atom2.getFormalCharge()) == 0 && reactant.getConnectedSingleElectronsCount(atom1) == 0 && reactant.getConnectedSingleElectronsCount(atom2) == 0) {
/**/
for (int j = 0; j < 2; j++) {
ArrayList<IAtom> atomList = new ArrayList<>();
if (j == 0) {
atomList.add(atom1);
atomList.add(atom2);
} else {
atomList.add(atom2);
atomList.add(atom1);
}
ArrayList<IBond> bondList = new ArrayList<>();
bondList.add(bondi);
IAtomContainerSet moleculeSet = reactant.getBuilder().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(reactant);
IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
if (reaction == null)
continue;
else
setOfReactions.addReaction(reaction);
}
}
}
return setOfReactions;
}
use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.
the class RadicalChargeSiteInitiationHReaction method initiate.
/**
* Initiate process.
*
*@exception CDKException Description of the Exception
*
* @param reactants reactants of the reaction.
* @param agents agents of the reaction (Must be in this case null).
*/
@Override
public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agents) throws CDKException {
logger.debug("initiate reaction: RadicalChargeSiteInitiationHReaction");
if (reactants.getAtomContainerCount() != 1) {
throw new CDKException("RadicalChargeSiteInitiationHReaction only expects one reactant");
}
if (agents != null) {
throw new CDKException("RadicalChargeSiteInitiationHReaction don't expects agents");
}
IReactionSet setOfReactions = reactants.getBuilder().newInstance(IReactionSet.class);
IAtomContainer reactant = reactants.getAtomContainer(0);
/*
* if the parameter hasActiveCenter is not fixed yet, set the active
* centers
*/
IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
if (ipr != null && !ipr.isSetParameter())
setActiveCenters(reactant);
for (IAtom atomi : reactants.getAtomContainer(0).atoms()) {
if (atomi.getFlag(CDKConstants.REACTIVE_CENTER) && reactant.getConnectedSingleElectronsCount(atomi) == 1 && atomi.getFormalCharge() == 1) {
for (IBond bondi : reactant.getConnectedBondsList(atomi)) {
if (bondi.getFlag(CDKConstants.REACTIVE_CENTER) && bondi.getOrder() == IBond.Order.SINGLE) {
IAtom atomj = bondi.getOther(atomi);
if (atomj.getFlag(CDKConstants.REACTIVE_CENTER) && atomj.getFormalCharge() == 0) {
for (IBond bondj : reactant.getConnectedBondsList(atomj)) {
if (bondj.equals(bondi))
continue;
if (bondj.getFlag(CDKConstants.REACTIVE_CENTER) && bondj.getOrder() == IBond.Order.SINGLE) {
IAtom atomk = bondj.getOther(atomj);
if (atomk.getFlag(CDKConstants.REACTIVE_CENTER) && atomk.getAtomicNumber() == IElement.H && atomk.getFormalCharge() == 0) {
ArrayList<IAtom> atomList = new ArrayList<>();
atomList.add(atomi);
atomList.add(atomj);
atomList.add(atomk);
ArrayList<IBond> bondList = new ArrayList<>();
bondList.add(bondi);
bondList.add(bondj);
IAtomContainerSet moleculeSet = reactant.getBuilder().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(reactant);
IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
if (reaction == null)
continue;
else
setOfReactions.addReaction(reaction);
}
}
}
}
}
}
}
}
return setOfReactions;
}
Aggregations