本文整理汇总了Java中org.openscience.cdk.interfaces.IAtomContainer类的典型用法代码示例。如果您正苦于以下问题:Java IAtomContainer类的具体用法?Java IAtomContainer怎么用?Java IAtomContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAtomContainer类属于org.openscience.cdk.interfaces包,在下文中一共展示了IAtomContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:22,代码来源:DefaultBitArrayFragment.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:19,代码来源:DefaultBitArrayFragment.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:19,代码来源:PrecursorCandidate.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:25,代码来源:LocalInMemoryDatabase.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:22,代码来源:OnlinePubChemDatabaseMicha.java
示例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();
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:23,代码来源:OnlinePubChemDatabaseMicha.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:26,代码来源:OnlinePubChemDatabaseMicha.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:25,代码来源:InChIDeuteriumGeneration.java
示例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);
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:19,代码来源:CalculateAtomStatistics.java
示例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];
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:23,代码来源:GetRankOfCandidateCSV.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:31,代码来源:SDFDeuteriumGeneration.java
示例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"));
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:17,代码来源:StandardSingleStructureImageGenerator.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:23,代码来源:MoleculeFunctions.java
示例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;
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:28,代码来源:MoleculeFunctions.java
示例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);
}
}
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:18,代码来源:MoleculeFunctions.java
示例16: computeDistanceMatrix
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
* computes the distance matrix of all atoms corrected by stretching factor
* and mathematically rounded
*
* @param ac
* @return
*/
public int[][] computeDistanceMatrix(IAtomContainer ac) {
final int dimension = ac.getAtomCount();
final int[][] distanceMatrix = new int[dimension][dimension];
for (int i = 0; i < dimension; i++) {
for (int j = i; j < dimension; j++) {
final Point3d start = ac.getAtom(i).getPoint3d();
final Point3d end = ac.getAtom(j).getPoint3d();
double distance;
if(start == null || end == null){
final Point2d start2d = ac.getAtom(i).getPoint2d();
final Point2d end2d = ac.getAtom(j).getPoint2d();
distance = Math.round(start2d.distance(end2d) * this.getStretchingFactor());
}else{
distance = Math.round(start.distance(end) * this.getStretchingFactor());
}
distanceMatrix[i][j] = (int) distance;
distanceMatrix[j][i] = (int) distance;
}
}
return distanceMatrix;
}
开发者ID:fortiema,项目名称:jCompoundMapper,代码行数:30,代码来源:Encoding3D.java
示例17: getFingerprint
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
@Override
public ArrayList<IFeature> getFingerprint(IAtomContainer ac) {
final ArrayList<IFeature> result = new ArrayList<IFeature>();
for (int i = 0; i < ac.getAtomCount(); i++) {
final List<List<IAtom>> lae = PathTools.getPathsOfLengthUpto(ac, ac.getAtom(i), super.getSearchDepth());
HashMap<Integer, List<List<IAtom>>> laeMap = getFeaturesBySearchDepth(lae);
Set<Integer> keySet = laeMap.keySet();
for (Integer key : keySet) {
List<String> localFragment = new ArrayList<String>();
try {
localFragment = this.getPaths(laeMap.get(key), ac);
} catch (MoltyperException e) {
e.printStackTrace();
}
final String shellD = localFragment.toString().replaceAll(" ", "");
final NumericStringFeature feature = new NumericStringFeature(shellD, 1.0);
result.add(feature);
}
}
return result;
}
开发者ID:fortiema,项目名称:jCompoundMapper,代码行数:23,代码来源:Encoding2DLocalAtomEnvironment.java
示例18: getPaths
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
/**
* returns a sorted lists of paths describing the environment
*
* @param localAtomEnvironment
* @return
* @throws MoltyperException
*/
private ArrayList<String> getPaths(List<List<IAtom>> localAtomEnvironment, IAtomContainer ac)
throws MoltyperException {
final ArrayList<String> result = new ArrayList<String>();
for (int i = 0; i < localAtomEnvironment.size(); i++) {
final List<IAtom> iThPath = localAtomEnvironment.get(i);
final StringBuffer sb = new StringBuffer();
for (int j = 0; j < iThPath.size(); j++) {
sb.append(super.getAtomLabel(iThPath.get(j)));
if (this.useBonds) {
if ((j < iThPath.size() - 1) && (iThPath.size() > 1)) {
final int bondindex = ac.getBondNumber(iThPath.get(j), iThPath.get(j + 1));
sb.append(super.getBondLabel(ac.getBond(bondindex)));
}
}
}
result.add(sb.toString());
}
Collections.sort(result);
return result;
}
开发者ID:fortiema,项目名称:jCompoundMapper,代码行数:28,代码来源:Encoding2DLocalAtomEnvironment.java
示例19: calculateFingerprint
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
private void calculateFingerprint(IAtomContainer ac) throws FingerPrinterException, MoltyperException,CDKException{
this.iteration=0;
this.completeFeatures=new ArrayList<IFeature>();
this.molecule=ac;
this.featuresOfLastIteration = new HashMap<IAtom,ECFPFeature>();
computeInitialIdentifiers();
for(int i=0;i<this.getSearchDepth();i++){
iteration++;
computeIteration();
}
// wegner: this is still ugly, I would prefer the molecule is persistent within this object, which it is only
// for the lifetime of a calculateFingerprint function call, very strange design, and not in a good way.
// Anyway, workaround is to pass a molecule object along to the ECFPFeature as workaround.
this.featuresOfLastIteration=null;
this.molecule=null;
}
开发者ID:fortiema,项目名称:jCompoundMapper,代码行数:20,代码来源:Encoding2DECFP.java
示例20: computeIterationForAtom
import org.openscience.cdk.interfaces.IAtomContainer; //导入依赖的package包/类
private ECFPFeature computeIterationForAtom(IAtom atom) throws FingerPrinterException, MoltyperException{
ECFPFeature oldFeature = featuresOfLastIteration.get(atom);
IAtomContainer newSubstructure = oldFeature.getNonDeepCloneOfSubstructure();
List<BondOrderIdentifierTupel> connectivity = new ArrayList<BondOrderIdentifierTupel>();
for(IAtom connectedAtom: molecule.getConnectedAtomsList(atom)){
int identifierOfConnectedAtom = featuresOfLastIteration.get(connectedAtom).hashCode();
//System.out.println("iterate "+connectedAtom.getAtomTypeName()+",id="+identifierOfConnectedAtom+",id="+featuresOfLastIteration.get(connectedAtom).featureToString(true));
connectivity.add(new BondOrderIdentifierTupel(this.getBondOrder(molecule.getBond(atom,connectedAtom)),identifierOfConnectedAtom));
IAtomContainer structure = this.featuresOfLastIteration.get(connectedAtom).representedSubstructure();
for(IAtom a: structure.atoms()){
if(!newSubstructure.contains(a))
newSubstructure.addAtom(a);
}
for(IBond b: structure.bonds()){
if(!newSubstructure.contains(b))
newSubstructure.addBond(b);
}
}
ECFPFeature newFeature = new ECFPFeature(this, molecule, atom, newSubstructure, this.iteration,oldFeature.hashCode(), connectivity);
return newFeature;
}
开发者ID:fortiema,项目名称:jCompoundMapper,代码行数:24,代码来源:Encoding2DECFP.java
注:本文中的org.openscience.cdk.interfaces.IAtomContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论