Logo Search packages:      
Sourcecode: cdk version File versions  Download package

static AminoAcid [] org::openscience::cdk::templates::AminoAcids::createAAs (  ) [inline, static]

Creates amino acid AminoAcid objects.

Returns:
aminoAcids, a HashMap containing the amino acids as AminoAcids.

Definition at line 108 of file AminoAcids.java.

References org::openscience::cdk::AtomContainer::addAtom(), org::openscience::cdk::AtomContainer::addBond(), org::openscience::cdk::AminoAcid::addCTerminus(), org::openscience::cdk::AminoAcid::addNTerminus(), org::openscience::cdk::interfaces::IAtomContainer::atoms(), org::openscience::cdk::interfaces::IAtomContainer::bonds(), org::openscience::cdk::tools::LoggingTool::debug(), org::openscience::cdk::tools::LoggingTool::error(), org::openscience::cdk::tools::manipulator::ChemFileManipulator::getAllAtomContainers(), org::openscience::cdk::AtomContainer::getAtomCount(), org::openscience::cdk::AtomContainer::getBondCount(), org::openscience::cdk::interfaces::IChemObject::getProperties(), org::openscience::cdk::interfaces::IChemObject::getProperty(), org::openscience::cdk::io::CMLReader::read(), org::openscience::cdk::tools::manipulator::AminoAcidManipulator::removeAcidicOxygen(), org::openscience::cdk::Monomer::setMonomerName(), and org::openscience::cdk::ChemObject::setProperty().

Referenced by aaBondInfo(), org::openscience::cdk::qsar::descriptors::molecular::AminoAcidCountDescriptor::AminoAcidCountDescriptor(), convertOneLetterCodeToThreeLetterCode(), convertThreeLetterCodeToOneLetterCode(), getHashMapBySingleCharCode(), and getHashMapByThreeLetterCode().

                                          {
      if (aminoAcids != null) {
            return aminoAcids;
        }
      
        // Create set of AtomContainers
        aminoAcids = new AminoAcid[20];

        IChemFile list = new ChemFile();
        CMLReader reader = new CMLReader(
            AminoAcids.class.getClassLoader().getResourceAsStream(
                        "org/openscience/cdk/templates/data/list_aminoacids.cml"
            )
        );
        try {
            list = (IChemFile)reader.read(list);
            List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(list);
            Iterator<IAtomContainer> iterator = containersList.iterator();
            int counter = 0;
            while(iterator.hasNext())
            {
                  IAtomContainer ac = (IAtomContainer)iterator.next();
                  logger.debug("Adding AA: ", ac);
                  // convert into an AminoAcid
                  AminoAcid aminoAcid = new AminoAcid();
                  Iterator<IAtom> atoms = ac.atoms().iterator();
                  Iterator<Object> props = ac.getProperties().keySet().iterator();
                  while (props.hasNext()) {
                        Object next = props.next();
                        logger.debug("Prop class: " + next.getClass().getName());
                        logger.debug("Prop: " + next.toString());
                        if (next instanceof DictRef) {
                              DictRef dictRef = (DictRef)next;
                              // logger.debug("DictRef type: " + dictRef.getType());
                              if (dictRef.getType().equals("pdb:residueName")) {
                                    aminoAcid.setProperty(RESIDUE_NAME, ac.getProperty(dictRef).toString().toUpperCase());
                                    aminoAcid.setMonomerName(ac.getProperty(dictRef).toString());
                              } else if (dictRef.getType().equals("pdb:oneLetterCode")) {
                                    aminoAcid.setProperty(RESIDUE_NAME_SHORT, ac.getProperty(dictRef));
                              } else if (dictRef.getType().equals("pdb:id")) {
                                    aminoAcid.setProperty(ID, ac.getProperty(dictRef));
                                    logger.debug("Set AA ID to: ", ac.getProperty(dictRef));
                              } else {
                                    logger.error("Cannot deal with dictRef!");
                              }
                        }
                  }
                  while (atoms.hasNext()) {
                        IAtom atom = (IAtom)atoms.next();
                        String dictRef = (String)atom.getProperty("org.openscience.cdk.dict");
                        if (dictRef != null && dictRef.equals("pdb:nTerminus")) {
                              aminoAcid.addNTerminus(atom);
                        } else if (dictRef != null && dictRef.equals("pdb:cTerminus")) {
                              aminoAcid.addCTerminus(atom);
                        } else {
                              aminoAcid.addAtom(atom);
                        }
                  }
                Iterator<IBond> bonds = ac.bonds().iterator();
                while (bonds.hasNext()) {
                    IBond bond = (IBond) bonds.next();
                        aminoAcid.addBond(bond);
                  }
                  AminoAcidManipulator.removeAcidicOxygen(aminoAcid);
                aminoAcid.setProperty(NO_ATOMS, "" + aminoAcid.getAtomCount());
                aminoAcid.setProperty(NO_BONDS, "" + aminoAcid.getBondCount());
                if (counter < aminoAcids.length) {
                  aminoAcids[counter] = aminoAcid;
                } else {
                  logger.error("Could not store AminoAcid! Array too short!");
                }
                counter++;
            }
        } catch (Exception exception) {
            logger.error("Failed reading file: ", exception.getMessage());
            logger.debug(exception);
        }
        
        return aminoAcids;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index