Exemple #1
0
        /// <summary>
        /// apply cartesian symmetry operators on cartesian coordinates
        /// directly to provide transformed cartesian coordinate
        /// </summary>
        /// <param name="symOpMatrix"></param>
        /// <param name="fractTransMatrix"></param>
        /// <param name="cartnInverseMatrix"></param>
        /// <returns></returns>
        public AtomInfo TransformAtom(SymOpMatrix symOpMatrix)
        {
            AtomInfo transformedAtom = (AtomInfo)this.Clone();;

            transformedAtom.xyz = symOpMatrix * this.xyz;
            return(transformedAtom);
        }
Exemple #2
0
        /// <summary>
        /// sort chains by atom ID
        /// </summary>
        public void SortByAtomId()
        {
            if (cartnAtoms == null)
            {
                return;
            }
            AtomInfo[] chain = this.CartnAtoms;
            Dictionary <int, AtomInfo> seqHash = new Dictionary <int, AtomInfo> ();

            foreach (AtomInfo atom in chain)
            {
                // sould have unique atom id
                seqHash.Add(atom.atomId, atom);
            }
            List <int> atomIdList = new List <int> (seqHash.Keys);

            atomIdList.Sort();
            AtomInfo[] sortedChain = new AtomInfo [chain.Length];
            int        count       = 0;

            foreach (int atomId in atomIdList)
            {
                sortedChain[count] = seqHash[atomId];
                count++;
            }
            this.CartnAtoms = sortedChain;
        }
Exemple #3
0
 /// <summary>
 /// transform a protein chain by applying a specific symmetry operation
 /// either from PDB xml or from a user-defined
 /// </summary>
 /// <param name="chainCoordList"></param>
 /// <param name="symMatrix"></param>
 /// <returns></returns>
 public AtomInfo[] TransformChainBySpecificSymOp(AtomInfo[] chainAtomList, SymOpMatrix symMatrix)
 {
     AtomInfo[] transformedAtomList = new AtomInfo [chainAtomList.Length];
     for (int atomI = 0; atomI < chainAtomList.Length; atomI++)
     {
         AtomInfo thisAtomInfo = chainAtomList[atomI].TransformAtom(symMatrix, cartn2fractMatrix, fract2cartnMatrix);
         transformedAtomList[atomI] = thisAtomInfo;
     }
     return(transformedAtomList);
 }
Exemple #4
0
 /// <summary>
 /// transform a protein chain by applying a specific symmetry operation
 /// either from PDB xml or from a user-defined
 /// </summary>
 /// <param name="chainCoordList"></param>
 /// <param name="symMatrix"></param>
 /// <returns></returns>
 private AtomInfo[] TransformChainByCartesianSymOp(AtomInfo[] chainAtomList, SymOpMatrix symMatrix)
 {
     AtomInfo[] transformedAtomList = new AtomInfo[chainAtomList.Length];
     for (int atomI = 0; atomI < chainAtomList.Length; atomI++)
     {
         AtomInfo thisAtomInfo = chainAtomList[atomI].TransformAtom(symMatrix);
         transformedAtomList[atomI] = thisAtomInfo;
     }
     return(transformedAtomList);
 }
Exemple #5
0
        /// <summary>
        /// a. change a cartesian coordinate to fractional coordinate
        /// b. transform the fractional coordinate
        /// c. compute the cartesian coordinate
        /// for the transformed fractional coordinate
        /// </summary>
        /// <param name="symOpMatrix"></param>
        /// <param name="fractTransMatrix"></param>
        /// <param name="cartnInverseMatrix"></param>
        /// <returns></returns>
        public AtomInfo TransformAtom(SymOpMatrix symOpMatrix, Matrix fractTransMatrix, Matrix cartnInverseMatrix)
        {
            AtomInfo transformedAtom = (AtomInfo)this.Clone();;

            if (this.fractCoord == null)
            {
                this.fractCoord = fractTransMatrix * this.xyz;
            }
            transformedAtom.fractCoord = symOpMatrix * this.fractCoord;
            transformedAtom.xyz        = cartnInverseMatrix * (symOpMatrix * this.fractCoord);
            return(transformedAtom);
        }
Exemple #6
0
 /// <summary>
 /// transform a protein chain by applying a specific symmetry operation
 /// either from PDB xml or from a user-defined
 /// </summary>
 /// <param name="chainCoordList"></param>
 /// <param name="symMatrix"></param>
 /// <returns></returns>
 private AtomInfo[] TransformChainBySymOpAndTrans(AtomInfo[] chainAtomList, SymOpMatrix symMatrix, double[] transVector)
 {
     AtomInfo[] transformedAtomList = new AtomInfo [chainAtomList.Length];
     for (int atomI = 0; atomI < chainAtomList.Length; atomI++)
     {
         AtomInfo thisAtomInfo = chainAtomList[atomI].TransformAtom(symMatrix, cartn2fractMatrix, fract2cartnMatrix);
         thisAtomInfo.xyz.X        += transVector[0];
         thisAtomInfo.xyz.Y        += transVector[1];
         thisAtomInfo.xyz.Z        += transVector[2];
         transformedAtomList[atomI] = thisAtomInfo;
     }
     return(transformedAtomList);
 }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="atoms"></param>
        /// <param name="ncsMatrix"></param>
        /// <returns></returns>
        private AtomInfo[] ApplyNcsMatrix(AtomInfo[] atoms, Matrix ncsMatrix)
        {
            AtomInfo[] newAtoms = new AtomInfo [atoms.Length];
            int        i        = 0;

            foreach (AtomInfo origAtom in atoms)
            {
                newAtoms[i]     = (AtomInfo)origAtom.Clone();
                newAtoms[i].xyz = ncsMatrix * origAtom.xyz;
                i++;
            }
            return(newAtoms);
        }
Exemple #8
0
 /// <summary>
 /// transform one chain 
 /// </summary>
 /// <param name="chain"></param>
 /// <param name="symMatrix"></param>
 /// <returns></returns>
 public AtomInfo[] BuildOneChain(ChainAtoms chain, SymOpMatrix symMatrix)
 {
     if (symMatrix.symmetryString == "1_555")
     {
         return chain.CartnAtoms;
     }
     AtomInfo[] transformedAtoms = new AtomInfo[chain.CartnAtoms.Length];
     int i = 0;
     foreach (AtomInfo atom in chain.CartnAtoms)
     {
         AtomInfo transformedAtom = atom.TransformAtom(symMatrix);
         transformedAtoms[i] = transformedAtom;
         i++;
     }
     return transformedAtoms;
 }
Exemple #9
0
        /// <summary>
        /// deep copy every fields
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            // showdow copy
            AtomInfo clonedAtomInfo = (AtomInfo)this.MemberwiseClone();

            // deep copy fields with reference type
            clonedAtomInfo.xyz = new Coordinate(xyz.X, xyz.Y, xyz.Z);
            if (this.ProjectedCoord != null)
            {
                clonedAtomInfo.ProjectedCoord = (double[])this.ProjectedCoord.Clone();
            }
            if (this.fractCoord != null)
            {
                clonedAtomInfo.fractCoord = new Coordinate(this.fractCoord.X, this.fractCoord.Y, this.fractCoord.Z);;
            }
            return(clonedAtomInfo);
        }
Exemple #10
0
 /// <summary>
 /// deep copy of external atom information
 /// </summary>
 /// <param name="extAtomInfo"></param>
 public AtomInfo(AtomInfo extAtomInfo)
 {
     this.residue     = extAtomInfo.residue;
     this.seqId       = extAtomInfo.seqId;
     this.authSeqId   = extAtomInfo.authSeqId;
     this.atomId      = extAtomInfo.atomId;
     this.authResidue = extAtomInfo.authResidue;
     this.xyz         = new Coordinate(extAtomInfo.xyz.X, extAtomInfo.xyz.Y, extAtomInfo.xyz.Z);
     this.atomName    = extAtomInfo.atomName;
     this.atomType    = extAtomInfo.atomType;
     this.bfactor     = extAtomInfo.bfactor;
     this.occupancy   = extAtomInfo.occupancy;
     if (extAtomInfo.ProjectedCoord != null)
     {
         this.ProjectedCoord = (double[])extAtomInfo.ProjectedCoord.Clone();
     }
     // don't copy the fractional coordinates
     this.fractCoord = null;
 }
Exemple #11
0
 public void Add(AtomInfo atom)
 {
     atomList.Add(atom);
 }
Exemple #12
0
 /// <summary>
 /// add an atom to the list
 /// </summary>
 /// <param name="atom"></param>
 /// <returns></returns>
 public void AddAtom(AtomInfo atom)
 {
     cartnAtoms.Add(atom);
 }