本文整理汇总了Java中org.openscience.cdk.interfaces.IAtomContainer类的典型用法代码示例。如果您正苦于以下问题:Java IAtomContainer类的具体用法?Java IAtomContainer怎么用?Java IAtomContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAtomContainer类属于org.openscience.cdk.interfaces包,在下文中一共展示了IAtomContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStructureAsAromaticIAtomContainer
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public IAtomContainer getStructureAsAromaticIAtomContainer() {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IAtomContainer fragmentStructure = builder.newInstance(IAtomContainer.class);
for(int i = 0; i < this.bondsBitArray.getSize(); i++) {
if(this.bondsBitArray.get(i)) {
IBond curBond = this.precursorMolecule.getStructureAsIAtomContainer().getBond(i);
if(this.precursorMolecule.isAromaticBond(i)) curBond.setIsAromatic(true);
for(IAtom atom : curBond.atoms()) {
atom.setImplicitHydrogenCount(0);
if(this.precursorMolecule.isAromaticBond(i)) atom.setIsAromatic(true);
fragmentStructure.addAtom(atom);
}
fragmentStructure.addBond(curBond);
}
}
// loss of hydrogens
// MoleculeFunctions.prepareAtomContainer(fragmentStructure);
return fragmentStructure;
}
示例2: getStructureAsIAtomContainer
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public IAtomContainer getStructureAsIAtomContainer() {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IAtomContainer fragmentStructure = builder.newInstance(IAtomContainer.class);
for(int i = 0; i < this.bondsBitArray.getSize(); i++) {
if(this.bondsBitArray.get(i)) {
IBond curBond = this.precursorMolecule.getStructureAsIAtomContainer().getBond(i);
for(IAtom atom : curBond.atoms()) {
fragmentStructure.addAtom(atom);
}
fragmentStructure.addBond(curBond);
}
}
// loss of hydrogens
// MoleculeFunctions.prepareAtomContainer(fragmentStructure);
return fragmentStructure;
}
示例3: getImplicitHydrogenAtomContainer
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public IAtomContainer getImplicitHydrogenAtomContainer() throws Exception {
int trials = 1;
IAtomContainer molecule = null;
while(trials <= 10) {
try {
molecule = MoleculeFunctions.getAtomContainerFromInChI((String)this.properties.get(VariableNames.INCHI_NAME));
}
catch(Exception e) {
trials++;
continue;
}
break;
}
if(molecule == null) throw new Exception("Could not read InChI!");
MoleculeFunctions.prepareAtomContainer(molecule, true);
MoleculeFunctions.convertExplicitToImplicitHydrogens(molecule);
return molecule;
}
示例4: initialiseCandidatesFromMemory
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
private void initialiseCandidatesFromMemory() {
IAtomContainer[] molecules = (IAtomContainer[])this.settings.get(VariableNames.MOLECULES_IN_MEMORY);
this.candidates = new Vector<TopDownPrecursorCandidate>();
if(molecules == null) return;
for(int i = 0; i < molecules.length; i++) {
MoleculeFunctions.prepareAtomContainer(molecules[i], true);
String[] inchiInfo = MoleculeFunctions.getInChIInfoFromAtomContainer(molecules[i]);
TopDownPrecursorCandidate precursorCandidate = new TopDownPrecursorCandidate(inchiInfo[0], (i + 1) + "");
java.util.Iterator<Object> properties = molecules[i].getProperties().keySet().iterator();
while(properties.hasNext()) {
String key = (String)properties.next();
if(molecules[i].getProperties().containsKey(key) && molecules[i].getProperty(key) != null) precursorCandidate.setProperty(key, molecules[i].getProperty(key));
}
precursorCandidate.setProperty(VariableNames.INCHI_KEY_NAME, inchiInfo[1]);
precursorCandidate.setProperty(VariableNames.INCHI_KEY_1_NAME, inchiInfo[1].split("-")[0]);
precursorCandidate.setProperty(VariableNames.INCHI_KEY_2_NAME, inchiInfo[1].split("-")[1]);
precursorCandidate.setProperty(VariableNames.MOLECULAR_FORMULA_NAME, inchiInfo[0].split("/")[1]);
this.candidates.add(precursorCandidate);
}
return;
}
示例5: getCandidateByIdentifier
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
* Get IAtomContainer by one single compound id
*
* @throws Exception
*
*/
public IAtomContainer getCandidateByIdentifier(String identifier) throws Exception {
//fetch the hits from PubChem
Vector<String> ids = this.savingRetrievedHits(new String[] {identifier});
if(ids == null || ids.size() == 0) return null;
if(this.cidToInChIs.get(identifier) == null)
return null;
IAtomContainer container = this.getAtomContainerFromInChI(this.cidToInChIs.get(identifier));
//if you like to use SMILES uncomment here
//IAtomContainer container = this.getAtomContainerFromSMILES(this.cidToSmiles.get(identifier));
this.prepareAtomContainer(container);
return container;
}
示例6: getAtomContainerFromInChI
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
*
* @param inchi
* @return
* @throws Exception
*/
protected IAtomContainer getAtomContainerFromInChI(String inchi) throws Exception {
if(this.inchiFactory == null) {
System.err.println("InChI-Factory not initialised");
throw new Exception();
}
InChIToStructure its = this.inchiFactory.getInChIToStructure(inchi, DefaultChemObjectBuilder.getInstance());
if(its == null) {
throw new Exception("InChI problem: " + inchi);
}
INCHI_RET ret = its.getReturnStatus();
if (ret == INCHI_RET.WARNING) {
} else if (ret != INCHI_RET.OKAY) {
throw new Exception("InChI problem: " + inchi);
}
return its.getAtomContainer();
}
示例7: prepareAtomContainer
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
*
* @param container
* @throws CDKException
*/
protected void prepareAtomContainer(IAtomContainer container) throws CDKException {
while(true) {
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(container);
Aromaticity arom = new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet());
arom.apply(container);
} catch (java.lang.NullPointerException e) {
//bad workaround for cdk bug?! but what shall I do...
//sometimes NullPointerException occurs but not in one of the further trials?!
continue;
}
break;
}
CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(container.getBuilder());
for(int i = 0; i < container.getAtomCount(); i++) {
hAdder.addImplicitHydrogens(container, container.getAtom(i));
}
AtomContainerManipulator.convertImplicitToExplicitHydrogens(container);
hAdder = null;
}
示例8: getAromaticAtoms
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
*
* @param molecule
* @return
*/
public static BitArray getAromaticAtoms(IAtomContainer molecule) {
Aromaticity arom = new Aromaticity(ElectronDonation.cdk(),
Cycles.cdkAromaticSet());
BitArray aromaticAtoms = new BitArray(molecule.getAtomCount());
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
arom.apply(molecule);
Set<IBond> aromaticBonds = arom.findBonds(molecule);
Iterator<IBond> it = aromaticBonds.iterator();
while(it.hasNext()) {
IBond bond = it.next();
for(int k = 0; k < bond.getAtomCount(); k++)
aromaticAtoms.set(molecule.getAtomNumber(bond.getAtom(k)));
}
} catch (CDKException e) {
e.printStackTrace();
}
return aromaticAtoms;
}
示例9: determineCarbonAtomStatistics
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public static void determineCarbonAtomStatistics(IAtomContainer mol, ICandidate candidate, java.util.Vector<Integer> aromaticAtomIndexes) {
int numberC = 0;
int numberAliphaticCH = 0;
int numberAromaticCH = 0;
for(int i = 0; i < mol.getAtomCount(); i++) {
IAtom atom = mol.getAtom(i);
if(atom.getSymbol().equals("C")) {
numberC++;
int hydrogens = atom.getImplicitHydrogenCount();
if(aromaticAtomIndexes.contains(i)) numberAromaticCH += hydrogens;
else numberAliphaticCH += hydrogens;
}
}
candidate.setProperty("#C", numberC);
candidate.setProperty("#aliphaticCH", numberAliphaticCH);
candidate.setProperty("#aromaticCH", numberAromaticCH);
}
示例10: calculateInchiKey
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
*
* @param con
* @return
* @throws CDKException
*/
public static String calculateInchiKey(IAtomContainer con) throws CDKException {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(con);
CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(con.getBuilder());
for(int i = 0; i < con.getAtomCount(); i++) {
try {
hAdder.addImplicitHydrogens(con, con.getAtom(i));
}
catch(CDKException e) {
continue;
}
}
AtomContainerManipulator.convertImplicitToExplicitHydrogens(con);
InChIGeneratorFactory factory = InChIGeneratorFactory.getInstance();
InChIGenerator gen = factory.getInChIGenerator(con);
return gen.getInchiKey().split("-")[0];
}
示例11: searchForDeuteriumExchangeablePositions
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
*
* @param elementsToExchange
* @param its
* @return
*/
public static int[] searchForDeuteriumExchangeablePositions(
String[] elementsToExchange, IAtomContainer its) {
Vector<Integer> positionsToExchange = new Vector<Integer>();
for (int i = 0; i < its.getAtomCount(); i++) {
String symbol = its.getAtom(i).getSymbol();
if (symbol.equals("H"))
continue;
for (int k = 0; k < elementsToExchange.length; k++) {
if (symbol.equals(elementsToExchange[k])) {
int numHs = getNumberExplicitHydrogens(its, i);
for(int l = 0; l < numHs; l++) {
positionsToExchange.add(i);
}
break;
}
}
}
int[] array = new int[positionsToExchange.size()];
for(int i = 0; i < positionsToExchange.size(); i++) {
array[i] = positionsToExchange.get(i);
}
return array;
}
示例12: main
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public static void main(String[] args) throws InvalidSmilesException, IOException {
IAtomContainer m = null;
try {
m = MoleculeFunctions.getAtomContainerFromInChI("InChI=1S/C10H22N2/c1-9(2)7-10(8-12-11)5-3-4-6-10/h9,12H,3-8,11H2,1-2H3");
MoleculeFunctions.prepareAtomContainer(m, false);
} catch (Exception e) {
e.printStackTrace();
}
StandardSingleStructureImageGenerator s = new StandardSingleStructureImageGenerator();
s.setImageHeight(500);
s.setImageWidth(500);
s.setStrokeRation(2);
RenderedImage img = s.generateImage(m, "1");
ImageIO.write((RenderedImage) img, "PNG", new java.io.File("/tmp/file.png"));
}
示例13: getAtomContainerFromSMILES
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public static IAtomContainer getAtomContainerFromSMILES(String smiles) throws Exception {
IAtomContainer molecule = sp.parseSmiles(smiles);
for(int i = 0; i < molecule.getAtomCount(); i++) {
if(molecule.getAtom(i).getSymbol().equals("H")) continue;
else {
java.util.List<IAtom> atoms = molecule.getConnectedAtomsList(molecule.getAtom(i));
short numDs = 0;
for(IAtom atom : atoms)
if(atom.getSymbol().equals("H") && (atom.getMassNumber() != null && atom.getMassNumber() == 2))
numDs++;
molecule.getAtom(i).setProperty(VariableNames.DEUTERIUM_COUNT_NAME, numDs);
}
}
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
Aromaticity arom = new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet());
arom.apply(molecule);
} catch (CDKException e) {
e.printStackTrace();
}
return molecule;
}
示例14: getAtomContainerFromInChI
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
*
* @param inchi
* @return
* @throws Exception
*/
public static IAtomContainer getAtomContainerFromInChI(String inchi) throws Exception {
de.ipbhalle.metfraglib.inchi.InChIToStructure its = inchiFactory.getInChIToStructure(inchi, DefaultChemObjectBuilder.getInstance());
if(its == null) {
throw new Exception("InChI problem: " + inchi);
}
INCHI_RET ret = its.getReturnStatus();
if (ret == INCHI_RET.WARNING) {
// logger.warn("InChI warning: " + its.getMessage());
} else if (ret != INCHI_RET.OKAY) {
throw new Exception("InChI problem: " + inchi);
}
IAtomContainer molecule = its.getAtomContainer();
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
Aromaticity arom = new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet());
arom.apply(molecule);
} catch (CDKException e) {
e.printStackTrace();
}
return molecule;
}
示例15: removeHydrogens
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
public static void removeHydrogens(IAtomContainer molecule) {
java.util.Vector<IAtom> hydrogenAtoms = new java.util.Vector<IAtom>();
java.util.Iterator<IAtom> atoms = molecule.atoms().iterator();
while(atoms.hasNext()) {
IAtom currentAtom = atoms.next();
if(currentAtom.getSymbol().equals("H")) hydrogenAtoms.add(currentAtom);
java.util.List<IAtom> neighbours = molecule.getConnectedAtomsList(currentAtom);
int numberHydrogens = 0;
for(int k = 0; k < neighbours.size(); k++) {
if(neighbours.get(k).getSymbol().equals("H")) numberHydrogens++;
}
currentAtom.setImplicitHydrogenCount(numberHydrogens);
}
for(IAtom atom : hydrogenAtoms) {
molecule.removeAtomAndConnectedElectronContainers(atom);
}
}