/** returns and identical copy of this object . * @return and identical copy of this object */ @Override public Object clone() { AtomImpl n = new AtomImpl(); n.setOccupancy(getOccupancy()); n.setTempFactor(getTempFactor()); n.altLoc = altLoc; // since char is a primitive we can do this (to avoid going through getter/setter that check for nulls) n.setCharge(getCharge()); double[] coords = getCoords(); n.setX(coords[0]); n.setY(coords[1]); n.setZ(coords[2]); n.setPDBserial(getPDBserial()); n.setName(getName()); n.setElement(getElement()); // NOTE bonds can't be cloned here, they would need to be cloned at the // chain or group level (depending if they are intra or inter group bonds) -- JD 2016-03-02 return n ; }
AtomImpl atom = new AtomImpl() ; atom.setPDBserial(pdbnumber) ; atom.setAltLoc(altLoc); atom.setName(fullname.trim()); coords[1] = y ; coords[2] = z ; atom.setCoords(coords); atom.setOccupancy( occu ); atom.setTempFactor( tempf ); atom.setElement(element); if ( ! currentGroup.hasAtom(atom.getName())) { currentGroup.addAtom(atom);
public AlternativeAlignment() { super(); nfrags = 0; aligpath = new IndexPair[0]; //alig1 = new short[0]; //alig2 = new short[0]; idx1 = new int[0]; idx2 = new int[0]; center = new AtomImpl(); rot = null; tr = new AtomImpl(); eqr0 = -99; rms0 = 99; joined = 0; gaps0 = -99; fromia = 0; currentRotMatrix = new Matrix(0,0); currentTranMatrix = new AtomImpl(); distanceMatrix = new Matrix(0,0); }
public FragmentPair(int length, int p1, int p2) { super(); this.length = length ; pos1 = p1; pos2 = p2; contacts = 0; cluster = 0; rms = 0.0; used = 0; covered = 0; unitv = new AtomImpl(); unitv.setX(0); unitv.setY(0); unitv.setZ(1); rot = null; trans = new AtomImpl(); center1 = new AtomImpl(); center2 = new AtomImpl(); } @Override
/** * Extract the translational vector as an Atom of a transformation matrix. * * @param transform * Matrix4d * @return Atom shift vector */ public static Atom getTranslationVector(Matrix4d transform){ Atom transl = new AtomImpl(); double[] coords = {transform.m03, transform.m13, transform.m23}; transl.setCoords(coords); return transl; }
public static final Atom invert(Atom a) { double[] coords = new double[]{0.0,0.0,0.0} ; Atom zero = new AtomImpl(); zero.setCoords(coords); return subtract(zero, a); }
/** * Get the centroid for the set of atoms starting from position pos, length fragmentLenght * * @param ca * @param pos * @param fragmentLength * @return an Atom */ public static Atom getCenter(Atom[] ca, int pos, int fragmentLength){ Atom center = new AtomImpl(); if ( pos+fragmentLength > ca.length) { logger.info("pos ("+pos+"), fragL ("+fragmentLength +") > ca.length"+ca.length); return center; } Atom[] tmp = getFragmentNoClone(ca,pos,fragmentLength); return Calc.getCentroid(tmp); }
/** * Create a rotation axis from a vector, a point, and an angle. * * The result will be a pure rotation, with no screw component. * @param axis A vector parallel to the axis of rotation * @param pos A point on the axis of rotation * @param theta The angle to rotate (radians) */ public RotationAxis(Atom axis, Atom pos, double theta) { this.rotationAxis = Calc.unitVector(axis); this.rotationPos = (Atom) pos.clone(); this.theta = theta; this.screwTranslation = new AtomImpl(); //zero this.otherTranslation = null; //deprecated }
/** * Handle cases with small angles of rotation * @param rotation * @param translation */ private void calculateTranslationalAxis(Matrix rotation, Atom translation) { // set axis parallel to translation rotationAxis = Calc.scale(translation, 1./Calc.amount(translation)); // position is undefined rotationPos = null; screwTranslation = translation; otherTranslation = new AtomImpl(); otherTranslation.setCoords(new double[] {0,0,0}); }
/** * Returns the centroid of the set of atoms. * * @param atomSet * a set of Atoms * @return an Atom representing the Centroid of the set of atoms */ public static final Atom getCentroid(Atom[] atomSet){ // if we don't catch this case, the centroid returned is (NaN,NaN,NaN), which can cause lots of problems down the line if (atomSet.length==0) throw new IllegalArgumentException("Atom array has length 0, can't calculate centroid!"); double[] coords = new double[3]; coords[0] = 0; coords[1] = 0; coords[2] = 0 ; for (Atom a : atomSet) { coords[0] += a.getX(); coords[1] += a.getY(); coords[2] += a.getZ(); } int n = atomSet.length; coords[0] = coords[0] / n; coords[1] = coords[1] / n; coords[2] = coords[2] / n; Atom vec = new AtomImpl(); vec.setCoords(coords); return vec; }
/** * Returns the Vector that needs to be applied to shift a set of atoms to * the Centroid, if the centroid is already known * * @param atomSet * array of Atoms * @return the vector needed to shift the set of atoms to its geometric * center */ public static final Atom getCenterVector(Atom[] atomSet, Atom centroid){ double[] coords = new double[3]; coords[0] = 0 - centroid.getX(); coords[1] = 0 - centroid.getY(); coords[2] = 0 - centroid.getZ(); Atom shiftVec = new AtomImpl(); shiftVec.setCoords(coords); return shiftVec; }
Atom shift = new AtomImpl(); double x = Double.parseDouble(getAttribute(eqr, "x")); double y = Double.parseDouble(getAttribute(eqr, "y"));
/** * Returns the center of mass of the set of atoms. Atomic masses of the * Atoms are used. * * @param points * a set of Atoms * @return an Atom representing the center of mass */ public static Atom centerOfMass(Atom[] points) { Atom center = new AtomImpl(); float totalMass = 0.0f; for (Atom a : points) { float mass = a.getElement().getAtomicMass(); totalMass += mass; center = scaleAdd(mass, a, center); } center = scaleEquals(center, 1.0f/totalMass); return center; }
Atom a = new AtomImpl();
public static void main(String[] args){ Chain c = new ChainImpl(); c.setId("X"); Group g = new AminoAcidImpl(); g.setResidueNumber(ResidueNumber.fromString("1A")); try { g.setPDBName("ALA"); } catch (Exception e){} Atom a = new AtomImpl(); a.setName("CA"); g.addAtom(a); c.addGroup(g); System.out.println(getPdbInfo(a)); }
/** * Multiply elements of a by s * * @param a * @param s * @return A new Atom with s*a */ public static Atom scale(Atom a, double s) { double x = a.getX(); double y = a.getY(); double z = a.getZ(); Atom b = new AtomImpl(); b.setX(x*s); b.setY(y*s); b.setZ(z*s); return b; }
rotationAxis = new AtomImpl(); rotationAxis.setCoords(rotAx);
/** * add two atoms ( a + b). * * @param a * an Atom object * @param b * an Atom object * @return an Atom object */ public static final Atom add(Atom a, Atom b){ Atom c = new AtomImpl(); c.setX( a.getX() + b.getX() ); c.setY( a.getY() + b.getY() ); c.setZ( a.getZ() + b.getZ() ); return c ; }
/** * subtract two atoms ( a - b). * * @param a * an Atom object * @param b * an Atom object * @return n new Atom object representing the difference */ public static final Atom subtract(Atom a, Atom b) { Atom c = new AtomImpl(); c.setX( a.getX() - b.getX() ); c.setY( a.getY() - b.getY() ); c.setZ( a.getZ() - b.getZ() ); return c ; }