コード例 #1
0
 private void processIdentBlock(int lineCount, IAtomContainer container) throws IOException {
   String identifier = "";
   for (int i = 0; i < lineCount; i++) {
     identifier = identifier + input.readLine().trim();
   }
   container.setID(identifier);
 }
コード例 #2
0
  private synchronized void UpdateMapping() throws Exception {
    boolean[][] FlagMatrix = winner.getFlagMatrix();

    ReactionContainer reactionStructureInformationContainer = mh.getReactionContainer();

    for (int iIndex = 0; iIndex < reactionStructureInformationContainer.getEductCount(); iIndex++) {
      for (int jIndex = 0;
          jIndex < reactionStructureInformationContainer.getProductCount();
          jIndex++) {
        int substrateIndex = iIndex;
        int productIndex = jIndex;
        IAtomContainer ac1 = reactionStructureInformationContainer.getEduct(substrateIndex);
        IAtomContainer ac2 = reactionStructureInformationContainer.getProduct(productIndex);

        if (FlagMatrix[substrateIndex][productIndex]) {

          // updateFlag=true;
          BitSet a_BitSet =
              reactionStructureInformationContainer.getFingerPrintofEduct(
                  substrateIndex); // a_BitSet=EDUCT
          BitSet b_BitSet =
              reactionStructureInformationContainer.getFingerPrintofProduct(
                  productIndex); // b_BitSet=PRODUCT

          /*
           * Choose this function if you want JMCS to run
           */
          ac1.setID(this.eductList.get(substrateIndex));
          ac2.setID(this.productList.get(productIndex));

          IGraphMatching graphMatching =
              new GraphMatching(reactionName, ac1, ac2, _dirSuffix, removeHydrogen);
          boolean mcsMatch =
              graphMatching.mcsMatch(
                  mh, removeHydrogen, substrateIndex, productIndex, a_BitSet, b_BitSet);
          if (DEBUG) {
            out.println(
                "Mol Size E: " + ac1.getAtomCount() + " , Mol Size P: " + ac2.getAtomCount());
          }
          if (mcsMatch) {
            if (DEBUG) {
              out.println(eductList.get(substrateIndex) + " <=> " + productList.get(productIndex));
            }
            delta += graphMatching.removeMatchedAtomsAndUpdateAAM(reaction);
            List<MolMapping> rMap =
                getReactionMolMapping()
                    .getMapping(
                        reactionName,
                        this.eductList.get(substrateIndex),
                        this.productList.get(productIndex));
            for (MolMapping map : rMap) {
              map.setReactionMapping(true);
              IAtomContainer mol = graphMatching.getMatchedPart();
              mol = canonLabeler.getCanonicalMolecule(mol);
              CDKSMILES cdkSmiles = new CDKSMILES(mol, true, false);
              map.setMatchedSMILES(cdkSmiles.getCanonicalSMILES(), ++stepIndex);
            }
          }
          IAtomContainer remainingEduct = graphMatching.getRemainingEduct();
          IAtomContainer remainingProduct = graphMatching.getRemainingProduct();

          reactionStructureInformationContainer.putEduct(substrateIndex, remainingEduct);
          reactionStructureInformationContainer.putProduct(productIndex, remainingProduct);
          reactionStructureInformationContainer.setEductModified(substrateIndex, true);
          reactionStructureInformationContainer.setProductModified(productIndex, true);
        }
      }
    }
  }
コード例 #3
0
  /**
   * Procedure required by the CDOInterface. This function is only supposed to be called by the JCFL
   * library
   */
  public void setObjectProperty(String objectType, String propertyType, String propertyValue) {
    logger.debug("objectType: " + objectType);
    logger.debug("propType: " + propertyType);
    logger.debug("property: " + propertyValue);

    if (objectType == null) {
      logger.error("Cannot add property for null object");
      return;
    }
    if (propertyType == null) {
      logger.error("Cannot add property for null property type");
      return;
    }
    if (propertyValue == null) {
      logger.warn("Will not add null property");
      return;
    }

    if (objectType.equals("Molecule")) {
      if (propertyType.equals("id")) {
        currentMolecule.setID(propertyValue);
      } else if (propertyType.equals("inchi")) {
        currentMolecule.setProperty("iupac.nist.chemical.identifier", propertyValue);
      }
    } else if (objectType.equals("PseudoAtom")) {
      if (propertyType.equals("label")) {
        if (!(currentAtom instanceof IPseudoAtom)) {
          currentAtom = builder.newPseudoAtom(currentAtom);
        }
        ((IPseudoAtom) currentAtom).setLabel(propertyValue);
      }
    } else if (objectType.equals("Atom")) {
      if (propertyType.equals("type")) {
        if (propertyValue.equals("R") && !(currentAtom instanceof IPseudoAtom)) {
          currentAtom = builder.newPseudoAtom(currentAtom);
        }
        currentAtom.setSymbol(propertyValue);
      } else if (propertyType.equals("x2")) {
        Point2d coord = currentAtom.getPoint2d();
        if (coord == null) coord = new Point2d();
        coord.x = Double.parseDouble(propertyValue);
        currentAtom.setPoint2d(coord);
      } else if (propertyType.equals("y2")) {
        Point2d coord = currentAtom.getPoint2d();
        if (coord == null) coord = new Point2d();
        coord.y = Double.parseDouble(propertyValue);
        currentAtom.setPoint2d(coord);
      } else if (propertyType.equals("x3")) {
        Point3d coord = currentAtom.getPoint3d();
        if (coord == null) coord = new Point3d();
        coord.x = Double.parseDouble(propertyValue);
        currentAtom.setPoint3d(coord);
      } else if (propertyType.equals("y3")) {
        Point3d coord = currentAtom.getPoint3d();
        if (coord == null) coord = new Point3d();
        coord.y = Double.parseDouble(propertyValue);
        currentAtom.setPoint3d(coord);
      } else if (propertyType.equals("z3")) {
        Point3d coord = currentAtom.getPoint3d();
        if (coord == null) coord = new Point3d();
        coord.z = Double.parseDouble(propertyValue);
        currentAtom.setPoint3d(coord);
      } else if (propertyType.equals("xFract")) {
        Point3d coord = currentAtom.getFractionalPoint3d();
        if (coord == null) coord = new Point3d();
        coord.x = Double.parseDouble(propertyValue);
        currentAtom.setFractionalPoint3d(coord);
      } else if (propertyType.equals("yFract")) {
        Point3d coord = currentAtom.getFractionalPoint3d();
        if (coord == null) coord = new Point3d();
        coord.y = Double.parseDouble(propertyValue);
        currentAtom.setFractionalPoint3d(coord);
      } else if (propertyType.equals("zFract")) {
        Point3d coord = currentAtom.getFractionalPoint3d();
        if (coord == null) coord = new Point3d();
        coord.z = Double.parseDouble(propertyValue);
        currentAtom.setFractionalPoint3d(coord);
      } else if (propertyType.equals("formalCharge")) {
        currentAtom.setFormalCharge(Integer.parseInt(propertyValue));
      } else if (propertyType.equals("charge") || propertyType.equals("partialCharge")) {
        currentAtom.setCharge(Double.parseDouble(propertyValue));
      } else if (propertyType.equals("hydrogenCount")) {
        currentAtom.setHydrogenCount(Integer.parseInt(propertyValue));
      } else if (propertyType.equals("dictRef")) {
        currentAtom.setProperty("org.openscience.cdk.dict", propertyValue);
      } else if (propertyType.equals("atomicNumber")) {
        currentAtom.setAtomicNumber(Integer.parseInt(propertyValue));
      } else if (propertyType.equals("massNumber")) {
        currentAtom.setMassNumber((int) Double.parseDouble(propertyValue));
      } else if (propertyType.equals("id")) {
        logger.debug("id: ", propertyValue);
        currentAtom.setID(propertyValue);
        atomEnumeration.put(propertyValue, numberOfAtoms);
      }
    } else if (objectType.equals("Bond")) {
      if (propertyType.equals("atom1")) {
        bond_a1 = Integer.parseInt(propertyValue);
      } else if (propertyType.equals("atom2")) {
        bond_a2 = Integer.parseInt(propertyValue);
      } else if (propertyType.equals("id")) {
        logger.debug("id: " + propertyValue);
        bond_id = propertyValue;
      } else if (propertyType.equals("order")) {
        try {
          Double order = Double.parseDouble(propertyValue);
          if (order == 1.0) {
            bond_order = IBond.Order.SINGLE;
          } else if (order == 2.0) {
            bond_order = IBond.Order.DOUBLE;
          } else if (order == 3.0) {
            bond_order = IBond.Order.TRIPLE;
          } else if (order == 4.0) {
            bond_order = IBond.Order.QUADRUPLE;
          } else {
            bond_order = IBond.Order.SINGLE;
          }
        } catch (Exception e) {
          logger.error("Cannot convert to double: " + propertyValue);
          bond_order = IBond.Order.SINGLE;
        }
      } else if (propertyType.equals("stereo")) {
        if (propertyValue.equals("H")) {
          bond_stereo = CDKConstants.STEREO_BOND_DOWN;
        } else if (propertyValue.equals("W")) {
          bond_stereo = CDKConstants.STEREO_BOND_UP;
        }
      }
    }
    logger.debug("Object property set...");
  }