Exemplo n.º 1
0
 /// <summary> Converts a Jmol <i>model</i> to a CDK AtomContainer.
 /// 
 /// </summary>
 /// <param name="model">A Jmol model as returned by the method ModelAdapter.openBufferedReader()
 /// </param>
 public virtual IAtomContainer convert(System.Object model)
 {
     IAtomContainer atomContainer = builder.newAtomContainer();
     SmarterJmolAdapter adapter = new SmarterJmolAdapter();
     // use this hashtable to map the ModelAdapter Unique IDs to
     // our CDK Atom's
     System.Collections.Hashtable htMapUidsToAtoms = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
     Org.Jmol.Api.JmolAdapter.AtomIterator atomIterator = adapter.getAtomIterator(model);
     while (atomIterator.hasNext())
     {
         IAtom atom = builder.newAtom(atomIterator.ElementSymbol);
         atom.X3d = atomIterator.X;
         atom.Y3d = atomIterator.Y;
         atom.Z3d = atomIterator.Z;
         htMapUidsToAtoms[atomIterator.UniqueID] = atom;
         atomContainer.addAtom(atom);
     }
     Org.Jmol.Api.JmolAdapter.BondIterator bondIterator = adapter.getBondIterator(model);
     while (bondIterator.hasNext())
     {
         System.Object uid1 = bondIterator.AtomUniqueID1;
         System.Object uid2 = bondIterator.AtomUniqueID2;
         int order = bondIterator.EncodedOrder;
         // now, look up the uids in our atom map.
         IAtom atom1 = (IAtom)htMapUidsToAtoms[uid1];
         IAtom atom2 = (IAtom)htMapUidsToAtoms[uid2];
         IBond bond = builder.newBond(atom1, atom2, (double)order);
         atomContainer.addBond(bond);
     }
     return atomContainer;
 }
Exemplo n.º 2
0
 internal StructureIterator(SmarterJmolAdapter enclosingInstance, AtomSetCollection atomSetCollection)
 {
     InitBlock(enclosingInstance);
     structureCount = atomSetCollection.structureCount;
     structures     = atomSetCollection.structures;
     istructure     = 0;
 }
Exemplo n.º 3
0
 internal BondIterator(SmarterJmolAdapter enclosingInstance, AtomSetCollection atomSetCollection)
 {
     InitBlock(enclosingInstance);
     this.atomSetCollection = atomSetCollection;
     atoms = atomSetCollection.atoms;
     bonds = atomSetCollection.bonds;
     ibond = 0;
 }
Exemplo n.º 4
0
			internal StructureIterator(SmarterJmolAdapter enclosingInstance, AtomSetCollection atomSetCollection)
			{
				InitBlock(enclosingInstance);
				structureCount = atomSetCollection.structureCount;
				structures = atomSetCollection.structures;
				istructure = 0;
			}
Exemplo n.º 5
0
			private void  InitBlock(SmarterJmolAdapter enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
Exemplo n.º 6
0
			internal BondIterator(SmarterJmolAdapter enclosingInstance, AtomSetCollection atomSetCollection)
			{
				InitBlock(enclosingInstance);
				this.atomSetCollection = atomSetCollection;
				atoms = atomSetCollection.atoms;
				bonds = atomSetCollection.bonds;
				ibond = 0;
			}
Exemplo n.º 7
0
 private void  InitBlock(SmarterJmolAdapter enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 8
0
 private IMolecule readMolecule(IMolecule molecule)
 {
     JmolAdapter adapter = new SmarterJmolAdapter();
     // note that it actually let's the adapter detect the format!
     System.Object model = adapter.openBufferedReader("", input);
     molecule.add(new Convertor(molecule.Builder).convert(model));
     return molecule;
 }