コード例 #1
0
 protected ArrayList<String> generateHashCodes(Iterable<IAtom> atoms) {
   ArrayList<String> hashes = new ArrayList<String>();
   for (IAtom atom : atoms) {
     hashes.add(Integer.toString(atom.hashCode()));
   }
   return hashes;
 }
コード例 #2
0
  /** Converts an Atom to a MSML Atom element */
  protected AtomType convertAtom(IAtom atom, String parentID) {
    AtomType atomElement = new AtomType();
    String id = "";
    if (atom.getID() != null) {
      id = atom.getID();
    } else {
      id = Integer.toString(atom.hashCode());
    }
    String atomID = parentID + PREFIX_ATOM + id;
    atomElement.setId(atomID);
    atomElement.setCustomId("" + id);
    // atom name
    atomElement.setTitle(atom.getAtomTypeName());
    // element name
    atomElement.setElementType(atom.getSymbol());
    double x, y, z;
    // set choords
    if (atom.getPoint3d() != null) {
      x = atom.getPoint3d().x;
      y = atom.getPoint3d().y;
      z = atom.getPoint3d().z;
    } else { // what if mol in 2d? -> has to use getPoint2d
      x = atom.getPoint2d().x;
      y = atom.getPoint2d().y;
      z = 0.0;
    }
    if (atom.getFormalCharge() != null) {
      atomElement.setFormalCharge(BigInteger.valueOf(atom.getFormalCharge()));
    }
    atomElement.setX3(new Float(x));
    atomElement.setY3(new Float(y));
    atomElement.setZ3(new Float(z));

    return atomElement;
  }