Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="needLigands"></param>
        /// <param name="authorOnly"></param>
        /// <param name="destPath"></param>
        public Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBus(string pdbId, string[] biolUnitIDs, bool needLigands)
        {
            EntryCrystal thisEntryCrystal = ReadEntryCrystalFromXml(pdbId);

            Dictionary <string, Dictionary <string, AtomInfo[]> > buHash = new Dictionary <string, Dictionary <string, AtomInfo[]> > ();

            //     buHash = buGenerator.BuildPdbBUsFromDb(pdbId, biolUnitIDs, thisEntryCrystal, needLigands);

            if (thisEntryCrystal.buGenCat.BuGenStructList.Length == 0) // no bu gen info, use asu
            {
                if (thisEntryCrystal.buGenCat.BuStatusInfoList.Length > 0 &&
                    thisEntryCrystal.buGenCat.BuStatusInfoList[0].details == "NMR")
                {
                    Dictionary <string, AtomInfo[]> asuChainHash = new Dictionary <string, AtomInfo[]> ();
                    foreach (ChainAtoms chain in thisEntryCrystal.atomCat.ChainAtomList)
                    {
                        if ((!needLigands) && (chain.PolymerType != "polypeptide"))
                        {
                            continue;
                        }
                        if (!asuChainHash.ContainsKey(chain.asymChain + "_1_555"))
                        {
                            asuChainHash.Add(chain.asymChain + "_1_555", chain.CartnAtoms);
                        }
                    }
                    buHash.Add("1", asuChainHash);
                }
                else
                {
                    buHash = buGenerator.BuildPdbBUsFromDb(pdbId, biolUnitIDs, thisEntryCrystal, needLigands);
                }
            }
            else
            {
                Dictionary <string, AtomInfo[]> buChainHash = null;
                try
                {
                    foreach (string buId in biolUnitIDs)
                    {
                        if (needLigands)
                        {
                            buChainHash = BuildFullPdbBuByPdbSymOps(pdbId, buId, thisEntryCrystal);
                        }
                        else
                        {
                            buChainHash = BuildPdbBuByPdbSymOps(pdbId, buId, thisEntryCrystal);
                        }
                        buHash.Add(buId, buChainHash);
                    }
                }
                catch (Exception ex)
                {
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue("Generate " + pdbId + " PDB BUs errors: " + ex.Message);
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue("Generate BUs from DB info.");
                    buHash = buGenerator.BuildPdbBUsFromDb(pdbId, biolUnitIDs, thisEntryCrystal, needLigands);
                }
            }
            return(buHash);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <param name="chainMatrixHash"></param>
        /// <returns></returns>
        private Dictionary <string, AtomInfo[]> BuildOnePisaAssembly(EntryCrystal thisEntryCrystal, string pdbId, string assemblySeqId)
        {
            Dictionary <string, List <SymOpMatrix> > chainMatrixHash = GetPisaBuMatrices(pdbId, assemblySeqId);

            Dictionary <string, AtomInfo[]> assemblyHash = BuildOneBuAssembly(thisEntryCrystal, chainMatrixHash, "pisa");

            return(assemblyHash);
        }
Esempio n. 3
0
        /// <summary>
        /// build crystal from the xml serialization object and full symmetry operators
        /// </summary>
        /// <param name="thisEntryCrystal"></param>
        /// <param name="symOpStrings"></param>
        /// <param name="fullSymOpStrings"></param>
        /// <returns></returns>
        public Dictionary <string, AtomInfo[]> BuildPdbBu(EntryCrystal thisEntryCrystal, string[] symOpStrings, string[] fullSymOpStrings)
        {
            SymOperator symOp    = new SymOperator();
            CrystalInfo crystal1 = thisEntryCrystal.crystal1;

            Dictionary <string, AtomInfo[]> crystalChainsHash = new Dictionary <string, AtomInfo[]>();

            base.cartn2fractMatrix = thisEntryCrystal.scaleCat.ScaleMatrix;
            base.fract2cartnMatrix = cartn2fractMatrix.Inverse();
            AtomInfo[]  transformedAtoms = null;
            SymOpMatrix symOpMatrix      = null;

            //ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
            ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;

            for (int i = 0; i < symOpStrings.Length; i++)
            {
                if (crystalChainsHash.ContainsKey(symOpStrings[i]))
                {
                    continue;
                }
                string chainId     = symOpStrings[i].Substring(0, symOpStrings[i].IndexOf("_"));
                string symOpString = symOpStrings[i].Substring(symOpStrings[i].IndexOf("_") + 1,
                                                               symOpStrings[i].Length - symOpStrings[i].IndexOf("_") - 1);
                int asymCount = 0;
                for (asymCount = 0; asymCount < chainAtomsList.Length; asymCount++)
                {
                    string asymChain = chainAtomsList[asymCount].AsymChain;
                    if (asymChain == chainId)
                    {
                        break;
                    }
                }
                if (symOpString == origSymOpString)
                {
                    crystalChainsHash.Add(symOpStrings[i], chainAtomsList[asymCount].CartnAtoms);
                    continue;
                }
                // get the symmetry operator matrix

                if (IsFullSymOpStringAMatrix(fullSymOpStrings[i]))
                {
                    symOpMatrix      = GetSymMatrixFromMatrixString(fullSymOpStrings[i]);
                    transformedAtoms = TransformChainByCartesianSymOp
                                           (chainAtomsList[asymCount].CartnAtoms, symOpMatrix);
                }
                else
                {
                    symOpMatrix      = symOp.GetSymMatrix(fullSymOpStrings[i], symOpStrings[i]);
                    transformedAtoms = TransformChainBySpecificSymOp(chainAtomsList[asymCount].CartnAtoms, symOpMatrix);
                }
                crystalChainsHash.Add(symOpStrings[i], transformedAtoms);
            }
            return(crystalChainsHash);
        }
Esempio n. 4
0
        public int[] BuildCrystal(EntryCrystal thisEntryCrystal, ref Dictionary <string, AtomInfo[]> crystalChainsHash)
        {
            if (AppSettings.symOps == null)
            {
                AppSettings.LoadSymOps();
            }
            if (crystal1.spaceGroup == "-")
            {
                crystal1.spaceGroup = "P 1";
            }
            SymOpMatrix[] symOpMatrices = AppSettings.symOps.FindSpaceGroup(crystal1.spaceGroup);
            if (symOpMatrices == null)
            {
                throw new Exception("No symmetry operators provided for this entry " + thisEntryCrystal.PdbId);
            }
            cartn2fractMatrix = thisEntryCrystal.scaleCat.ScaleMatrix;
            fract2cartnMatrix = cartn2fractMatrix.Inverse();

            //ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
            ChainAtoms[] chainAtomsList = new ChainAtoms [thisEntryCrystal.atomCat.ChainAtomList.Length];
            switch (atomType.ToUpper())
            {
            case "CA":
                chainAtomsList = thisEntryCrystal.atomCat.CalphaAtomList();
                // clear the whole atom list,free memory
                thisEntryCrystal.atomCat.ChainAtomList = null;
                break;

            case "CB":
                chainAtomsList = thisEntryCrystal.atomCat.CbetaAtomList();
                // clear the whole atom list, free memory
                thisEntryCrystal.atomCat.ChainAtomList = null;
                break;

            case "CA_CB":
                chainAtomsList = thisEntryCrystal.atomCat.CalphaCbetaAtomList();
                // clear the whole atom list, free memory
                thisEntryCrystal.atomCat.ChainAtomList = null;
                break;

            case "ALL":
                chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
                break;

            default:
                break;
            }
            crystalChainsHash = BuildCrystalBySymOps(chainAtomsList, symOpMatrices);
            int[] maxSteps = TranslateUnitCell(ref crystalChainsHash);
            return(maxSteps);
        }
Esempio n. 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <param name="chainMatrixHash"></param>
        /// <returns></returns>
        public Dictionary<string, AtomInfo[]> BuildOneBuAssembly(EntryCrystal thisEntryCrystal, Dictionary<string, List<SymOpMatrix>> chainMatrixHash, string type)
        {
            Dictionary<string, AtomInfo[]> chainCoordHash = new Dictionary<string,AtomInfo[]> ();

            ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
            ChainAtoms thisChain = null;

            foreach (string asymChain in chainMatrixHash.Keys)
            {
                thisChain = null; // fixed on June 30, 2010
                foreach (ChainAtoms chain in chainAtomsList)
                {
                    if (chain.AsymChain == asymChain)
                    {
                        thisChain = chain;
                        break;
                    }
                }
                if (thisChain == null)
                {
                    continue;
                }

                string chainSymOpString = "";
                foreach (SymOpMatrix symMatrix in chainMatrixHash[asymChain])
                {
                    if (symMatrix.symmetryString == "-" || symMatrix.symmetryString == "")
                    {
                        chainSymOpString = asymChain + "_" + symMatrix.symmetryOpNum + "_-";
                    }
                    else
                    {
                        chainSymOpString = asymChain + "_" + symMatrix.symmetryString;
                        if (type == "pisa")
                        {
                            if (symMatrix.symmetryOpNum != "" && symMatrix.symmetryOpNum != "0")
                            {
                                chainSymOpString += ("(" + symMatrix.symmetryOpNum + ")"); // for those non-NCS operator (same symmetry string)
                            }
                        }
                    }
                    if (!chainCoordHash.ContainsKey(chainSymOpString))
                    {
                        AtomInfo[] atoms = BuildOneChain(thisChain, symMatrix);
                        chainCoordHash.Add(chainSymOpString, atoms);
                    }
                }
            }
            return chainCoordHash;
        }
Esempio n. 6
0
        /// <summary>
        /// calculate and transfer all chains based on the input symmetry strings
        /// </summary>
        /// <param name="thisEntryCrystal"></param>
        /// <param name="symmetryStrings">digits: 2_565</param>
        /// <returns></returns>
        public Dictionary <string, AtomInfo[]> BuildCrystalWithAllChains(EntryCrystal thisEntryCrystal, string[] symmetryStrings)
        {
            SymOperator symOp = new SymOperator();

            crystal1 = thisEntryCrystal.crystal1;
            if (AppSettings.symOps == null)
            {
                AppSettings.LoadSymOps();
            }
            if (crystal1.spaceGroup == "-")
            {
                crystal1.spaceGroup = "P 1";
            }
            SymOpMatrix[] sgSymOpMatrices = AppSettings.symOps.FindSpaceGroup(crystal1.spaceGroup);

            Dictionary <string, AtomInfo[]> crystalChainsHash = new Dictionary <string, AtomInfo[]>();

            cartn2fractMatrix = thisEntryCrystal.scaleCat.ScaleMatrix;
            fract2cartnMatrix = cartn2fractMatrix.Inverse();

            ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
            string       symOpString    = "";

            for (int i = 0; i < symmetryStrings.Length; i++)
            {
                for (int asymCount = 0; asymCount < chainAtomsList.Length; asymCount++)
                {
                    string asymChain = chainAtomsList[asymCount].AsymChain;
                    symOpString = asymChain + "_" + symmetryStrings[i];

                    if (crystalChainsHash.ContainsKey(symOpString))
                    {
                        continue;
                    }

                    if (symmetryStrings[i] == origSymOpString)
                    {
                        crystalChainsHash.Add(symOpString, chainAtomsList[asymCount].CartnAtoms);
                        continue;
                    }

                    SymOpMatrix symOpMatrix      = symOp.GetSymmetryMatrixFromSymmetryString(sgSymOpMatrices, symmetryStrings[i]);
                    AtomInfo[]  transformedAtoms = TransformChainBySpecificSymOp(chainAtomsList[asymCount].CartnAtoms, symOpMatrix);
                    crystalChainsHash.Add(symOpString, transformedAtoms);
                }
            }
            return(crystalChainsHash);
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbXmlFile">a xml file from pdb web site</param>
        /// <returns></returns>
        public Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBAsAllAtoms(string pdbXmlFile)
        {
            if (pdbXmlFile.IndexOf(".gz") > -1)
            {
                string tempDir = "C:\\xml_temp";
                if (!Directory.Exists(tempDir))
                {
                    Directory.CreateDirectory(tempDir);
                }

                pdbXmlFile = ParseHelper.UnZipFile(pdbXmlFile, tempDir);
            }

            FileParser.XmlAtomParser xmlParser        = new CrystalInterfaceLib.FileParser.XmlAtomParser();
            EntryCrystal             thisEntryCrystal = xmlParser.ParseXmlFile(pdbXmlFile);

            Dictionary <string, Dictionary <string, AtomInfo[]> > baChainHash = BuildPdbBAsAllAtoms(thisEntryCrystal);

            return(baChainHash);
        }
Esempio n. 8
0
        /// <summary>
        /// build crystal from the xml serialization object and full symmetry operators
        /// </summary>
        /// <param name="thisEntryCrystal"></param>
        /// <param name="symOpStrings"></param>
        /// <param name="fullSymOpStrings"></param>
        /// <returns></returns>
        public Dictionary <string, AtomInfo[]> BuildPdbBu(EntryCrystal thisEntryCrystal, string[] symOpStrings, SymOpMatrix[] symOpMatrices)
        {
            AtomInfo[] transformedAtoms = null;
            Dictionary <string, AtomInfo[]> crystalChainsHash = new Dictionary <string, AtomInfo[]>();

            //ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
            ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;

            for (int i = 0; i < symOpStrings.Length; i++)
            {
                if (crystalChainsHash.ContainsKey(symOpStrings[i]))
                {
                    continue;
                }
                string chainId     = symOpStrings[i].Substring(0, symOpStrings[i].IndexOf("_"));
                string symOpString = symOpStrings[i].Substring(symOpStrings[i].IndexOf("_") + 1,
                                                               symOpStrings[i].Length - symOpStrings[i].IndexOf("_") - 1);
                int asymCount = 0;
                for (asymCount = 0; asymCount < chainAtomsList.Length; asymCount++)
                {
                    string asymChain = chainAtomsList[asymCount].AsymChain;
                    if (asymChain == chainId)
                    {
                        break;
                    }
                }
                if (symOpString == origSymOpString)
                {
                    crystalChainsHash.Add(symOpStrings[i], chainAtomsList[asymCount].CartnAtoms);
                    continue;
                }
                transformedAtoms = TransformChainByCartesianSymOp(chainAtomsList[asymCount].CartnAtoms, symOpMatrices[i]);

                crystalChainsHash.Add(symOpStrings[i], transformedAtoms);
            }
            return(crystalChainsHash);
        }
Esempio n. 9
0
        /// <summary>
        /// build PDB biological units
        /// by applying the symmetry operations provided in XML
        /// </summary>
        /// <param name="chainAtomsList">chains in XML</param>
        /// <param name="buGenStructList">symmetry operations</param>
        /// <param name="buSymmetryMatrixList">symmetry matrix</param>
        /// <returns>biological units with corresponding chains</returns>
        private void GeneratePdbBusByPdbSymOps(string pdbId, EntryCrystal thisEntryCrystal, string destPath)
        {
            ChainAtoms[]  chainAtomsList  = thisEntryCrystal.atomCat.ChainAtomList;
            BuGenStruct[] buGenStructList = thisEntryCrystal.buGenCat.BuGenStructList;

            BuWriter buWriter = new BuWriter();

            List <string> buIdList = new List <string>  ();

            for (int asymCount = 0; asymCount < buGenStructList.Length; asymCount++)
            {
                string biolUnitId = buGenStructList[asymCount].biolUnitId;
                if (!buIdList.Contains(biolUnitId))
                {
                    buIdList.Add(biolUnitId);
                }
            }
            // process biological units
            foreach (string buId in buIdList)
            {
                try
                {
                    Dictionary <string, AtomInfo[]> buChains = BuildPdbBuByPdbSymOps(pdbId, buId.ToString(), thisEntryCrystal);

                    // writer bu into a PDB formatted file
                    string fileName = buWriter.WriteBiolUnitFile(pdbId, buId.ToString(), buChains, destPath,
                                                                 thisEntryCrystal.crystal1, thisEntryCrystal.scaleCat.ScaleMatrix);
                    // Compress file
                    ParseHelper.ZipPdbFile(fileName);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Cannot generate biological unit file: {0}_{1}: {2}", pdbId, buId.ToString(), ex.Message));
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="thisEntryCrystal"></param>
        /// <param name="needLigands"></param>
        /// <returns></returns>
        public Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBUsFromDb(string pdbId, string[] buIDs, EntryCrystal thisEntryCrystal, bool needLigands)
        {
            Dictionary <string, Dictionary <string, List <SymOpMatrix> > > buComponentInfoHash = GetPdbBuComponentsFromDb(pdbId, buIDs, needLigands);
            Dictionary <string, Dictionary <string, AtomInfo[]> >          entryBuHash         = BuildPdbBUs(pdbId, buComponentInfoHash, thisEntryCrystal, needLigands);

            return(entryBuHash);
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="thisEntryCrystal"></param>
        /// <returns></returns>
        public Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBAsAllAtoms(EntryCrystal thisEntryCrystal)
        {
            string pdbId = thisEntryCrystal.PdbId;
            Dictionary <string, Dictionary <string, AtomInfo[]> > buHash = null;

            if (thisEntryCrystal.buGenCat.BuGenStructList.Length == 0) // no bu gen info, use asu
            {
                if (thisEntryCrystal.buGenCat.BuStatusInfoList.Length > 0 &&
                    thisEntryCrystal.buGenCat.BuStatusInfoList[0].details == "NMR")
                {
                    Dictionary <string, AtomInfo[]> asuChainHash = new Dictionary <string, AtomInfo[]> ();

                    foreach (ChainAtoms chain in thisEntryCrystal.atomCat.ChainAtomList)
                    {
                        asuChainHash.Add(chain.asymChain + "_1_555", chain.CartnAtoms);
                    }
                    buHash.Add("1", asuChainHash);
                }
                else
                {
                    buHash = buGenerator.BuildPdbBUsFromDb(pdbId, thisEntryCrystal, true);
                }
            }
            else
            {
                try
                {
                    buHash = BuildFullPdbBusByPdbSymOps(pdbId, thisEntryCrystal);
                }
                catch (Exception ex)
                {
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue("Generate " + pdbId + " PDB BUs errors: " + ex.Message);
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue("Generate BUs from DB info.");
                    buHash = buGenerator.BuildPdbBUsFromDb(pdbId, thisEntryCrystal, true);
                }
            }
            return(buHash);
        }
Esempio n. 12
0
        /// <summary>
        /// build crystal from the xml serialization object and full symmetry operators
        /// </summary>
        /// <param name="thisEntryCrystal"></param>
        /// <param name="symOpStrings"></param>
        /// <param name="fullSymOpStrings"></param>
        /// <returns></returns>
        public Dictionary <string, AtomInfo[]> BuildCrystal(EntryCrystal thisEntryCrystal, string[] symOpStrings, string[] fullSymOpStrings)
        {
            SymOperator symOp = new SymOperator();

            crystal1 = thisEntryCrystal.crystal1;

            Dictionary <string, AtomInfo[]> crystalChainsHash = new Dictionary <string, AtomInfo[]>();

            cartn2fractMatrix = thisEntryCrystal.scaleCat.ScaleMatrix;
            fract2cartnMatrix = cartn2fractMatrix.Inverse();

            //ChainAtoms[] chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
            ChainAtoms[] chainAtomsList = new ChainAtoms [thisEntryCrystal.atomCat.ChainAtomList.Length];
            switch (atomType)
            {
            case "CA":
                chainAtomsList = thisEntryCrystal.atomCat.CalphaAtomList();
                // clear the whole atom list,free memory
                thisEntryCrystal.atomCat.ChainAtomList = null;
                break;

            case "CB":
                chainAtomsList = thisEntryCrystal.atomCat.CbetaAtomList();
                // clear the whole atom list, free memory
                thisEntryCrystal.atomCat.ChainAtomList = null;
                break;

            case "CA_CB":
                chainAtomsList = thisEntryCrystal.atomCat.CalphaCbetaAtomList();
                // clear the whole atom list, free memory
                thisEntryCrystal.atomCat.ChainAtomList = null;
                break;

            case "ALL":
                chainAtomsList = thisEntryCrystal.atomCat.ChainAtomList;
                break;

            default:
                break;
            }
            for (int i = 0; i < symOpStrings.Length; i++)
            {
                if (crystalChainsHash.ContainsKey(symOpStrings[i]))
                {
                    continue;
                }
                string chainId     = symOpStrings[i].Substring(0, symOpStrings[i].IndexOf("_"));
                string symOpString = symOpStrings[i].Substring(symOpStrings[i].IndexOf("_") + 1,
                                                               symOpStrings[i].Length - symOpStrings[i].IndexOf("_") - 1);
                int asymCount = 0;
                for (asymCount = 0; asymCount < chainAtomsList.Length; asymCount++)
                {
                    string asymChain = chainAtomsList[asymCount].AsymChain;
                    if (asymChain == chainId)
                    {
                        break;
                    }
                }
                if (symOpString == origSymOpString)
                {
                    crystalChainsHash.Add(symOpStrings[i], chainAtomsList[asymCount].CartnAtoms);
                    continue;
                }
                SymOpMatrix symOpMatrix      = symOp.GetSymMatrix(fullSymOpStrings[i], symOpStrings[i]);
                AtomInfo[]  transformedAtoms = TransformChainBySpecificSymOp(chainAtomsList[asymCount].CartnAtoms, symOpMatrix);
                crystalChainsHash.Add(symOpStrings[i], transformedAtoms);
            }
            return(crystalChainsHash);
        }
Esempio n. 13
0
        /// <summary>
        /// build a PDB biological unit
        /// by applying the symmetry operations provided in XML
        /// </summary>
        /// <param name="chainAtomsList">chains in XML</param>
        /// <param name="buGenStructList">symmetry operations</param>
        /// <param name="buSymmetryMatrixList">symmetry matrix</param>
        /// <returns>biological units with corresponding chains</returns>
        /// </summary>
        private Dictionary <string, AtomInfo[]> BuildFullPdbBuByPdbSymOps(string pdbId, string biolUnitId, EntryCrystal thisEntryCrystal)
        {
            Dictionary <string, AtomInfo[]> buHash = null;

            ChainAtoms[]  chainAtomsList  = thisEntryCrystal.atomCat.ChainAtomList;
            BuGenStruct[] buGenStructList = thisEntryCrystal.buGenCat.BuGenStructList;

            List <string>      symOpStrList     = new List <string> ();
            List <string>      fullSymOpStrList = new List <string> ();
            List <SymOpMatrix> symOpMatrixList  = new List <SymOpMatrix> ();

            for (int asymCount = 0; asymCount < buGenStructList.Length; asymCount++)
            {
                if (biolUnitId != buGenStructList[asymCount].biolUnitId)
                {
                    continue;
                }
                string asymId = buGenStructList[asymCount].asymId;
                foreach (ChainAtoms chain in chainAtomsList)
                {
                    if (chain.AsymChain == asymId)
                    {
                        SymOpMatrix symOpMatrix =
                            thisEntryCrystal.buGenCat.FindSymOpMatrix(buGenStructList[asymCount].symOperId);
                        if (symOpMatrix == null)
                        {
                            fullSymOpStrList.Add(buGenStructList[asymCount].symmetryMatrix);
                            symOpStrList.Add(asymId + "_" + buGenStructList[asymCount].symmetryString);
                        }
                        else
                        {
                            if (symOpMatrix.symmetryString == "" || symOpMatrix.symmetryString == "-")
                            {
                                // put the symmetry operator id if the symmetry string is empty
                                symOpStrList.Add(asymId + "_" + buGenStructList[asymCount].symOperId);
                            }
                            else
                            {
                                symOpStrList.Add(asymId + "_" + symOpMatrix.symmetryString);
                            }
                            symOpMatrixList.Add(symOpMatrix);
                        }
                    }
                }
            }

            string[] symOpStrings = symOpStrList.ToArray();
            if (symOpMatrixList.Count > 0)
            {
                buHash = BuildPdbBu(thisEntryCrystal, symOpStrings, symOpMatrixList.ToArray());
            }
            else if (fullSymOpStrList.Count > 0)
            {
                buHash = BuildPdbBu(thisEntryCrystal, symOpStrings, fullSymOpStrList.ToArray());
            }
            return(buHash);
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="thisEntryCrystal"></param>
        /// <returns></returns>
        private Dictionary <string, Dictionary <string, AtomInfo[]> > GetPisaMonomersFromAsu(EntryCrystal thisEntryCrystal)
        {
            int    assemblySeqId       = 1;
            string assemblySeqIdString = "";
            Dictionary <string, Dictionary <string, AtomInfo[]> > pisaMultimersHash = new Dictionary <string, Dictionary <string, AtomInfo[]> > ();

            foreach (ChainAtoms chain in thisEntryCrystal.atomCat.ChainAtomList)
            {
                /*       if (chain.polymerType != "polydeoxyribonucleotide" || chain.polymerType == "polyribonucleotide")
                 *     {
                 *         continue;
                 *     }*/
                if (chain.polymerType == "polypeptide")
                {
                    assemblySeqIdString = assemblySeqId.ToString();
                    if (pisaMultimersHash.ContainsKey(assemblySeqIdString))
                    {
                        pisaMultimersHash[assemblySeqIdString].Add(chain.asymChain + "_1_555", chain.CartnAtoms);
                    }
                    else
                    {
                        Dictionary <string, AtomInfo[]> chainAtomsHash = new Dictionary <string, AtomInfo[]> ();
                        chainAtomsHash.Add(chain.asymChain + "_1_555", chain.CartnAtoms);
                        pisaMultimersHash.Add(assemblySeqIdString, chainAtomsHash);
                        assemblySeqId++;
                    }
                }
                else // add ligands into the first monomer
                {
                    if (pisaMultimersHash.ContainsKey("1"))
                    {
                        pisaMultimersHash["1"].Add(chain.asymChain + "_1_555", chain.CartnAtoms);
                    }
                    else
                    {
                        Dictionary <string, AtomInfo[]> chainAtomsHash = new Dictionary <string, AtomInfo[]> ();
                        chainAtomsHash.Add(chain.asymChain + "_1_555", chain.CartnAtoms);
                        pisaMultimersHash.Add("1", chainAtomsHash);
                    }
                }
            }
            return(pisaMultimersHash);
        }
Esempio n. 15
0
        /// <summary>
        /// build PDB biological units
        /// by applying the symmetry operations provided in XML
        /// </summary>
        /// <param name="chainAtomsList">chains in XML</param>
        /// <param name="buGenStructList">symmetry operations</param>
        /// <param name="buSymmetryMatrixList">symmetry matrix</param>
        /// <returns>biological units with corresponding chains</returns>
        private Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBusByPdbSymOps(string pdbId, EntryCrystal thisEntryCrystal)
        {
            ChainAtoms[]  chainAtomsList  = thisEntryCrystal.atomCat.ChainAtomList;
            BuGenStruct[] buGenStructList = thisEntryCrystal.buGenCat.BuGenStructList;

            BuWriter buWriter = new BuWriter();

            List <string> buIdList = new List <string> ();

            for (int asymCount = 0; asymCount < buGenStructList.Length; asymCount++)
            {
                string biolUnitId = buGenStructList[asymCount].biolUnitId;
                if (!buIdList.Contains(biolUnitId))
                {
                    buIdList.Add(biolUnitId);
                }
            }
            // process biological units
            Dictionary <string, Dictionary <string, AtomInfo[]> > buHash = new Dictionary <string, Dictionary <string, AtomInfo[]> > ();

            foreach (string buId in buIdList)
            {
                try
                {
                    Dictionary <string, AtomInfo[]> buChains = BuildPdbBuByPdbSymOps(pdbId, buId.ToString(), thisEntryCrystal);

                    buHash.Add(buId, buChains);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Cannot generate biological unit file: {0}_{1}: {2}", pdbId, buId.ToString(), ex.Message));
                }
            }
            return(buHash);
        }
Esempio n. 16
0
        /// <summary>
        /// build asymmetric unit from NCS
        /// </summary>
        /// <param name="thisEntryCrystal"></param>
        /// <returns></returns>
        //	public void BuildAsymUnitFromNcs (ref EntryCrystal thisEntryCrystal, string[] origAsymChains, out bool asuChanged)
        public void BuildAsymUnitFromNcs(ref EntryCrystal thisEntryCrystal, out bool asuChanged)
        {
            asuChanged = false;
            //		chainLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            //		ChainAtoms[] chainAtomsList = new ChainAtoms [thisEntryCrystal.atomCat.ChainAtomList.Length];

            int genNcsNum = 0;

            foreach (NcsOperator ncsOp in thisEntryCrystal.ncsCat.NcsOperatorList)
            {
                if (ncsOp.code == "generate")
                {
                    genNcsNum++;
                }
            }
            if (genNcsNum == 0)
            {
                return;
            }
            else if (genNcsNum * thisEntryCrystal.atomCat.ChainAtomList.Length > chainLetters.Length)
            /*   else if (genNcsNum > chainLetters.Length) */
            {
                return;
            }

            List <ChainAtoms> asuChainList = new List <ChainAtoms>();

            //	RemoveOrigAsuChainNames (thisEntryCrystal.atomCat.ChainAtomList, ref chainLetters);
            //	int ncsChainCount = 1;
            foreach (ChainAtoms chain in thisEntryCrystal.atomCat.ChainAtomList)
            {
                /*	if (chain.PolymerType != "polypeptide")
                 *      {
                 *              continue;
                 *      }*/
                asuChainList.Add(chain);
                //	ncsChainCount = 1;
                foreach (NcsOperator ncsOp in thisEntryCrystal.ncsCat.NcsOperatorList)
                {
                    if (ncsOp.code == "given")
                    {
                        continue;
                    }

                    AtomInfo[] ncsAtoms = ApplyNcsMatrix(chain.CartnAtoms, ncsOp.ncsMatrix);
                    if (DoesChainExist(ncsAtoms, thisEntryCrystal.atomCat.ChainAtomList))
                    {
                        continue;
                    }
                    asuChanged = true;
                    ChainAtoms newChain = new ChainAtoms(chain);
                    newChain.CartnAtoms = ncsAtoms;
                    //	newChain.AsymChain = chain.AsymChain + chainLetters[ncsChainCount].ToString ();
                    //	newChain.AsymChain =GetAsymChainNameForNcsChain (ref ncsChainCount, chain.AsymChain, origAsymChains);
                    // name the new chain with original asymmetric chain + a number,
                    // this should distinguish the original asymmetri chains with these regenerated chains
                    //      newChain.AsymChain = chain.AsymChain + ncsChainCount.ToString();
                    newChain.AsymChain = chain.AsymChain + ncsOp.ncsId.ToString();
                    //       ncsChainCount ++;
                    asuChainList.Add(newChain);
                }
            }
            thisEntryCrystal.atomCat.ChainAtomList = asuChainList.ToArray();
        }
Esempio n. 17
0
        /// <summary>
        /// build PDB biological units
        /// by applying the symmetry operations provided in XML
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <returns></returns>
        public Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBusFromCoordFile(string pdbId, EntryCrystal thisEntryCrystal, string atomType)
        {
            // key: biolUnitID,  Value: Hashtable (key: )
            Dictionary <string, Dictionary <string, AtomInfo[]> > entryBuChainsHash = new Dictionary <string, Dictionary <string, AtomInfo[]> >();

            ChainAtoms[]  chainAtomsList  = thisEntryCrystal.atomCat.ChainAtomList;
            BuGenStruct[] buGenStructList = thisEntryCrystal.buGenCat.BuGenStructList;

            List <string> buIdList = new List <string> ();

            for (int asymCount = 0; asymCount < buGenStructList.Length; asymCount++)
            {
                string biolUnitId = buGenStructList[asymCount].biolUnitId;
                if (!buIdList.Contains(biolUnitId))
                {
                    buIdList.Add(biolUnitId);
                }
            }
            // process biological units
            foreach (string buId in buIdList)
            {
                try
                {
                    Dictionary <string, AtomInfo[]> buChains = BuildPdbBuByPdbSymOps(pdbId, buId.ToString(), thisEntryCrystal);
                    if (buChains == null || buChains.Count == 0)
                    {
                        continue;
                    }
                    entryBuChainsHash.Add(buId.ToString(), buChains);
                }
                catch (Exception ex)
                {
                    string msg = string.Format("Cannot generate biological unit file: {0}_{1}: {2}", pdbId, buId.ToString(), ex.Message);
                }
            }
            return(entryBuChainsHash);
        }
Esempio n. 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="buComponentInfoHash"></param>
        /// <param name="thisEntryCrystal"></param>
        /// <param name="needLigands"></param>
        /// <returns></returns>
        private Dictionary <string, Dictionary <string, AtomInfo[]> > BuildPdbBUs(string pdbId, Dictionary <string, Dictionary <string, List <SymOpMatrix> > > buComponentInfoHash, EntryCrystal thisEntryCrystal, bool needLigands)
        {
            Dictionary <string, Dictionary <string, AtomInfo[]> > entryBuChainAtomsHash = new Dictionary <string, Dictionary <string, AtomInfo[]> > ();

            foreach (string buId in buComponentInfoHash.Keys)
            {
                Dictionary <string, List <SymOpMatrix> > buChainSymMatrixHash = buComponentInfoHash[buId];
                Dictionary <string, AtomInfo[]>          buChainAtomsHash     = BuildOneBuAssembly(thisEntryCrystal, buChainSymMatrixHash, "pdb");
                entryBuChainAtomsHash.Add(buId, buChainAtomsHash);
            }
            return(entryBuChainAtomsHash);
        }
Esempio n. 19
0
        /// <summary>
        /// build a PDB biological unit
        /// by applying the symmetry operations provided in XML
        /// </summary>
        /// <param name="chainAtomsList">chains in XML</param>
        /// <param name="buGenStructList">symmetry operations</param>
        /// <param name="buSymmetryMatrixList">symmetry matrix</param>
        /// <returns>biological units with corresponding chains</returns>
        /// </summary>
        private Dictionary <string, AtomInfo[]> BuildPdbBuByPdbSymOps(string pdbId, string biolUnitId, EntryCrystal thisEntryCrystal)
        {
            ChainAtoms[]  chainAtomsList  = thisEntryCrystal.atomCat.ChainAtomList;
            BuGenStruct[] buGenStructList = thisEntryCrystal.buGenCat.BuGenStructList;

            List <string>      symOpStrList     = new List <string> ();
            List <string>      fullSymOpStrList = new List <string> ();
            List <SymOpMatrix> symOpMatrixList  = new List <SymOpMatrix> ();

            for (int asymCount = 0; asymCount < buGenStructList.Length; asymCount++)
            {
                if (biolUnitId != buGenStructList[asymCount].biolUnitId)
                {
                    continue;
                }
                string asymId = buGenStructList[asymCount].asymId;
                foreach (ChainAtoms chain in chainAtomsList)
                {
                    if (chain.AsymChain == asymId)
                    {
                        // at this step, only consider polypeptide chains
                        if (chain.PolymerType == "polypeptide")
                        {
                            SymOpMatrix symOpMatrix =
                                thisEntryCrystal.buGenCat.FindSymOpMatrix(buGenStructList[asymCount].symOperId);
                            if (symOpMatrix == null)
                            {
                                fullSymOpStrList.Add(buGenStructList[asymCount].symmetryMatrix);
                                symOpStrList.Add(asymId + "_" + buGenStructList[asymCount].symmetryString);
                            }
                            else
                            {
                                if (symOpMatrix.symmetryString == "")
                                {
                                    // put the symmetry operator id if the symmetry string is empty
                                    symOpStrList.Add(asymId + "_" + buGenStructList[asymCount].symOperId);
                                }
                                else
                                {
                                    symOpStrList.Add(asymId + "_" + symOpMatrix.symmetryString);
                                }
                                symOpMatrixList.Add(symOpMatrix);
                            }
                            break;
                        }
                    }
                }
            }
            Dictionary <string, AtomInfo[]> buHash = null;

            string[] symOpStrings = new string[symOpStrList.Count];
            symOpStrList.CopyTo(symOpStrings);
            if (symOpMatrixList.Count > 0)
            {
                SymOpMatrix[] symOpMatrices = new SymOpMatrix[symOpMatrixList.Count];
                symOpMatrixList.CopyTo(symOpMatrices);
                buHash = BuildPdbBu(thisEntryCrystal, symOpStrings, symOpMatrices);
            }
            else if (fullSymOpStrList.Count > 0)
            {
                string[] fullSymmetryStrings = new string[fullSymOpStrList.Count];
                fullSymOpStrList.CopyTo(fullSymmetryStrings);
                buHash = BuildPdbBu(thisEntryCrystal, symOpStrings, fullSymmetryStrings);
            }
            return(buHash);
        }