/** * Returns an array of the requested Atoms from the Structure object. * Iterates over all groups and checks if the requested atoms are in this * group, no matter if this is a {@link AminoAcid} or {@link HetatomImpl} * group. If the group does not contain all requested atoms then no atoms * are added for that group. For structures with more than one model, only * model 0 will be used. * * @param s * the structure to get the atoms from * * @param atomNames * contains the atom names to be used. * @return an Atom[] array */ public static final Atom[] getAtomArray(Structure s, String[] atomNames) { List<Chain> chains = s.getModel(0); List<Atom> atoms = new ArrayList<Atom>(); extractAtoms(atomNames, chains, atoms); return atoms.toArray(new Atom[atoms.size()]); }
/** * Returns an array of the requested Atoms from the Structure object. In * contrast to {@link #getAtomArray(Structure, String[])} this method * iterates over all chains. Iterates over all chains and groups and checks * if the requested atoms are in this group, no matter if this is a * {@link AminoAcid} or {@link HetatomImpl} group. If the group does not * contain all requested atoms then no atoms are added for that group. For * structures with more than one model, only model 0 will be used. * * @param s * the structure to get the atoms from * * @param atomNames * contains the atom names to be used. * @return an Atom[] array */ public static final Atom[] getAtomArrayAllModels(Structure s, String[] atomNames) { List<Atom> atoms = new ArrayList<Atom>(); for (int i = 0; i < s.nrModels(); i++) { List<Chain> chains = s.getModel(i); extractAtoms(atomNames, chains, atoms); } return atoms.toArray(new Atom[atoms.size()]); }