Examples of IMolecule


Examples of org.openscience.cdk.interfaces.IMolecule

    if("fingerprintint".equals(request.getParameter("output"))) serviceType = "fingerprintint";
    if("fingerprinthex".equals(request.getParameter("output"))) serviceType = "fingerprinthex";
    if("fingerprintbin".equals(request.getParameter("output"))) serviceType = "fingerprintbin";
    //if("SciXML".equals(request.getParameter("output"))) serviceType = "scixml";
   
    IMolecule mol = null;
    boolean makeStructure = true;
    if(request.getParameter("inchi") != null && (request.getParameter("inchi").length() > 0)) {
      makeStructure = false;
      if(mol == null) {
        StereoInChIToMolecule.primeCacheForInChI(request.getParameter("inchi"));
        mol = ConverterToInChI.getMolFromInChI(request.getParameter("inchi"));
        if(mol != null) {
          try {           
            StructureConverter.configureMolecule(mol);         
          } catch (Exception e) {
            mol = null
          }
          makeStructure = !MultiFragmentStructureDiagramGenerator.hasStructure(mol);
          if(mol.getAtomCount() == 1) makeStructure = true;         
        }
      }
    }
   
    if(mol == null && request.getParameter("smiles") != null && request.getParameter("smiles").length() > 0) {
      try {
        mol = new SmilesParser(DefaultChemObjectBuilder.getInstance()).parseSmiles(request.getParameter("smiles"));
        if(mol != null) {
          StructureConverter.configureMolecule(mol);         
          makeStructure = !MultiFragmentStructureDiagramGenerator.hasStructure(mol);
          if(mol.getAtomCount() == 1) makeStructure = true;         
        }
      } catch (Exception e) {
        mol = null
      }
    }
   
    if(mol == null && request.getParameter("name") != null && request.getParameter("name").length() > 0) {
      try {
        NameToStructure nts = NameToStructure.getInstance();
        Element cml  = nts.parseToCML(request.getParameter("name"));
        if (cml != null){
          mol = StructureConverter.cmlToMolecule(cml);
          if(mol != null) {
            StructureConverter.configureMolecule(mol);         
            makeStructure = !MultiFragmentStructureDiagramGenerator.hasStructure(mol);
            if(mol.getAtomCount() == 1) makeStructure = true;
           
            for (Iterator<IAtom> iterator = mol.atoms(); iterator.hasNext();) {//remove explicit hydrogen and make hydrogens properties of atoms to make viewing easier
              IAtom a = iterator.next();
              int hydrogen =0;
              List<IAtom> neighbours = mol.getConnectedAtomsList(a);
              for (IAtom neighbour : neighbours) {
                if (neighbour.getAtomicNumber() ==1 ){
                  mol.removeBond(a, neighbour);
                  mol.removeAtom(neighbour);
                  hydrogen++;
                }
              }
              a.setHydrogenCount(hydrogen);
            }
          }
          else{
            response.setContentType("text/plain");
            response.getWriter().println("CML could not be converted to CDK molecule");   
          }
        }
        else{
          response.setContentType("text/plain");
          response.getWriter().println("OPSIN failed to parse this name");   
        }
      } catch (Exception e) {
        mol = null
      }
    }

    if(mol == null && request.getParameter("element") != null && (request.getParameter("element").length() > 0)) {
      String elemSymbol = request.getParameter("element");
      Atom a = new Atom(elemSymbol);
      a.setPoint2d(new Point2d(0.0, 0.0));
      mol = new Molecule();
      mol.addAtom(a);
      makeStructure = false;
    }
   
    if (mol == null){
      response.setContentType("text/plain");
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

    if(lexEntry != null) {
      if(lexEntry.getAttribute("SMILES") != null) {
        state.smiles = lexEntry.getAttributeValue("SMILES");
        setNEAttribute(state.ne, "SMILES", state.smiles);
        try {
          IMolecule mol = smilesParser.parseSmiles(state.smiles);
          state.inchi = ConverterToInChI.getInChI(mol);
          if(state.inchi != null) {
            setNEAttribute(state.ne, "InChI", state.inchi);
            cacheEntry(name, state.smiles, state.inchi, null);
          } else {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

      boolean synonymInDoc = false;
      OpsinResult opsinResult = NameToStructure.getInstance().parseChemicalName(name, false);
      state.cmlMol = opsinResult.getCml();
      if(state.cmlMol != null) {
        state.inchi = NameToInchi.convertResultToInChI(opsinResult, false);
        IMolecule outputMol = StructureConverter.cmlToMolecule(state.cmlMol);
        StructureConverter.enhanceCMLMolecule(state.cmlMol, name, state.inchi);
        state.smiles = generator.createSMILES(outputMol);
        setNEAttribute(state.ne, "SMILES", state.smiles);
        if(state.inchi != null) setNEAttribute(state.ne, "InChI", state.inchi);
        if(!makeCML) {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

          if (state.cmlMol == null && state.inchi != null) {
            if(!state.InChItoCML.containsKey(state.inchi)) {
              //build from inchi
              try {
                StereoInChIToMolecule.primeCacheForInChINoThrow(state.inchi);
                IMolecule mol = ConverterToInChI.getMolFromInChI(state.inchi);
                StructureConverter.configureMolecule(mol);
//                IMolecule mol = parser.parseSmiles(smiles);
                state.cmlMol = StructureConverter.molToCml(mol, name);
                state.cmlPile.appendChild(state.cmlMol);
                state.InChItoCML.put(state.inchi, state.cmlMol);
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

      //System.out.println(type);
      if("application/xml".equals(type)) {
        Document cml = builder.build(conn.getInputStream());
        Element cmlMol = cml.getRootElement();
        StructureConverter.enhanceCMLMolecule(cmlMol, name);
        IMolecule outputMol = StructureConverter.cmlToMolecule(cmlMol);
        String smiles = generator.createSMILES(outputMol);
        String inchi = ConverterToInChI.getInChI(outputMol);
        Results results = new Results(smiles, inchi, cmlMol);
        return results;       
      } else if("text/plain".equals(type) && "Name did not parse!".equals(new BufferedReader(new InputStreamReader(conn.getInputStream())).readLine())) {
        // Failure from SimpleOPSINServlet
        return null;
      } else if("chemical/x-mdl-molfile".equals(type)) {
        MDLReader mdlr = new MDLReader(conn.getInputStream());
        IMolecule outputMol = (IMolecule)mdlr.read(new Molecule());
        StructureConverter.configureMolecule(outputMol);
        String smiles = generator.createSMILES(outputMol);
        String inchi = ConverterToInChI.getInChI(outputMol);
        Results results = new Results(smiles, inchi, null);
        return results; 
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

    /*if(inchi != null) {
      setToSearch();
      Query q = new TermQuery(new Term("InChI", inchi));
      if(indexSearcher.search(q).length() > 0) return;
    }*/
    IMolecule mol;
    try {
      mol = new Molecule();
      mol = ConverterToInChI.getMolFromInChI(inchi);
      StructureConverter.configureMolecule(mol);
      try {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

    List<Integer> bestResults = vc.hitsByScore();
    VectorCollector newVc = new VectorCollector();
    IndexReader ir = indexSearcher.getIndexReader();
    float maxScore = -1;
    for(Integer i : bestResults) {
      IMolecule hitMol = deSerialiseMol(ir.document(i).get("mol"));
      float score = vc.getResultsVector().get(i);
      if(UniversalIsomorphismTester.isIsomorph(hitMol, queryMol)) {
        newVc.collect(i, score);
      }
      if(score < maxScore) break;
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

    List<Integer> bestResults = vc.hitsByScore();
    VectorCollector newVc = new VectorCollector();
    IndexReader ir = indexSearcher.getIndexReader();
    for(Integer i : bestResults) {
      if(maxHits != -1 && newVc.getResultsVector().size() >= maxHits) break;
      IMolecule hitMol = deSerialiseMol(ir.document(i).get("mol"));
      float score = vc.getResultsVector().get(i);
      if(UniversalIsomorphismTester.isSubgraph(hitMol, queryMol)) {
        newVc.collect(i, score);
      }
    }
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

        name = s.split("\\s+REJECT")[0];
      }
      String opsinInchi = null;
      try {
        Element cmlMol = cmlMol = NameToStructure.getInstance().parseToCML(name);
        IMolecule outputMol = StructureConverter.cmlToMolecule(cmlMol);         
        opsinInchi = ConverterToInChI.getInChI(outputMol);
      } catch (Exception e) {
        // Fail silently for now. Maybe we need to do something better.
      }
      total++;
View Full Code Here

Examples of org.openscience.cdk.interfaces.IMolecule

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles("C1CC12CC2CC1CC1");
    AllRingsFinder ar = new AllRingsFinder();
    IRingSet ringSet = ar.findAllRings(mol);
    List l = RingPartitioner.partitionRings(ringSet);
    for(Object o : l) {
      IAtomContainer ac = RingPartitioner.convertToAtomContainer((IRingSet)o);
      IMolecule nMol = new Molecule(ac);
      System.out.println(new SmilesGenerator().createSMILES(nMol));
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.