Java Code Examples for org.openscience.cdk.interfaces.IAtomContainer#setProperty()

The following examples show how to use org.openscience.cdk.interfaces.IAtomContainer#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtAtomContainerManipulator.java    From ReactionDecoder with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Copy the input container and suppress any explicit hydrogens. Only
 * hydrogens that can be represented as a hydrogen count value on the atom
 * are suppressed. If a copy is not needed please use {@link
 * #suppressHydrogens}.
 *
 * @param org the container from which to remove hydrogens
 * @return a copy of the input with suppressed hydrogens
 * @see #suppressHydrogens
 */
public static IAtomContainer copyAndSuppressedHydrogens(IAtomContainer org) {
    /*
     * Remove the CTAB_SGROUPS flag as CDK 2.2 complains
     */
    org.setProperty(CDKConstants.CTAB_SGROUPS, null);
    /*
     * @ASAD: IMP STEP to avoid unset Hydrogen arror:
     * Set implicit Hydrogen count
     */
    try {
        IAtomContainer clone = org.clone();
        clone.setID(org.getID());
        for (int i = 0; i < org.getAtomCount(); i++) {
            int implicitHydrogenCount = getImplicitHydrogenCount(clone.getAtom(i));
            clone.getAtom(i).setImplicitHydrogenCount(implicitHydrogenCount);
            clone.getAtom(i).setProperties(org.getAtom(i).getProperties());
            clone.getAtom(i).setFlags(org.getAtom(i).getFlags());
        }
        return suppressHydrogens(clone);
    } catch (CloneNotSupportedException e) {
        throw new IllegalStateException("atom container could not be cloned");
    }
}
 
Example 2
Source File: VentoFoggia.java    From ReactionDecoder with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Mappings matchAll(final IAtomContainer target) {

    final EdgeToBondMap bonds2;
    final int[][] g2;

    AdjListCache cached = target.getProperty(AdjListCache.class.getName());
    if (cached == null || !cached.validate(target)) {
        cached = new AdjListCache(target);
        target.setProperty(AdjListCache.class.getName(), cached);
    }

    bonds2 = cached.bmap;
    g2 = cached.g;

    Iterable<int[]> iterable = new VFIterable(query, target,
            g1, g2,
            bonds1, bonds2,
            atomMatcher, bondMatcher,
            subgraph);
    return new Mappings(query, target, iterable);
}
 
Example 3
Source File: CDKReactionBuilder.java    From ReactionDecoder with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void setReactantMolecule(IReaction IR, Collection<IAtomContainer> metabolites) {
//
//        System.out.println("-------------------");
//        System.out.println("Reactants");
//        System.out.println("-------------------");

        Iterator<IAtomContainer> it = metabolites.iterator();
        //System.out.println("Stoic Map Size: " + stoichiometryMap.size());

        while (it.hasNext()) {
            IAtomContainer mol = it.next();
//            System.out.println("Insertion: " + mol.getID() + ", " + stoichiometryMap.get(mol.getID()));
            mol.setProperty("STOICHIOMETRY", stoichiometryMap.get(mol.getID()));
            IR.addReactant(mol, stoichiometryMap.get(mol.getID()));
            //IR.setReactantCoefficient(mol,wt);
//            System.out.println("Reaction: " + mol.getID() + ", " + standardizedReaction.getProductCoefficient(mol));
        }

        metabolites.clear();
        stoichiometryMap.clear();
    }
 
Example 4
Source File: CDKReactionBuilder.java    From ReactionDecoder with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void setProductMolecule(IReaction IR, Collection<IAtomContainer> metabolites) {

//        System.out.println("-------------------");
//        System.out.println("Products");
//        System.out.println("-------------------");
        Iterator<IAtomContainer> it = metabolites.iterator();
        while (it.hasNext()) {
            IAtomContainer mol = it.next();
//
//            System.out.println("Insertion: " + mol.getID() + ", " + stoichiometryMap.get(mol.getID()));
            mol.setProperty("STOICHIOMETRY", stoichiometryMap.get(mol.getID()));
            IR.addProduct(mol, stoichiometryMap.get(mol.getID()));
//         standardizedReaction.setProductCoefficient(mol,stoichiometryMap.get(mol.getID()));
        }

        metabolites.clear();
        stoichiometryMap.clear();
    }
 
Example 5
Source File: MDLV2000Writer.java    From ReactionDecoder with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void writeChemFile(IChemFile file) throws Exception {
    IAtomContainer bigPile = file.getBuilder().newInstance(IAtomContainer.class);
    for (IAtomContainer container : ChemFileManipulator.getAllAtomContainers(file)) {
        bigPile.add(container);
        if (container.getTitle() != null) {
            if (bigPile.getTitle() != null) {
                bigPile.setTitle(bigPile.getTitle() + "; " + container.getTitle());
            } else {
                bigPile.setTitle(container.getTitle());
            }
        }
        if (container.getProperty(CDKConstants.REMARK) != null) {
            if (bigPile.getProperty(CDKConstants.REMARK) != null) {
                bigPile.setProperty(CDKConstants.REMARK, bigPile.getProperty(CDKConstants.REMARK) + "; "
                        + container.getProperty(CDKConstants.REMARK));
            } else {
                bigPile.setProperty(CDKConstants.REMARK, container.getProperty(CDKConstants.REMARK));
            }
        }
    }
    writeMolecule(bigPile);
}
 
Example 6
Source File: AbstractDirectLayout.java    From ReactionDecoder with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 * @param ac
 */
public void invert(IAtomContainer ac) {
    if (shouldInvert && 
            ac.getProperty(INVERTED) == null ||
            !((Boolean)ac.getProperty(INVERTED))) {
        for (IAtom atom : ac.atoms()) {
            atom.getPoint2d().y *= - 1;
        }
        ac.setProperty(INVERTED, TRUE);
    }
    shouldInvert = false;
}
 
Example 7
Source File: MDLV2000Reader.java    From ReactionDecoder with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Read non-structural data from input and store as properties the provided
 * 'container'. Non-structural data appears in a structure data file (SDF)
 * after an Molfile and before the record deliminator ('$$$$'). The data
 * consists of one or more Data Header and Data blocks, an example is seen
 * below.
 *
 * <pre>{@code
 * > 29 <DENSITY>
 * 0.9132 - 20.0
 *
 * > 29 <BOILING.POINT>
 * 63.0 (737 MM)
 * 79.0 (42 MM)
 *
 * > 29 <ALTERNATE.NAMES>
 * SYLVAN
 *
 * > 29 <DATE>
 * 09-23-1980
 *
 * > 29 <CRC.NUMBER>
 * F-0213
 *
 * }</pre>
 *
 *
 * @param input input source
 * @param container the container
 * @throws IOException an error occur whilst reading the input
 */
static void readNonStructuralData(final BufferedReader input, final IAtomContainer container) throws IOException {

    String line, header = null;
    boolean wrap = false;

    final StringBuilder data = new StringBuilder(80);

    while (!endOfRecord(line = input.readLine())) {

        final String newHeader = dataHeader(line);

        if (newHeader != null) {

            if (header != null) {
                container.setProperty(header, data.toString());
            }

            header = newHeader;
            wrap = false;
            data.setLength(0);

        } else {

            if (data.length() > 0 || !line.equals(" ")) {
                line = line.trim();
            }

            if (line.isEmpty()) {
                continue;
            }

            if (!wrap && data.length() > 0) {
                data.append(NEW_LINE);
            }
            data.append(line);

            wrap = line.length() == 80;
        }
    }

    if (header != null) {
        container.setProperty(header, data.toString());
    }
}