public static Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstIndex, int lastIndex, int[] specialAtomIndexes, Atom[] atoms)
		{
			//    System.out.println("PhosphorusMonomer.validateAndAllocate");
			if (firstIndex != lastIndex || specialAtomIndexes[JmolConstants.ATOMID_NUCLEIC_PHOSPHORUS] != firstIndex)
				return null;
			return new PhosphorusMonomer(chain, group3, seqcode, firstIndex, lastIndex, phosphorusOffsets);
		}
        public static new Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, int[] specialAtomIndexes, Atom[] atoms)
		{
			sbyte[] offsets = scanForOffsets(firstAtomIndex, specialAtomIndexes, interestingAminoAtomIDs);
			if (offsets == null)
				return null;
			if (specialAtomIndexes[JmolConstants.ATOMID_CARBONYL_OXYGEN] < 0)
			{
				int carbonylOxygenIndex = specialAtomIndexes[JmolConstants.ATOMID_O1];
				System.Console.Out.WriteLine("I see someone who does not have a carbonyl oxygen");
				if (carbonylOxygenIndex < 0)
					return null;
				offsets[1] = (sbyte) (carbonylOxygenIndex - firstAtomIndex);
			}
			if (!isBondedCorrectly(firstAtomIndex, offsets, atoms))
				return null;
			AminoMonomer aminoMonomer = new AminoMonomer(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets);
			return aminoMonomer;
		}
        public virtual void renderDistance(Atom atomA, Atom atomB, short colix)
		{
			/*
			Miguel commented this out on 31 Aug 2005
			and sent an email to the list asking why it would have been here
			if (! (atomA.isVisible() && atomB.isVisible()))
			return;
			
			1 Sep 2005 ... the previous hack was put in to control the
			display of measurements when there are multiple models.
			The code below should do a better job ... Miguel
			*/
			if (displayModelIndex >= 0 && (displayModelIndex != atomA.modelIndex || displayModelIndex != atomB.modelIndex))
				return ;
			int zA = atomA.ScreenZ - atomA.ScreenD - 10;
			int zB = atomB.ScreenZ - atomB.ScreenD - 10;
			int radius = drawSegment(atomA.ScreenX, atomA.ScreenY, zA, atomB.ScreenX, atomB.ScreenY, zB, colix);
			paintMeasurementString((atomA.ScreenX + atomB.ScreenX) / 2, (atomA.ScreenY + atomB.ScreenY) / 2, ((zA + zB) / 2), radius, colix);
		}
Exemple #4
0
        public void deleteBondedAtom(Atom atomToDelete)
		{
			if (bonds == null)
				return ;
			for (int i = bonds.Length; --i >= 0; )
			{
				Bond bond = bonds[i];
				Atom atomBonded = (bond.atom1 != this)?bond.atom1:bond.atom2;
				if (atomBonded == atomToDelete)
				{
					deleteBond(i);
					return ;
				}
			}
		}
Exemple #5
0
        public Bond getBond(Atom atomOther)
		{
            if (bonds != null)
            {
                for (int i = bonds.Length; --i >= 0; )
                {
                    Bond bond = bonds[i];
                    if ((bond.atom1 == atomOther) || (bond.atom2 == atomOther))
                        return bond;
                }
            }
			return null;
		}
Exemple #6
0
        public bool isCursorOnTop(int xCursor, int yCursor, int minRadius, Atom competitor)
		{
			int r = screenDiameter / 2;
			if (r < minRadius)
				r = minRadius;
			int r2 = r * r;
			int dx = screenX - xCursor;
			int dx2 = dx * dx;
			if (dx2 > r2)
				return false;
			int dy = screenY - yCursor;
			int dy2 = dy * dy;
			int dz2 = r2 - (dx2 + dy2);
			if (dz2 < 0)
				return false;
			if (competitor == null)
				return true;
			int z = screenZ;
			int zCompetitor = competitor.screenZ;
			int rCompetitor = competitor.screenDiameter / 2;
			if (z < zCompetitor - rCompetitor)
				return true;
			int dxCompetitor = competitor.screenX - xCursor;
			int dx2Competitor = dxCompetitor * dxCompetitor;
			int dyCompetitor = competitor.screenY - yCursor;
			int dy2Competitor = dyCompetitor * dyCompetitor;
			int r2Competitor = rCompetitor * rCompetitor;
			int dz2Competitor = r2Competitor - (dx2Competitor + dy2Competitor);
			return (z - Math.Sqrt(dz2) < zCompetitor - Math.Sqrt(dz2Competitor));
		}
Exemple #7
0
        public short getColixAtomPalette(Atom atom, string palette)
		{
            return 0;// colorManager.getColixAtomPalette(atom, palette);
		}
        public static new Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstAtomIndex, int lastAtomIndex, int[] specialAtomIndexes, Atom[] atoms)
		{
			sbyte[] offsets = scanForOffsets(firstAtomIndex, specialAtomIndexes, interestingNucleicAtomIDs);
			
			if (offsets == null)
				return null;
			NucleicMonomer nucleicMonomer = new NucleicMonomer(chain, group3, seqcode, firstAtomIndex, lastAtomIndex, offsets);
			return nucleicMonomer;
		}
Exemple #9
0
 public void bondAtoms(Atom atom1, Atom atom2, short order, BitArray bsA, BitArray bsB)
 {
     bool atom1InSetA = bsA == null || bsA.Get(atom1.atomIndex);
     bool atom1InSetB = bsB == null || bsB.Get(atom1.atomIndex);
     bool atom2InSetA = bsA == null || bsA.Get(atom2.atomIndex);
     bool atom2InSetB = bsB == null || bsB.Get(atom2.atomIndex);
     if (atom1InSetA & atom2InSetB || atom1InSetB & atom2InSetA)
         addBond(atom1.bondMutually(atom2, order, this));
 }
Exemple #10
0
        public void bondAtoms(Atom atom1, Atom atom2, short order)
		{
			addBond(atom1.bondMutually(atom2, order, this));
		}
Exemple #11
0
        public AtomIterator getWithinAnyModelIterator(Atom atomCenter, float radius)
		{
			withinAnyModelIterator.initialize(atomCenter, radius);
			return withinAnyModelIterator;
		}
        public virtual void createHydrogenBond(Atom atom1, Atom atom2, BitArray bsA, BitArray bsB)
		{
			//System.out.println("createHydrogenBond:" + atom1.getAtomNumber() + "<->" + atom2.getAtomNumber());
            if (atom1 != null && atom2 != null)
            {
                Frame frame = model.mmset.frame;
                frame.bondAtoms(atom1, atom2, JmolConstants.BOND_H_NUCLEOTIDE, bsA, bsB);
            }
		}
        public virtual void renderTorsion(Atom atomA, Atom atomB, Atom atomC, Atom atomD, short colix, bool renderArcs)
		{
			/*
			if (! (atomA.isVisible() && atomB.isVisible() &&
			atomC.isVisible() && atomD.isVisible()))
			return;
			*/
			if (displayModelIndex >= 0 && (displayModelIndex != atomA.modelIndex || displayModelIndex != atomB.modelIndex || displayModelIndex != atomC.modelIndex || displayModelIndex != atomD.modelIndex))
				return ;
			int zA = atomA.ScreenZ - atomA.ScreenD - 10;
			int zB = atomB.ScreenZ - atomB.ScreenD - 10;
			int zC = atomC.ScreenZ - atomC.ScreenD - 10;
			int zD = atomD.ScreenZ - atomD.ScreenD - 10;
			int radius = drawSegment(atomA.ScreenX, atomA.ScreenY, zA, atomB.ScreenX, atomB.ScreenY, zB, colix);
			radius += drawSegment(atomB.ScreenX, atomB.ScreenY, zB, atomC.ScreenX, atomC.ScreenY, zC, colix);
			radius += drawSegment(atomC.ScreenX, atomC.ScreenY, zC, atomD.ScreenX, atomD.ScreenY, zD, colix);
			radius /= 3;
			paintMeasurementString((atomA.ScreenX + atomB.ScreenX + atomC.ScreenX + atomD.ScreenX) / 4, (atomA.ScreenY + atomB.ScreenY + atomC.ScreenY + atomD.ScreenY) / 4, (zA + zB + zC + zD) / 4, radius, colix);
		}
        public virtual void renderAngle(Atom atomA, Atom atomB, Atom atomC, short colix, bool renderArcs)
		{
			/*
			if (! (atomA.isVisible() && atomB.isVisible() && atomC.isVisible()))
			return;
			*/
			if (displayModelIndex >= 0 && (displayModelIndex != atomA.modelIndex || displayModelIndex != atomB.modelIndex || displayModelIndex != atomC.modelIndex))
				return ;
            //g3d.setColix(colix);
			int zA = atomA.ScreenZ - atomA.ScreenD - 10;
			int zB = atomB.ScreenZ - atomB.ScreenD - 10;
			int zC = atomC.ScreenZ - atomC.ScreenD - 10;
			int zOffset = (zA + zB + zC) / 3;
			int radius = drawSegment(atomA.ScreenX, atomA.ScreenY, zA, atomB.ScreenX, atomB.ScreenY, zB, colix);
			radius += drawSegment(atomB.ScreenX, atomB.ScreenY, zB, atomC.ScreenX, atomC.ScreenY, zC, colix);
			radius = (radius + 1) / 2;
			
			if (!renderArcs)
				return ;
			
			
			// FIXME mth -- this really should be a function of pixelsPerAngstrom
			// in addition, the location of the arc is not correct
			// should probably be some percentage of the smaller distance
			AxisAngle4f aa = measurement.aa;
			if (aa == null)
			{
				// 180 degrees
				paintMeasurementString(atomB.ScreenX + 5, atomB.ScreenY - 5, zB, radius, colix);
				return ;
			}
			int dotCount = (int) ((aa.angle / (2 * System.Math.PI)) * 64);
			float stepAngle = aa.angle / dotCount;
			aaT.set_Renamed(aa);
			int iMid = dotCount / 2;
			for (int i = dotCount; --i >= 0; )
			{
				aaT.angle = i * stepAngle;
				matrixT.set_Renamed(aaT);
				pointT.set_Renamed(measurement.pointArc);
				matrixT.transform(pointT);
				pointT.add(atomB.point3f);
                //Point3i screenArc = viewer.transformPoint(pointT);
                //int zArc = screenArc.z - zOffset;
                //if (zArc < 0)
                //    zArc = 0;
                //g3d.drawPixel(screenArc.x, screenArc.y, zArc);
                //if (i == iMid)
                //{
                //    pointT.set_Renamed(measurement.pointArc);
                //    pointT.scale(1.1f);
                //    matrixT.transform(pointT);
                //    pointT.add(atomB.point3f);
                //    Point3i screenLabel = viewer.transformPoint(pointT);
                //    int zLabel = screenLabel.z - zOffset;
                //    paintMeasurementString(screenLabel.x, screenLabel.y, zLabel, radius, colix);
                //}
			}
		}
Exemple #15
0
 public void checkValencesAndBond(Atom atomA, Atom atomB, short order)
 {
     //    System.out.println("checkValencesAndBond(" +
     //                       atomA.point3f + "," + atomB.point3f + ")");
     if (atomA.CurrentBondCount > JmolConstants.MAXIMUM_AUTO_BOND_COUNT || atomB.CurrentBondCount > JmolConstants.MAXIMUM_AUTO_BOND_COUNT)
     {
         System.Console.Out.WriteLine("maximum auto bond count reached");
         return;
     }
     int formalChargeA = atomA.FormalCharge;
     if (formalChargeA != 0)
     {
         int formalChargeB = atomB.FormalCharge;
         if ((formalChargeA < 0 && formalChargeB < 0) || (formalChargeA > 0 && formalChargeB > 0))
             return;
     }
     addBond(atomA.bondMutually(atomB, order, this));
 }
Exemple #16
0
 public void bondAtoms(Atom atom1, Atom atom2, int order)
 {
     // skip ht lookup - pointless
     if (bondCount == bonds.Length)
         bonds = (Bond[])Util.setLength(bonds, bondCount + 2 * ATOM_GROWTH_INCREMENT);
     // note that if the atoms are already bonded then
     // Atom.bondMutually(...) will return null
     Bond bond = atom1.bondMutually(atom2, (short)order, this);
     if (bond != null)
     {
         bonds[bondCount++] = bond;
         if ((order & JmolConstants.BOND_HYDROGEN_MASK) != 0)
             fileHasHbonds = true;
     }
 }
Exemple #17
0
        public Bond(Atom atom1, Atom atom2, short order, short mad, short colix)
		{
			if (atom1 == null)
				throw new System.NullReferenceException();
			if (atom2 == null)
				throw new System.NullReferenceException();
			this.atom1 = atom1;
			this.atom2 = atom2;
			if (atom1.elementNumber == 16 && atom2.elementNumber == 16)
				order |= JmolConstants.BOND_SULFUR_MASK;
			if (order == JmolConstants.BOND_AROMATIC_MASK)
				order = JmolConstants.BOND_AROMATIC;
			this.order = order;
			this.mad = mad;
			this.colix = colix;
		}
Exemple #18
0
        private Atom AddAtom(int modelIndex, object atomUid, sbyte atomicNumber, string atomName,
                             int formalCharge, float partialCharge, int occupancy, float bfactor,
                             float x, float y, float z, bool isHetero, int atomSerial, char chainID,
                             string group3, int groupSequenceNumber, char groupInsertionCode,
                             float vectorX, float vectorY, float vectorZ, char alternateLocationID,
                             object clientAtomReference)
        {
            if (modelIndex != currentModelIndex)
            {
                currentModel = mmset.getModel(modelIndex);
                currentModelIndex = modelIndex;
                currentChainID = '\uFFFF';
            }
            if (chainID != currentChainID)
            {
                currentChainID = chainID;
                currentChain = currentModel.getOrAllocateChain(chainID);
                currentGroupInsertionCode = '\uFFFF';
            }
            if (groupSequenceNumber != currentGroupSequenceNumber ||
                groupInsertionCode != currentGroupInsertionCode)
            {
                currentGroupSequenceNumber = groupSequenceNumber;
                currentGroupInsertionCode = groupInsertionCode;
                startGroup(currentChain, group3, groupSequenceNumber, groupInsertionCode, atomCount);
            }

            if (atomCount == atoms.Length)
                growAtomArrays();

            Atom atom = new Atom(this,
                                 currentModelIndex,
                                 atomCount,
                                 atomicNumber,
                                 atomName,
                                 formalCharge, partialCharge,
                                 occupancy,
                                 bfactor,
                                 x, y, z,
                                 isHetero, atomSerial, chainID,
                                 vectorX, vectorY, vectorZ,
                                 alternateLocationID,
                                 clientAtomReference);

            atoms[atomCount] = atom;
            ++atomCount;
            htAtomMap[atomUid] = atom;

            return atom;
        }
Exemple #19
0
        public Bond(Atom atom1, Atom atom2, short order, Frame frame)
            :this(atom1, atom2, order, /*((order & JmolConstants.BOND_HYDROGEN_MASK) != 0?*/1/*:frame.viewer.MadBond)*/, (short)0)
		{ }
Exemple #20
0
        public short getColixAtom(Atom atom)
		{
            return 0;// colorManager.getColixAtom(atom);
		}
Exemple #21
0
        public virtual void deleteAtomReferences()
		{
			if (atom1 != null)
				atom1.deleteBond(this);
			if (atom2 != null)
				atom2.deleteBond(this);
			atom1 = atom2 = null;
		}
Exemple #22
0
        public bool isCursorOnTopOfVisibleAtom(int xCursor, int yCursor, int minRadius, Atom competitor)
		{
			return (((formalChargeAndFlags & VISIBLE_FLAG) != 0) && isCursorOnTop(xCursor, yCursor, minRadius, competitor));
		}
        public static bool isBondedCorrectly(int firstAtomIndex, sbyte[] offsets, Atom[] atoms)
		{
			return (isBondedCorrectly(2, 0, firstAtomIndex, offsets, atoms) && isBondedCorrectly(0, 3, firstAtomIndex, offsets, atoms) && isBondedCorrectly(3, 1, firstAtomIndex, offsets, atoms));
		}
Exemple #24
0
        public bool isBonded(Atom atomOther)
		{
			return getBond(atomOther) != null;
		}
        public static bool isBondedCorrectly(int offset1, int offset2, int firstAtomIndex, sbyte[] offsets, Atom[] atoms)
		{
			int atomIndex1 = firstAtomIndex + (offsets[offset1] & 0xFF);
			int atomIndex2 = firstAtomIndex + (offsets[offset2] & 0xFF);
			/*
			System.out.println("isBondedCorrectly() " +
			" atomIndex1=" + atomIndex1 +
			" atomIndex2=" + atomIndex2);
			*/
			if (atomIndex1 >= atomIndex2)
				return false;
			return atoms[atomIndex1].isBonded(atoms[atomIndex2]);
		}
Exemple #26
0
        public Bond bondMutually(Atom atomOther, short order, Frame frame)
		{
			if (isBonded(atomOther))
				return null;
			Bond bond = new Bond(this, atomOther, order, frame);
			addBond(bond, frame);
			atomOther.addBond(bond, frame);
			return bond;
		}
Exemple #27
0
 private short getBondOrder(Atom atomA, float bondingRadiusA, Atom atomB, float bondingRadiusB, float distance2, float minBondDistance2, float bondTolerance)
 {
     //            System.out.println(" radiusA=" + bondingRadiusA +
     //                               " radiusB=" + bondingRadiusB +
     //                         " distance2=" + distance2 +
     //                         " tolerance=" + bondTolerance);
     if (bondingRadiusA == 0 || bondingRadiusB == 0)
         return 0;
     float maxAcceptable = bondingRadiusA + bondingRadiusB + bondTolerance;
     float maxAcceptable2 = maxAcceptable * maxAcceptable;
     if (distance2 < minBondDistance2)
     {
         //System.out.println("less than minBondDistance");
         return 0;
     }
     if (distance2 <= maxAcceptable2)
     {
         //System.out.println("returning 1");
         return 1;
     }
     return 0;
 }
Exemple #28
0
		// find the longest bond to discard
		// but return null if atomChallenger is longer than any
		// established bonds
		// note that this algorithm works when maximum valence == 0
        public Bond getLongestBondToDiscard(Atom atomChallenger)
		{
			float dist2Longest = point3f.distanceSquared(atomChallenger.point3f);
			Bond bondLongest = null;
			for (int i = bonds.Length; --i >= 0; )
			{
				Bond bond = bonds[i];
				Atom atomOther = bond.atom1 != this?bond.atom1:bond.atom2;
				float dist2 = point3f.distanceSquared(atomOther.point3f);
				if (dist2 > dist2Longest)
				{
					bondLongest = bond;
					dist2Longest = dist2;
				}
			}
			//    out.println("atom at " + point3f + " suggests discard of " +
			//                       bondLongest + " dist2=" + dist2Longest);
			return bondLongest;
		}
        public static Monomer validateAndAllocate(Chain chain, string group3, int seqcode, int firstIndex, int lastIndex, int[] specialAtomIndexes, Atom[] atoms)
		{
			if (firstIndex != lastIndex || specialAtomIndexes[JmolConstants.ATOMID_ALPHA_CARBON] != firstIndex)
				return null;
			return new AlphaMonomer(chain, group3, seqcode, firstIndex, lastIndex, alphaOffsets);
		}