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

The following examples show how to use org.biojava.nbio.structure.Atom#setName() . 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: TestInterfaceFinder.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
private List<Group> getGroupList(int size, String type, Chain chain, Point3d center) {
    List<Group> list = new ArrayList<>();
    double offsetx = 0;
    double offsety = 0;
    double offsetz = 0;
    for (int i=0;i<size;i++) {
        Group g = new AminoAcidImpl();
        g.setPDBName(type);
        g.setResidueNumber(new ResidueNumber(chain.getId(), i+1, null));
        chain.addGroup(g);
        Atom a = new AtomImpl();
        a.setName(StructureTools.CA_ATOM_NAME);
        a.setX(center.x + offsetx);
        a.setY(center.y + offsety);
        a.setZ(center.z + offsetz);
        g.addAtom(a);
        list.add(g);

        if (i%3 == 0) offsetx += 1;
        if (i%3 == 1) offsety += 1;
        if (i%3 == 2) offsetz += 1;
    }

    return list;
}
 
Example 2
Source File: SimpleMMcifConsumer.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Convert a mmCIF AtomSite object to a BioJava Atom object
 *
 * @param atom the mmmcif AtomSite record
 * @return an Atom
 */
private Atom convertAtom(AtomSite atom){


	Atom a = new AtomImpl();

	a.setPDBserial(Integer.parseInt(atom.getId()));
	a.setName(atom.getLabel_atom_id());

	double x = Double.parseDouble (atom.getCartn_x());
	double y = Double.parseDouble (atom.getCartn_y());
	double z = Double.parseDouble (atom.getCartn_z());
	a.setX(x);
	a.setY(y);
	a.setZ(z);

	float occupancy = Float.parseFloat (atom.getOccupancy());
	a.setOccupancy(occupancy);

	float temp = Float.parseFloat (atom.getB_iso_or_equiv());
	a.setTempFactor(temp);

	String alt = atom.getLabel_alt_id();
	if (( alt != null ) && ( alt.length() > 0) && (! alt.equals("."))){
		a.setAltLoc(new Character(alt.charAt(0)));
	} else {
		a.setAltLoc(new Character(' '));
	}

	Element element = Element.R;
	try {
		element = Element.valueOfIgnoreCase(atom.getType_symbol());
	}  catch (IllegalArgumentException e) {
		logger.info("Element {} was not recognised as a BioJava-known element, the element will be represented as the generic element {}", atom.getType_symbol(), Element.R.name());
	}
	a.setElement(element);

	return a;

}
 
Example 3
Source File: TestAsaCalc.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Atom getAtom(double x, double y, double z) {
	Atom atom = new AtomImpl();
	AminoAcidImpl g = new AminoAcidImpl();
	g.setAminoType('A');
	atom.setGroup(g);
	atom.setName("CA");
	atom.setElement(Element.C);
	atom.setX(x);
	atom.setY(y);
	atom.setZ(z);
	return atom;
}
 
Example 4
Source File: TestSubunitCluster.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private List<Group> getGroupList(int size, String type, Chain chain) {
	List<Group> list = new ArrayList<>();
	for (int i=0;i<size;i++) {
		Group g = new AminoAcidImpl();
		g.setPDBName(type);
		g.setResidueNumber(new ResidueNumber(chain.getId(), i+1, null));
		chain.addGroup(g);
		Atom a = new AtomImpl();
		a.setName(StructureTools.CA_ATOM_NAME);
		g.addAtom(a);
		list.add(g);
	}
	return list;
}
 
Example 5
Source File: TestMMCIFWriting.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Atom getAtom(String name, Element e, int id, double x, double y, double z) {
	Atom a = new AtomImpl();
	a.setX(x);
	a.setY(y);
	a.setZ(z);
	a.setPDBserial(id);
	a.setName(name);
	a.setElement(e);
	return a;
}
 
Example 6
Source File: CifFileSupplierIntegrationTest.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Atom getAtom(String name, Element e, int id, double x, double y, double z) {
    Atom a = new AtomImpl();
    a.setX(x);
    a.setY(y);
    a.setZ(z);
    a.setPDBserial(id);
    a.setName(name);
    a.setElement(e);
    return a;
}
 
Example 7
Source File: MmtfStructureReader.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void setAtomInfo(String atomName,
		int serialNumber, char alternativeLocationId, float x,
		float y, float z, float occupancy,
		float temperatureFactor,
		String element, int charge) {
	Atom atom = new AtomImpl();
	Group altGroup = null;
	atom.setPDBserial(serialNumber);
	atom.setName(atomName.trim());
	atom.setElement(Element.valueOfIgnoreCase(element));
	if(alternativeLocationId==MmtfStructure.UNAVAILABLE_CHAR_VALUE){
		alternativeLocationId = ' ';
	}
	if (alternativeLocationId != ' ') {
		// Get the altGroup
		altGroup = getCorrectAltLocGroup(alternativeLocationId);
		atom.setAltLoc(alternativeLocationId);
	} else {
		atom.setAltLoc(Character.valueOf(' '));
	}
	atom.setX(x);
	atom.setY(y);
	atom.setZ(z);
	atom.setOccupancy(occupancy);
	atom.setTempFactor(temperatureFactor);
	atom.setCharge((short) charge);
	if (altGroup == null) {
		group.addAtom(atom);
	} else {
		altGroup.setChain(chain);
		altGroup.addAtom(atom);
	}

	// IF the main group doesn't have this atom
	if (!group.hasAtom(atom.getName())) {

		// If it's not a microheterogenity case
		if (group.getPDBName().equals(atom.getGroup().getPDBName())) {
			// And it's not a deuterated case.  'nanoheterogenity'
			if(!StructureTools.hasNonDeuteratedEquiv(atom,group)){
				group.addAtom(atom);
			}
		}
	}
	atomsInGroup.add(atom);
	allAtoms[atomCounter] = atom;
	atomCounter++;
}
 
Example 8
Source File: TestMmtfStructureWriter.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Test the writing of Structure objects to a file.
 * @throws IOException
 */
@Test
public void testWrite() throws IOException {

	// Create a structure
	Structure structure = new StructureImpl();

	// Add some header information
	PDBHeader pdbHeader = new PDBHeader();
	pdbHeader.setExperimentalTechnique("X-RAY DIFFRACTION");
	structure.setPDBHeader(pdbHeader);

	// Create one chain
	structure.setEntityInfos(new ArrayList<EntityInfo>());
	Chain chain = new ChainImpl();
	chain.setId("A");
	chain.setName("A");
	Group group = new AminoAcidImpl();
	group.setPDBName("FKF");
	ChemComp chemComp = new ChemComp();
	chemComp.setType("TYPfdl");
	chemComp.setOne_letter_code("A");
	group.setChemComp(chemComp);

	// Create one Atom
	Atom atom = new AtomImpl();
	atom.setName("A");
	atom.setElement(Element.Ag);
	atom.setCoords(new double[] { 1.0, 2.0, 3.0 });

	// Link together the objects
	chain.addGroup(group);
	group.addAtom(atom);

	ResidueNumber residueNumber = new ResidueNumber();
	residueNumber.setInsCode('A');
	residueNumber.setSeqNum(100);
	group.setResidueNumber(residueNumber);

	structure.addChain(chain);

	File tempFile = testFolder.newFile("tmpfile");
	MmtfActions.writeToFile(structure, tempFile.toPath());
}