Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtom


     */
    @Test public void testGetInchiEandZ12Dichloroethene2D() throws Exception {

        // (E)-1,2-dichloroethene
        IAtomContainer acE = new AtomContainer();
        IAtom a1E = new Atom("C", new Point2d(2.866, -0.250));
        IAtom a2E = new Atom("C", new Point2d(3.732, 0.250));
        IAtom a3E = new Atom("Cl", new Point2d(2.000, 2.500));
        IAtom a4E = new Atom("Cl", new Point2d(4.598, -0.250));
        a1E.setImplicitHydrogenCount(1);
        a2E.setImplicitHydrogenCount(1);
        acE.addAtom(a1E);
        acE.addAtom(a2E);
        acE.addAtom(a3E);
        acE.addAtom(a4E);

        acE.addBond(new Bond(a1E, a2E, CDKConstants.BONDORDER_DOUBLE));
        acE.addBond(new Bond(a1E, a3E, CDKConstants.BONDORDER_SINGLE));
        acE.addBond(new Bond(a2E, a4E, CDKConstants.BONDORDER_SINGLE));
       
        Assert.assertEquals(gen.generateInchi(acE).getInChI(), "InChI=1S/C2H2Cl2/c3-1-2-4/h1-2H/b2-1+");
       
        // (Z)-1,2-dichloroethene
        IAtomContainer acZ = new AtomContainer();
        IAtom a1Z = new Atom("C", new Point2d(2.866, -0.440));
        IAtom a2Z = new Atom("C", new Point2d(3.732, 0.060));
        IAtom a3Z = new Atom("Cl", new Point2d(2.000, 0.060));
        IAtom a4Z = new Atom("Cl", new Point2d(3.732, 1.060));
        a1Z.setImplicitHydrogenCount(1);
        a2Z.setImplicitHydrogenCount(1);
        acZ.addAtom(a1Z);
        acZ.addAtom(a2Z);
        acZ.addAtom(a3Z);
View Full Code Here


    @Test
    public void testGetInchiFromLandDAlanine3D() throws Exception {
       
        // L-Alanine
        IAtomContainer acL = new AtomContainer();
        IAtom a1L = new Atom("C", new Point3d(-0.358, 0.819, 20.655));
        IAtom a2L = new Atom("C", new Point3d(-1.598, -0.032, 20.905));
        IAtom a3L = new Atom("N", new Point3d(-0.275, 2.014, 21.574));
        IAtom a4L = new Atom("C", new Point3d(0.952, 0.043, 20.838));
        IAtom a5L = new Atom("O", new Point3d(-2.678, 0.479, 21.093));
        IAtom a6L = new Atom("O", new Point3d(-1.596, -1.239, 20.958));
        a1L.setImplicitHydrogenCount(1);
        a3L.setImplicitHydrogenCount(2);
        a4L.setImplicitHydrogenCount(3);
        a5L.setImplicitHydrogenCount(1);
        acL.addAtom(a1L);
        acL.addAtom(a2L);
        acL.addAtom(a3L);
        acL.addAtom(a4L);
        acL.addAtom(a5L);
        acL.addAtom(a6L);
       
        acL.addBond(new Bond(a1L, a2L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a1L, a3L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a1L, a4L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a2L, a5L, CDKConstants.BONDORDER_SINGLE));
        acL.addBond(new Bond(a2L, a6L, CDKConstants.BONDORDER_DOUBLE));
       
        Assert.assertEquals(gen.generateInchi(acL).getInChI(), "InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m0/s1");
       
       
        // D-Alanine
        IAtomContainer acD = new AtomContainer();
        IAtom a1D = new Atom("C", new Point3d(0.358, 0.819, 20.655));
        IAtom a2D = new Atom("C", new Point3d(1.598, -0.032, 20.905));
        IAtom a3D = new Atom("N", new Point3d(0.275, 2.014, 21.574));
        IAtom a4D = new Atom("C", new Point3d(-0.952, 0.043, 20.838));
        IAtom a5D = new Atom("O", new Point3d(2.678, 0.479, 21.093));
        IAtom a6D = new Atom("O", new Point3d(1.596, -1.239, 20.958));
        a1D.setImplicitHydrogenCount(1);
        a3D.setImplicitHydrogenCount(2);
        a4D.setImplicitHydrogenCount(3);
        a5D.setImplicitHydrogenCount(1);
        acD.addAtom(a1D);
View Full Code Here

        if(symbol!=null && symbol.length()>0){

            jcpPanel.get2DHub().setActiveDrawModule(newActiveModule);
            if(atomsInRange!=null){
                while(atomsInRange.hasNext()){
                    IAtom atom = atomsInRange.next();
                    jcpPanel.get2DHub().setSymbol(atom,symbol);
                    //TODO still needed? should this go in hub?
                    // configure the atom, so that the atomic number matches the symbol
                    try
                    {
                        XMLIsotopeFactory.getInstance(atom.getBuilder()).configure(atom);
                    } catch (Exception exception)
                    {
                        logger.error("Error while configuring atom");
                        logger.debug(exception);
                    }
View Full Code Here

      atomsInRange = atoms.iterator();
    }
    if(atomsInRange==null)
      return;
    while(atomsInRange.hasNext()){
            IAtom atom = atomsInRange.next();
            int isotopeNumber = 0;
            try {
                IIsotope isotope =
                    XMLIsotopeFactory.getInstance(
                                atom.getBuilder()).getMajorIsotope(
                                atom.getSymbol());
                isotopeNumber = isotope.getMassNumber();
            } catch (Exception exception) {
                logger.error("Error while configuring atom");
                logger.debug(exception);
            }
            // adapt for menu chosen
            if (type.equals("major")) {
                // that's the default
            } else if (type.equals("majorPlusOne")) {
                isotopeNumber += 1;
            } else if (type.equals("majorPlusTwo")) {
                isotopeNumber += 2;
            } else if (type.equals("majorPlusThree")) {
                isotopeNumber += 3;
            } else if (type.equals("majorMinusOne")) {
                isotopeNumber -= 1;
            } else if (type.equals("majorMinusTwo")) {
                isotopeNumber -= 2;
            } else if (type.equals("majorMinusThree")) {
                isotopeNumber -= 3;
            } else if (type.indexOf("specific")==0) {
              isotopeNumber = Integer.parseInt(type.substring(8));
      }
            jcpPanel.get2DHub().setMassNumber(atom,isotopeNumber);
            jcpPanel.get2DHub().updateView();
            newActiveModule.setID(atom.getSymbol());
            jcpPanel.get2DHub().getController2DModel().setDrawElement(atom.getSymbol());
            jcpPanel.get2DHub().getController2DModel().setDrawIsotopeNumber(isotopeNumber);
            jcpPanel.get2DHub().getController2DModel().setDrawPseudoAtom(false);
        }
        jcpPanel.get2DHub().setActiveDrawModule(newActiveModule);
    }
View Full Code Here

    for (int i = 0; i < undoRedoContainer.getBondCount(); i++) {
      IBond bond = undoRedoContainer.getBond(i);
      container.removeBond(bond);
    }
    for (int i = 0; i < undoRedoContainer.getAtomCount(); i++) {
      IAtom atom = undoRedoContainer.getAtom(i);
      container.removeAtom(atom);
    }
    chemModelRelay.updateAtoms(container, container.atoms());
    IAtomContainer molecule = container.getBuilder().newInstance(IAtomContainer.class,container);
    IAtomContainerSet moleculeSet = ConnectivityChecker
View Full Code Here

    for (int i = 0; i < undoRedoContainer.getBondCount(); i++) {
      IBond bond = undoRedoContainer.getBond(i);
      container.addBond(bond);
    }
    for (int i = 0; i < undoRedoContainer.getAtomCount(); i++) {
      IAtom atom = undoRedoContainer.getAtom(i);
      container.addAtom(atom);
    }
    chemModelRelay.updateAtoms(container, container.atoms());
    IAtomContainer molecule = container.getBuilder().newInstance(IAtomContainer.class,container);
    IAtomContainerSet moleculeSet = ConnectivityChecker
View Full Code Here

    this.type=type;
  }

  public void redo() {
    for (int i = 0; i < undoRedoContainer.getAtomCount(); i++) {
      IAtom atom=undoRedoContainer.getAtom(i);
      atom.getPoint2d().x+=offset.x;
      atom.getPoint2d().y+=offset.y;
    }
  }
View Full Code Here

    }
  }

  public void undo() {
    for (int i = 0; i < undoRedoContainer.getAtomCount(); i++) {
      IAtom atom=undoRedoContainer.getAtom(i);
      atom.getPoint2d().x-=offset.x;
      atom.getPoint2d().y-=offset.y;
    }
  }
View Full Code Here

    IRGroupQuery rgrpQ= rgrpHandler.getrGroupQuery();

    if (type.equals("setSubstitute")||type.equals("setRoot")) {
      this.redoRootAttachmentPoints=rgrpHandler.getrGroupQuery().getRootAttachmentPoints();
      for (Iterator<IAtom> atItr = existingAtomDistr.keySet().iterator(); atItr.hasNext();) {
        IAtom atom = atItr.next();
        existingAtomDistr.get(atom).addAtom(atom);
      }
      for (Iterator<IBond> bndItr = existingBondDistr.keySet().iterator(); bndItr.hasNext();) {
        IBond bond = bndItr.next();
        existingBondDistr.get(bond).addBond(bond);
      }
        hub.getChemModel().getMoleculeSet().removeAtomContainer(userSelection);
     
      if (type.equals("setRoot")) {
        if (isNewRgrp) {
          rgrpQ.setRootStructure(null);
          rgrpQ.setRootAttachmentPoints(null);
          for (IAtomContainer atc: hub.getIChemModel().getMoleculeSet().atomContainers()) {
            atc.removeProperty(CDKConstants.TITLE)
          }
          hub.unsetRGroupHandler();
        }
        else {
          existingRoot.setProperty(CDKConstants.TITLE,RGroup.ROOT_LABEL)
          rgrpQ.setRootStructure(existingRoot);
          rgrpQ.setRootAttachmentPoints(existingRootAttachmentPoints);
        }
      }
 
      else if (type.equals("setSubstitute")) {
        if  (existingRgroupLists !=null) {
          for(Iterator<Integer> rNums=existingRgroupLists.keySet().iterator(); rNums.hasNext();){
            int rNum= rNums.next();
            rgrpQ.getRGroupDefinitions().put(rNum, existingRgroupLists.get(rNum));
          }
        }
      }
    }

    else if (type.startsWith("setAtomApoAction")) {
      RGroup undoRGroup=existingRGroupApo.keySet().iterator().next();     
        for (Iterator<Integer> rnumItr= hub.getRGroupHandler().getrGroupQuery().getRGroupDefinitions().keySet().iterator(); rnumItr.hasNext();) {
          for (RGroup rgrp:  hub.getRGroupHandler().getrGroupQuery().getRGroupDefinitions().get(rnumItr.next()).getRGroups()) {
            if(rgrp.equals(undoRGroup)) {
              IAtom apo1=existingRGroupApo.get(undoRGroup).get(1);
              IAtom apo2=existingRGroupApo.get(undoRGroup).get(2);
              rgrp.setFirstAttachmentPoint(apo1);
              rgrp.setSecondAttachmentPoint(apo2);
            }
          }
        }
    }
    else if (type.startsWith("setBondApoAction")) {
      for(Iterator<IAtom> atItr=existingRootAttachmentPoints.keySet().iterator(); atItr.hasNext();) {
        IAtom rAtom= atItr.next();
        Map<Integer,IBond> undoApo = existingRootAttachmentPoints.get(rAtom);
        Map<Integer,IBond> apoBonds = rgrpQ.getRootAttachmentPoints().get(rAtom);

        redoRootAttachmentPoints= new HashMap<IAtom, Map<Integer, IBond>>();
        Map<Integer,IBond> redoApo = new HashMap<Integer,IBond>();
View Full Code Here

        hub.setRGroupHandler(rgrpHandler);
      }
 
      IRGroupQuery rgrpQ= rgrpHandler.getrGroupQuery();
      for (Iterator<IAtom> atItr = existingAtomDistr.keySet().iterator(); atItr.hasNext();) {
        IAtom atom = atItr.next();
        existingAtomDistr.get(atom).removeAtom(atom);
      }
      for (Iterator<IBond> bndItr = existingBondDistr.keySet().iterator(); bndItr.hasNext();) {
        IBond bond = bndItr.next();
        existingBondDistr.get(bond).removeBond(bond);
      }
      hub.getChemModel().getMoleculeSet().addAtomContainer(userSelection);
 
      if (type.equals("setRoot")) {
        rgrpQ.setRootStructure(redoRootStructure);
        rgrpQ.getRootStructure().setProperty(CDKConstants.TITLE,RGroup.ROOT_LABEL)
        rgrpQ.setRootAttachmentPoints(redoRootAttachmentPoints);
      }
      else if (type.equals("setSubstitute")) {
        if  (redoRgroupLists !=null) {
          for(Iterator<Integer> rNums=redoRgroupLists.keySet().iterator(); rNums.hasNext();){
            int rNum= rNums.next();
            rgrpQ.getRGroupDefinitions().put(rNum, redoRgroupLists.get(rNum));
          }
        }
      }
    }
    else if (type.startsWith("setAtomApoAction")) {
      RGroup redoRGroup=redoRGroupApo.keySet().iterator().next();     
        for (Iterator<Integer> rnumItr= hub.getRGroupHandler().getrGroupQuery().getRGroupDefinitions().keySet().iterator(); rnumItr.hasNext();) {
          for (RGroup rgrp:  hub.getRGroupHandler().getrGroupQuery().getRGroupDefinitions().get(rnumItr.next()).getRGroups()) {
            if(rgrp.equals(redoRGroup)) {
              IAtom apo1=redoRGroupApo.get(redoRGroup).get(1);
              IAtom apo2=redoRGroupApo.get(redoRGroup).get(2);
              rgrp.setFirstAttachmentPoint(apo1);
              rgrp.setSecondAttachmentPoint(apo2);
            }
          }
        }
    }
    else if (type.startsWith("setBondApoAction")) {
      for(Iterator<IAtom> atItr=redoRootAttachmentPoints.keySet().iterator(); atItr.hasNext();) {
        IAtom rAtom= atItr.next();
        Map<Integer,IBond> apoBonds = hub.getRGroupHandler().getrGroupQuery().getRootAttachmentPoints().get(rAtom);

        apoBonds.remove(1); apoBonds.remove(2);
        Map<Integer,IBond> redoApo = redoRootAttachmentPoints.get(rAtom);
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.