Java Code Examples for org.biojava.nbio.structure.Atom#getGroup()

The following examples show how to use org.biojava.nbio.structure.Atom#getGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StructureInterface.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns and array of all non-Hydrogen atoms in the given molecule, including all
 * main chain HETATOM groups. Non main-chain HETATOM groups with fewer than minSizeHetAtomToInclude
 * non-Hydrogen atoms are not included.
 * @param m
 * @param minSizeHetAtomToInclude HETATOM groups (non main-chain) with fewer number of
 * non-Hydrogen atoms are not included
 * @return
 */
private static Atom[] getAllNonHAtomArray(Atom[] m, int minSizeHetAtomToInclude) {
	List<Atom> atoms = new ArrayList<>();

	for (Atom a:m){

		if (a.getElement()==Element.H) continue;

		Group g = a.getGroup();
		if (g.getType().equals(GroupType.HETATM) &&
			!isInChain(g) &&
			getSizeNoH(g)<minSizeHetAtomToInclude) {
			continue;
		}

		atoms.add(a);

	}
	return atoms.toArray(new Atom[atoms.size()]);
}
 
Example 2
Source File: SymmetryTools.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns the List of Groups of the corresponding representative Atom
 * array. The representative Atom array needs to fulfill: no two Atoms are
 * from the same Group and Groups are sequential (connected in the original
 * Structure), except if they are from different Chains.
 *
 * @param rAtoms
 *            array of representative Atoms (CA, P, etc).
 * @return List of Groups
 */
public static List<Group> getGroups(Atom[] rAtoms) {

	List<Group> groups = new ArrayList<Group>(rAtoms.length);

	for (Atom a : rAtoms) {
		Group g = a.getGroup();
		if (g != null)
			groups.add(g);
		else
			logger.info("Group not found for representative Atom {}", a);
	}
	return groups;
}
 
Example 3
Source File: MMCIFFileTools.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Converts an Atom object to an {@link AtomSite} object.
 * @param a the atom
 * @param model the model number for the output AtomSites
 * @param chainName the chain identifier (author id) for the output AtomSites
 * @param chainId the internal chain identifier (asym id) for the output AtomSites
 * @param atomId the atom id to be written to AtomSite
 * @return
 */
public static AtomSite convertAtomToAtomSite(Atom a, int model, String chainName, String chainId, int atomId) {

	/*
	ATOM 7    C CD  . GLU A 1 24  ? -10.109 15.374 38.853 1.00 50.05 ? ? ? ? ? ? 24  GLU A CD  1
	ATOM 8    O OE1 . GLU A 1 24  ? -9.659  14.764 37.849 1.00 49.80 ? ? ? ? ? ? 24  GLU A OE1 1
	ATOM 9    O OE2 . GLU A 1 24  ? -11.259 15.171 39.310 1.00 50.51 ? ? ? ? ? ? 24  GLU A OE2 1
	ATOM 10   N N   . LEU A 1 25  ? -5.907  18.743 37.412 1.00 41.55 ? ? ? ? ? ? 25  LEU A N   1
	ATOM 11   C CA  . LEU A 1 25  ? -5.168  19.939 37.026 1.00 37.55 ? ? ? ? ? ? 25  LEU A CA  1
	*/

	Group g = a.getGroup();

	String record ;
	if ( g.getType().equals(GroupType.HETATM) ) {
		record = "HETATM";
	} else {
		record = "ATOM";
	}

	String entityId = "0";
	String labelSeqId = Integer.toString(g.getResidueNumber().getSeqNum());
	if (g.getChain()!=null && g.getChain().getEntityInfo()!=null) {
		entityId = Integer.toString(g.getChain().getEntityInfo().getMolId());
		if (g.getChain().getEntityInfo().getType() == EntityType.POLYMER) {
			// this only makes sense for polymeric chains, non-polymer chains will never have seqres groups and there's no point in calling getAlignedResIndex
			labelSeqId = Integer.toString(g.getChain().getEntityInfo().getAlignedResIndex(g, g.getChain()));
		}
	}

	Character  altLoc = a.getAltLoc();
	String altLocStr;
	if (altLoc==null || altLoc == ' ') {
		altLocStr = MMCIF_DEFAULT_VALUE;
	} else {
		altLocStr = altLoc.toString();
	}

	Element e = a.getElement();
	String eString = e.toString().toUpperCase();
	if ( e.equals(Element.R)) {
		eString = "X";
	}

	String insCode = MMCIF_MISSING_VALUE;
	if (g.getResidueNumber().getInsCode()!=null ) {
		insCode = Character.toString(g.getResidueNumber().getInsCode());
	}

	AtomSite atomSite = new AtomSite();
	atomSite.setGroup_PDB(record);
	atomSite.setId(Integer.toString(atomId));
	atomSite.setType_symbol(eString);
	atomSite.setLabel_atom_id(a.getName());
	atomSite.setLabel_alt_id(altLocStr);
	atomSite.setLabel_comp_id(g.getPDBName());
	atomSite.setLabel_asym_id(chainId);
	atomSite.setLabel_entity_id(entityId);
	atomSite.setLabel_seq_id(labelSeqId);
	atomSite.setPdbx_PDB_ins_code(insCode);
	atomSite.setCartn_x(FileConvert.d3.format(a.getX()));
	atomSite.setCartn_y(FileConvert.d3.format(a.getY()));
	atomSite.setCartn_z(FileConvert.d3.format(a.getZ()));
	atomSite.setOccupancy(FileConvert.d2.format(a.getOccupancy()));
	atomSite.setB_iso_or_equiv(FileConvert.d2.format(a.getTempFactor()));
	atomSite.setAuth_seq_id(Integer.toString(g.getResidueNumber().getSeqNum()));
	atomSite.setAuth_comp_id(g.getPDBName());
	atomSite.setAuth_asym_id(chainName);
	atomSite.setAuth_atom_id(a.getName());
	atomSite.setPdbx_PDB_model_num(Integer.toString(model));

	return atomSite;
}
 
Example 4
Source File: CifFileSupplierImpl.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void accept(WrappedAtom wrappedAtom) {
    Atom atom = wrappedAtom.getAtom();
    Group group = atom.getGroup();
    Chain chain = group.getChain();

    groupPDB.add(group.getType().equals(GroupType.HETATM) ? "HETATM" : "ATOM");
    id.add(wrappedAtom.getAtomId());
    Element element = atom.getElement();
    typeSymbol.add(element.equals(Element.R) ? "X" : element.toString().toUpperCase());
    labelAtomId.add(atom.getName());
    Character altLoc = atom.getAltLoc();
    if (altLoc == null || altLoc == ' ') {
        labelAltId.markNextNotPresent();
    } else {
        labelAltId.add(String.valueOf(altLoc));
    }
    labelCompId.add(group.getPDBName());
    labelAsymId.add(wrappedAtom.getChainId());
    String entityId = "0";
    int seqId = group.getResidueNumber().getSeqNum();
    if (chain.getEntityInfo() != null) {
        entityId = Integer.toString(chain.getEntityInfo().getMolId());
        if (chain.getEntityInfo().getType() == EntityType.POLYMER) {
            // this only makes sense for polymeric chains, non-polymer chains will never have seqres groups and
            // there's no point in calling getAlignedResIndex
            seqId = chain.getEntityInfo().getAlignedResIndex(group, chain);
        }
    }
    labelEntityId.add(entityId);
    labelSeqId.add(seqId);
    String insCode = "";
    if (group.getResidueNumber().getInsCode() != null ) {
        insCode = Character.toString(group.getResidueNumber().getInsCode());
    }
    if (insCode.isEmpty()) {
        pdbxPDBInsCode.markNextUnknown();
    } else {
        pdbxPDBInsCode.add(insCode);
    }
    cartnX.add(atom.getX());
    cartnY.add(atom.getY());
    cartnZ.add(atom.getZ());
    occupancy.add(atom.getOccupancy());
    bIsoOrEquiv.add(atom.getTempFactor());
    authSeqId.add(group.getResidueNumber().getSeqNum());
    authCompId.add(group.getPDBName());
    authAsymId.add(wrappedAtom.getChainName());
    authAtomId.add(atom.getName());
    pdbxPDBModelNum.add(wrappedAtom.getModel());
}
 
Example 5
Source File: FileConvert.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Print ATOM record in the following syntax
 * <pre>
 * ATOM      1  N   ASP A  15     110.964  24.941  59.191  1.00 83.44           N
 *
 * COLUMNS        DATA TYPE       FIELD         DEFINITION
 * ---------------------------------------------------------------------------------
 * 1 -  6        Record name     "ATOM  "
 * 7 - 11        Integer         serial        Atom serial number.
 * 13 - 16        Atom            name          Atom name.
 * 17             Character       altLoc        Alternate location indicator.
 * 18 - 20        Residue name    resName       Residue name.
 * 22             Character       chainID       Chain identifier.
 * 23 - 26        Integer         resSeq        Residue sequence number.
 * 27             AChar           iCode         Code for insertion of residues.
 * 31 - 38        Real(8.3)       x             Orthogonal coordinates for X in
 * Angstroms.
 * 39 - 46        Real(8.3)       y             Orthogonal coordinates for Y in
 * Angstroms.
 * 47 - 54        Real(8.3)       z             Orthogonal coordinates for Z in
 * Angstroms.
 * 55 - 60        Real(6.2)       occupancy     Occupancy.
 * 61 - 66        Real(6.2)       tempFactor    Temperature factor.
 * 73 - 76        LString(4)      segID         Segment identifier, left-justified.
 * 77 - 78        LString(2)      element       Element symbol, right-justified.
 * 79 - 80        LString(2)      charge        Charge on the atom.
 * </pre>
 * @param a
 * @param str
 * @param chainID the chain ID that the Atom will have in the output string
 */
public static void toPDB(Atom a, StringBuffer str, String chainID) {

	Group g = a.getGroup();

	GroupType type = g.getType() ;

	String record = "" ;
	if ( type.equals(GroupType.HETATM) ) {
		record = "HETATM";
	} else {
		record = "ATOM  ";
	}


	// format output ...
	String resName = g.getPDBName();
	String pdbcode = g.getResidueNumber().toString();


	int    seri       = a.getPDBserial()        ;
	String serial     = String.format("%5d",seri);
	String fullName   = formatAtomName(a);

	Character  altLoc = a.getAltLoc();
	if ( altLoc == null)
		altLoc = ' ';

	String resseq = "" ;
	if ( hasInsertionCode(pdbcode) )
		resseq     = String.format("%5s",pdbcode);
	else
		resseq     = String.format("%4s",pdbcode)+" ";

	String x          = String.format("%8s",d3.format(a.getX()));
	String y          = String.format("%8s",d3.format(a.getY()));
	String z          = String.format("%8s",d3.format(a.getZ()));
	String occupancy  = String.format("%6s",d2.format(a.getOccupancy())) ;
	String tempfactor = String.format("%6s",d2.format(a.getTempFactor()));


	String leftResName = String.format("%3s",resName);

	StringBuffer s = new StringBuffer();
	s.append(record);
	s.append(serial);
	s.append(" ");
	s.append(fullName);
	s.append(altLoc);
	s.append(leftResName);
	s.append(" ");
	s.append(chainID);
	s.append(resseq);
	s.append("   ");
	s.append(x);
	s.append(y);
	s.append(z);
	s.append(occupancy);
	s.append(tempfactor);

	Element e = a.getElement();

	String eString = e.toString().toUpperCase();

	if ( e.equals(Element.R)) {
		eString = "X";
	}
	str.append(String.format("%-76s%2s", s.toString(),eString));
	str.append(newline);

}