Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtom


            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;
    }
   
View Full Code Here


      bestBond.setStereo(CDKConstants.STEREO_BOND_UP_INV);
    }
  }
 
  private void flipStereoCenterAtAtom(String atomId) throws Exception {
    IAtom a = atomMap.get(atomId);
    List l = mol.getConnectedAtomsList(a);
    // Find a pre-existing stereo bond
    for(Object o : l) {
      IAtom aa = (IAtom)o;
      IBond bond = mol.getBond(a, aa);
      if(bond.getStereo() != CDKConstants.STEREO_BOND_NONE) {
        boolean inv = (bond.getStereo() == CDKConstants.STEREO_BOND_UP_INV || bond.getStereo() == CDKConstants.STEREO_BOND_DOWN_INV);
        if(inv && (bond.getAtom(0) == a)) continue;
        if(!inv && !(bond.getAtom(0) == a)) continue;
View Full Code Here

  }
 
  public static List<List<IAtom>> getXAlkyl(IMolecule mol, String atomStr, int alkylLength) {
    List<List<IAtom>> groups = new ArrayList<List<IAtom>>();
    for(int i=0;i<mol.getAtomCount();i++) {
      IAtom a = mol.getAtom(i);
      if(a.getAtomicNumber() != 6) continue;
      if(mol.getBondOrderSum(a) != 1.0) continue;
      // OK, found a "methyl", let's see what's further on
      List<IAtom> connected = mol.getConnectedAtomsList(a);
      if(connected.size() != 1) continue;
      IAtom connectedAtom = connected.get(0);
      List<IAtom> atoms = new ArrayList<IAtom>();
      atoms.add(a);
      if(alkylLength == 1) {
        if(atomStr != null && !connectedAtom.getSymbol().equals(atomStr)) continue;
        if(connectedAtom.getSymbol().equals("C") && mol.getConnectedAtomsCount(connectedAtom) == 2) continue;
        groups.add(atoms);
        continue;
      } else {
        IAtom nextAtom = connectedAtom;
        IAtom prevAtom = a;
        boolean ok = true;
        for(int stepsToGo = alkylLength-1;stepsToGo>0;stepsToGo--) {
          if(!nextAtom.getSymbol().equals("C") || mol.getConnectedAtomsCount(nextAtom) != 2) {
            ok = false;
            break;
          }
          atoms.add(nextAtom);
          IAtom nextNextAtom = null;
          for(IAtom otherAtom : (List<IAtom>)mol.getConnectedAtomsList(nextAtom)) {
            if(otherAtom == prevAtom) continue;
            nextNextAtom = otherAtom;
          }
          prevAtom = nextAtom;
View Full Code Here

  private QueryAtomContainer makeQAC(String smiles) throws Exception {
    IMolecule mol = sp.parseSmiles(smiles);
    ha.addExplicitHydrogensToSatisfyValency(mol);
    QueryAtomContainer qac = QueryAtomContainerCreator.createBasicQueryContainer(mol);
    for(int i=0;i<qac.getAtomCount();i++) {
      IAtom a = qac.getAtom(i);
      if(a.getSymbol().equals("R")) {
        a.setSymbol("C");
        a.setAtomicNumber(6);
      }
    }
    return qac;
  }
View Full Code Here

        if(verbose) System.out.println("One bond?");
        if(l.size() != 1) continue;
        Bond b = (Bond)l.get(0);
        if(verbose) System.out.println("Not a stereo bond?");
        if(b.getStereo() != CDKConstants.STEREO_BOND_NONE) continue;
        IAtom otherAtom = b.getConnectedAtom(mol.getAtom(i));
        // Special cases
        /*if(getInstance().valencies.containsKey(otherAtom.getAtomicNumber())) {
          int valency = getInstance().valencies.get(otherAtom.getAtomicNumber());
          if(valency == 1) {
            if(otherAtom.getFormalCharge() != 0) valency = 0;
          }
          System.out.println(valency);
          if(valency < mol.getConnectedAtomsCount(otherAtom)) {
            System.out.println("removing");
            System.out.println(mol.getAtomCount());
            mol.removeAtomAndConnectedElectronContainers(mol.getAtom(i));
            System.out.println(mol.getAtomCount());
            i--;
            continue;
          }
        }*/
        if(verbose) System.out.println("Connect to carbon?");
        if(verbose) System.out.println(otherAtom.getAtomicNumber());
        if(otherAtom.getAtomicNumber() != 6) continue;
        if(verbose) System.out.println("Bridgehead?");
        if(!removeBridgeHeads && mol.getConnectedAtomsCount(otherAtom) == 4) {
          List ll = mol.getConnectedAtomsList(otherAtom);
          boolean isBridgehead = true;
          for(Object o : ll) {
            IAtom aa = (IAtom)o;
            if(aa == mol.getAtom(i)) continue;
            // Detect cyclicity
            if(!isRingBond(mol, aa, otherAtom)) {
              // ie if it isn't cyclic
              isBridgehead = false;
View Full Code Here

 
  private static boolean scanForRingBonds(IMolecule mol, IAtom targetAtom, IAtom a1, IAtom a2, Set<IAtom> atoms) {
    boolean isRingBond = false;
    List l = mol.getConnectedAtomsList(targetAtom);
    for(Object o : l) {
      IAtom a = (IAtom)o;
      if(a2.equals(a) && !a1.equals(targetAtom)) {
        isRingBond = true;
        //throw new Exception("Cyclic double bond");
      } else if(!a1.equals(a) && !a2.equals(a) && !atoms.contains(a)) {
        atoms.add(a);
View Full Code Here

    for(int i=0;i<mm.getBondCount();i++) {
      IBond b = mm.getBond(i);
      b.setFlag(CDKConstants.ISAROMATIC, false);
    }
    for(int i=0;i<mm.getAtomCount();i++) {
      IAtom a = mm.getAtom(i);
      a.setHybridization(0);
      a.setFlag(CDKConstants.ISAROMATIC, false);
    }
  }
View Full Code Here

      isotopeFactory = IsotopeFactory.getInstance(DefaultChemObjectBuilder.getInstance());     
    } catch (Exception e) {
      throw new Error(e);
    }
    for(int i=0;i<mol.getAtomCount();i++) {
      IAtom a = mol.getAtom(i);
      if(!a.getSymbol().equals("Si")) continue;
      int c = (int)mol.getBondOrderSum(a);
      if(a.getFormalCharge() == 1 || a.getFormalCharge() == -1) c += 1;
      int hr = 4 - c;
      for(int j=0;j<hr;j++) {
        IAtom ha = new Atom("H");
        isotopeFactory.configure(ha);
        IBond b = new Bond(a, ha);
        mol.addAtom(ha);
        mol.addBond(b);
      }
View Full Code Here

 
  private boolean getAtomsAfterAtom(IMolecule mol, IAtom targetAtom, IAtom a1, IAtom a2, Set<IAtom> atoms) throws Exception {
    boolean isRingBond = false;
    List l = mol.getConnectedAtomsList(targetAtom);
    for(Object o : l) {
      IAtom a = (IAtom)o;
      if(a2.equals(a) && !a1.equals(targetAtom)) {
        isRingBond = true;
        //throw new Exception("Cyclic double bond");
      } else if(!a1.equals(a) && !a2.equals(a) && !atoms.contains(a)) {
        atoms.add(a);
View Full Code Here

  }
 
  /* Atomistic (sp3) stereochemistry */
 
  private void makeStereoCenterAtAtom(String atomId, boolean undefined) throws Exception {
    IAtom a = atomMap.get(atomId);
    List l = mol.getConnectedAtomsList(a);

    // First up - add a hydrogen to a bridgehead
    if(mol.getConnectedAtomsCount(a) == 3) {
      boolean isBridgehead = true;
      for(Object o : l) {
        IAtom aa = (IAtom)o;
        // Detect cyclicity
        Set<IAtom> danglingAtoms = new HashSet<IAtom>();
        if(!getAtomsAfterAtom(mol, aa, a, danglingAtoms)) {
          // ie if it isn't cyclic
          isBridgehead = false;
          break;
        }
      }
      if(isBridgehead) {
        IAtom newH = new Atom("H");
        mol.addAtom(newH);
       
      }
    }
   
    // Find the best bond
    PriorityInformation bestPi = null;
    IBond bestBond = null;
    for(Object o : l) {
      IAtom aa = (IAtom)o;
      IBond bond = mol.getBond(a, aa);
      if(bond.getStereo() != CDKConstants.STEREO_BOND_NONE) continue;
      Set<IAtom> danglingAtoms = new HashSet<IAtom>();
      boolean isCyclic = getAtomsAfterAtom(mol, aa, a, danglingAtoms);
      PriorityInformation pi = new PriorityInformation(isCyclic, bond.getOrder() != CDKConstants.BONDORDER_SINGLE, aa.getAtomicNumber(), danglingAtoms.size());
      if(bestPi == null || pi.compareTo(bestPi) > 0) {
        bestBond = bond;
        bestPi = pi;
      }
    }
View Full Code Here

TOP

Related Classes of org.openscience.cdk.interfaces.IAtom

Copyright © 2018 www.massapicom. 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.