/** convenience method to determine whether atom is of given elementType; * * @param element * @return true if element of same type as getElementType() */ public boolean hasElement(String elementType) { return elementType != null && elementType.equals(this.getElementType()); }
/** to string. * @return atom id and element type at present */ public String getString() { StringBuilder sb = new StringBuilder(); sb.append("id='"+this.getId()+"'"); sb.append(" elementType='"+this.getElementType()+"'"); return sb.toString(); }
/** * gets chemical element corresponding to elementType. * * @return the chemical element (or null) */ public ChemicalElement getChemicalElement() { return ChemicalElement.getChemicalElement(this.getElementType()); }
/** gets all explict hydrogen ligand atoms. * ignore hydrogen count * @return list of atoms */ public List<CMLAtom> getLigandHydrogenAtoms() { List<CMLAtom> hydrogenAtoms = new ArrayList<CMLAtom>(); List<CMLAtom> ligandAtoms = this.getLigandAtoms(); for (CMLAtom ligand : ligandAtoms) { if (AS.H.equals(ligand.getElementType())) { hydrogenAtoms.add(ligand); } } return hydrogenAtoms; }
/** * split into atoms sets which contain only single elemenTypes. * * @return atomSetTools mapped by element atomicSymbol (empty map if none) */ public Map<String, CMLAtomSet> splitByElements() { Map<String, CMLAtomSet> map = new HashMap<String, CMLAtomSet>(); List<CMLAtom> atoms = getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); String el = atom.getElementType(); CMLAtomSet atomSet = map.get(el); if (atomSet == null) { atomSet = new CMLAtomSet(); map.put(el, atomSet); } atomSet.addAtom(atom); } return map; }
/** * gets atomSubset by elementType. * * @param elementType * for selecting subset * @return the atomSet containing ony atoms with given elementType */ public CMLAtomSet getAtomSetByElementType(String elementType) { CMLAtomSet atomSet = new CMLAtomSet(); List<CMLAtom> atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (elementType.equals(atom.getElementType())) { atomSet.addAtom((CMLAtom) atom); } } return atomSet; }
/** * Convenience method for determing if molecule has coordinates of a given * type. if hasSubMolecules returns true if any submolecules fit * * @param type of coordinates * @param omitHydrogen akip hydrogens without coordinates * @return has coords */ public boolean hasCoordinates(CoordinateType type, boolean omitHydrogen) { boolean has = true; for (CMLAtom atom : getAtoms()) { if (omitHydrogen && "H".equals(atom.getElementType())) { continue; } has = atom.hasCoordinates(type); if (!has) break; } return has; }
/** * is atom of given type. * * @param typeList * @return true if of type */ public boolean atomIsCompatible(List<Type> typeList) { boolean isCompatible = false; ChemicalElement chemicalElement = ChemicalElement .getChemicalElement(this.getElementType()); for (Type type : typeList) { if (type != null && chemicalElement.isChemicalElementType(type)) { isCompatible = true; } } return isCompatible; }
/** * excludes atoms by excludeElementTypes. * * creates new AtomSet. * * @param elementTypes * to exclude * @return atomSet */ public CMLAtomSet excludeElementTypes(String[] elementTypes) { CMLAtomSet newAtomSet = new CMLAtomSet(); List<CMLAtom> atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); String elementType = atom.getElementType(); boolean exclude = false; for (int j = 0; j < elementTypes.length; j++) { if (elementType == null || elementType.equals(S_EMPTY) || elementType.equals(elementTypes[j])) { exclude = true; break; } } if (!exclude) { newAtomSet.addAtom(atoms.get(i)); } } return newAtomSet; }
/** * includes atoms by excludeElementTypes. * * creates new AtomSet. * * @param elementTypes * to include * @return atomSet */ public CMLAtomSet includeElementTypes(String[] elementTypes) { CMLAtomSet newAtomSet = new CMLAtomSet(); List<CMLAtom> atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); String elementType = atom.getElementType(); boolean include = false; for (int j = 0; j < elementTypes.length; j++) { if (elementType.equals(elementTypes[j])) { include = true; break; } } if (include) { newAtomSet.addAtom(atom); } } return newAtomSet; }
if (atom != null && atom.getId() != null) { ChemicalElement element = ChemicalElement.getChemicalElement(atom .getElementType()); if (element != null) { if (basis.equals(Basis.MINIMAL)) {
if (el == null) { throw new RuntimeException("cannot find chemicalElement for atom ("+ atom.getId()+"):"+atom.getElementType());
List<CMLBond> bonds = getBonds(); for (CMLBond bond : bonds) { String elem0 = bond.getAtom(0).getElementType(); String elem1 = bond.getAtom(1).getElementType(); boolean skip = false; if (excludeElements != null) {
throw new RuntimeException("zero or negative occupancy: " + occupancy); String elementType = atom.getElementType(); if (elementType == null || ChemicalElement.getChemicalElement(elementType) == null) { boolean countit = true; for (CMLAtom chk : oatoms) { String ctype = chk.getElementType(); if ( !AS.H.equals(ctype)) { countit = false;
String elementType = atom.getElementType(); double occupancy = (atom.getOccupancyAttribute() == null) ? 1.0 : atom.getOccupancy();