Exemplo n.º 1
0
        /// <summary>
        /// check if there are same crystal forms for all groups
        /// </summary>
        public void CheckReduntCrystForms()
        {
            ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
            ProtCidSettings.progressInfo.currentOperationLabel = "Redundant crystal forms.";

            InitializeTables();
            InitializeDbTables();

            string queryString = string.Format("Select Distinct GroupSeqID From {0};",
                                               GroupDbTableNames.dbTableNames[GroupDbTableNames.HomoSeqInfo]);
            DataTable groupIdTable = ProtCidSettings.protcidQuery.Query(queryString);
            int       groupId      = 0;

            ProtCidSettings.progressInfo.totalStepNum      = groupIdTable.Rows.Count;
            ProtCidSettings.progressInfo.totalOperationNum = groupIdTable.Rows.Count;
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Detecting reduntdant crystal forms.");

            foreach (DataRow groupRow in groupIdTable.Rows)
            {
                ProtCidSettings.progressInfo.currentOperationNum++;
                ProtCidSettings.progressInfo.currentStepNum++;
                groupId = Convert.ToInt32(groupRow["GroupSeqID"].ToString());
                ProtCidSettings.progressInfo.currentFileName = groupId.ToString();

                CheckGroupReduntCrystForms(groupId);
                if (reduntCrystFormTable.Rows.Count > 0)
                {
                    dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, reduntCrystFormTable);
                    reduntCrystFormTable.Clear();
                }
            }
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
        }
Exemplo n.º 2
0
 public void ClassifyHomoEntries(string[] entryList)
 {
     InitializeTables();
     DeleteObsHomoGroupDataInDb(groupSeqNum);
     AddEntryDataToTable(entryList, groupSeqNum);
     RetrieveRepEntries();
     dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, HomoGroupTables.homoGroupTables);
     HomoGroupTables.ClearTables();
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="crcCodes"></param>
        public void  ImportHHalignments(string[] crcCodes)
        {
            string queryString = "";

            foreach (string crc in crcCodes)
            {
                queryString = string.Format("Select * From HHGlobal Where query = '{0}' OR hit = '{0}';", crc);
                DataTable hhalignmentTable = dbQuery.Query(remotePiscesDbConnect, queryString);
                hhalignmentTable.TableName = "hhglobal";
                dbInsert.InsertDataIntoDBtables(localMysqlDbConnect, hhalignmentTable);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        private void InsertHhAlignDataToDb(DataTable hhAlignmentTable)
        {
            int       rowCutoff       = 100;
            int       rowCount        = 0;
            DataTable subHhAlignTable = hhAlignmentTable.Clone();

            subHhAlignTable.TableName = hhAlignmentTable.TableName;
            for (int i = 0; i < hhAlignmentTable.Rows.Count; i++)
            {
                if (rowCount == rowCutoff)
                {
                    try
                    {
                        dbInsert.BatchInsertDataIntoDBtables(ProtCidSettings.alignmentDbConnection, subHhAlignTable);
                    }
                    catch
                    {
                        dbInsert.InsertDataIntoDBtables(ProtCidSettings.alignmentDbConnection, subHhAlignTable);
                    }
                    subHhAlignTable.Clear();
                    rowCount = 0;
                }
                DataRow newDataRow = subHhAlignTable.NewRow();
                newDataRow.ItemArray = hhAlignmentTable.Rows[i].ItemArray;
                subHhAlignTable.Rows.Add(newDataRow);
                rowCount++;
            }
            if (subHhAlignTable.Rows.Count > 0)
            {
                dbInsert.BatchInsertDataIntoDBtables(ProtCidSettings.alignmentDbConnection, subHhAlignTable);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// the domain alignments for representative domain interfaces
        /// </summary>
        public void GetDomainAlignments()
        {
            string queryString = string.Format("SELECT DISTINCT RelSeqID FROM {0}DomainInterfaces;",
                                               ProtCidSettings.dataType);
            DataTable seqIdTable     = ProtCidSettings.protcidQuery.Query(queryString);
            int       relSeqId       = -1;
            string    familyCode1    = "";
            string    familyCode2    = "";
            DataTable alignInfoTable = null;

            foreach (DataRow seqIdRow in seqIdTable.Rows)
            {
                relSeqId    = Convert.ToInt32(seqIdRow["RelSeqID"].ToString());
                familyCode1 = seqIdRow["Family1"].ToString().Trim();
                familyCode2 = seqIdRow["Family2"].ToString().Trim();
                if (familyCode1 == familyCode2)
                {
                    alignInfoTable = GetSameFamilyDomainAlignments(relSeqId, familyCode1);
                }
                else
                {
                    alignInfoTable = GetDifFamilyDomainAlignments(relSeqId, familyCode1, familyCode2);
                }
                dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, alignInfoTable);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="chainAtomsHash"></param>
        public void GetIntraChainDomainInterfaces(string pdbId, Dictionary <string, AtomInfo[]> chainAtomsHash)
        {
            string    queryString    = string.Format("Select * From PdbPfam Where PdbID = '{0}';", pdbId);
            DataTable domainDefTable = dbQuery.Query(ProtCidSettings.pdbfamDbConnection, queryString);

            int    domainInterfaceId = 1;
            string asymChain         = "";
            int    entityId          = -1;

            List <string> chainSymOpList = new List <string> (chainAtomsHash.Keys);

            chainSymOpList.Sort();
            foreach (string chainSymOpString in chainSymOpList)
            {
                asymChain = GetAsymChain(chainSymOpString);
                entityId  = asuInfoFinder.GetEntityIdForAsymChain(pdbId, asymChain);
                DataRow[] domainDefRows = domainDefTable.Select(string.Format("EntityID = '{0}'", entityId));
                if (domainDefRows.Length < 2)
                {
                    continue;
                }
                AtomInfo[] chainAtoms = (AtomInfo[])chainAtomsHash[chainSymOpString];

                Dictionary <long, AtomInfo[]> chainDomainAtomsHash = GetDomainAtoms(domainDefRows, chainAtoms);

                // the interacted domain pairs intra-chain
                string[] interactedDomainPairs = GetInteractedDomainPairs(chainDomainAtomsHash);

                // insert domain-domain interfaces into table
                InsertDataIntoTable(pdbId, asymChain, ref domainInterfaceId, interactedDomainPairs, domainDefTable);
            }
            dbInsert.InsertDataIntoDBtables(ProtCidSettings.buCompConnection, BuCompTables.intraChainDomainInterfaceTable);
        }
Exemplo n.º 7
0
        public void ParsePdbSwsFiles()
        {
            CreateDbRefTableStructures("sws");
            CreateDbRefTablesInDb("sws");

            string    chainFile            = Path.Combine(dataDir, "pdbsws_chain.txt");
            Hashtable entryEntityChainHash = new Hashtable();

            string[] addedEntryChains = ParsePdbSwsChainFile(chainFile, ref entryEntityChainHash);
            dbInsert.InsertDataIntoDBtables(dbRefTable);

            string residueFile = Path.Combine(dataDir, "pdbsws_res.txt");

            ParsePdbSwsResidueFile(residueFile, addedEntryChains, entryEntityChainHash);
            dbInsert.InsertDataIntoDBtables(dbRefSeqTable);
        }
Exemplo n.º 8
0
        /// <summary>
        /// update protbudbiolassemblies table
        /// </summary>
        /// <param name="entries"></param>
        public void UpdateProtBudBiolAssemblies(string[] entries)
        {
            Console.WriteLine("Retrieving biol units info");

            if (entries == null)
            {
                string entryFile = "ProtEntries.txt";
                entries = GetAsuEntries(parsedEntryFile, entryFile, true);
            }

            StreamWriter parsedEntryWriter = new StreamWriter(parsedEntryFile, true);

            DataTable buTable = null;

            foreach (string pdbId in entries)
            {
                if (isUpdate)
                {
                    DeleteObsoleteBuData(pdbId);
                }
                buTable = new DataTable(buTableName);
                buQuery.GetBiolUnitForPdbEntry(pdbId, "", "", ref buTable);
                UpdateBuTableNmrEMResolution(buTable);
                dbInsert.InsertDataIntoDBtables(ProtCidSettings.pdbfamDbConnection, buTable);

                parsedEntryWriter.WriteLine(pdbId);
                parsedEntryWriter.Flush();
            }
            parsedEntryWriter.Close();

            Console.WriteLine("Done!");
        }
Exemplo n.º 9
0
        /// <summary>
        /// insert redundant crystal forms summary info to db table
        /// </summary>
        public void UpdateCfGroupInfo()
        {
            InitializeDbTable();
            DataTable cfGroupTable = InitializeTable();

            Dictionary <int, Dictionary <int, List <string> > > familyReduntCfHash = GetRedundantCFs();

            /*		string queryString = string.Format ("Select Distinct GroupSeqID From {0};",
             *                      GroupDbTableNames.dbTableNames[GroupDbTableNames.SgInterfaces]);*/
            string queryString = string.Format("Select Distinct GroupSeqID From {0};",
                                               GroupDbTableNames.dbTableNames[GroupDbTableNames.HomoSeqInfo]);
            DataTable groupTable = ProtCidSettings.protcidQuery.Query(queryString);

            ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
            ProtCidSettings.progressInfo.totalStepNum          = groupTable.Rows.Count;
            ProtCidSettings.progressInfo.totalOperationNum     = groupTable.Rows.Count;
            ProtCidSettings.progressInfo.currentOperationLabel = "Update CF Info.";

            int groupId = 0;

            foreach (DataRow dRow in groupTable.Rows)
            {
                groupId = Convert.ToInt32(dRow["GroupSeqID"].ToString());
                ProtCidSettings.progressInfo.currentOperationNum++;
                ProtCidSettings.progressInfo.currentStepNum++;
                ProtCidSettings.progressInfo.currentFileName = groupId.ToString();

                GetNonReduntCfGroupsInFamily(groupId, familyReduntCfHash[groupId], ref cfGroupTable);
            }
            DbInsert dbInsert = new DbInsert();

            dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, cfGroupTable);
            //		DbBuilder.dbConnect.DisconnectFromDatabase ();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Compare cryst and bu interfaces for all entries in db
        /// </summary>
        public void CompareEntryCrystBuInterfaces()
        {
            Initialize();

            ProtCidSettings.progressInfo.ResetCurrentProgressInfo();

            //		string crystEntryQuery = "SELECT Distinct PdbID FROM CrystEntryInterfaces;";
            //		DataTable crystEntryTable = dbQuery.Query (crystEntryQuery);
            string[] nonBuCompEntries = GetNonBuCompEntries();
            //      string[] nonBuCompEntries = {"1v9t"};

            ProtCidSettings.progressInfo.currentOperationLabel = "Comparing Cryst BU Interface";
            ProtCidSettings.progressInfo.totalOperationNum     = nonBuCompEntries.Length;
            ProtCidSettings.progressInfo.totalStepNum          = nonBuCompEntries.Length;

#if DEBUG
            StreamWriter entryWriter = new StreamWriter("notInDbEntryList.txt", true);
#endif
            foreach (string pdbId in nonBuCompEntries)
            {
                ProtCidSettings.progressInfo.currentOperationNum++;
                ProtCidSettings.progressInfo.currentStepNum++;
                ProtCidSettings.progressInfo.currentFileName = pdbId;

                try
                {
                    CompareEntryCrystBuInterfaces(pdbId);
                }
                catch (Exception ex)
                {
                    ProtCidSettings.logWriter.WriteLine("Comparing " + pdbId + " cryst bu interfaces errors: " + ex.Message);
                    ProtCidSettings.logWriter.Flush();
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue("Comparing " + pdbId + " cryst bu interfaces errors: " + ex.Message);
                }

                dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, crystBuInterfaceCompTables);
                ClearTables();
            }
            try
            {
                Directory.Delete(ProtCidSettings.tempDir, true);
            }
            catch {}
#if DEBUG
            entryWriter.Close();
#endif
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entryBuInterfaceHashes"></param>
        public void ComapreEntryBuInterfaces(string pdbId, Dictionary <string, InterfaceChains[]>[] entryBuInterfaceHashes)
        {
            Dictionary <string, InterfacePairInfo[]> pdbPisaBuInterfaceCompHash = CompareEntryBuInterfaces(entryBuInterfaceHashes[(int)BuType.PDB], entryBuInterfaceHashes[(int)BuType.PISA]);

            InsertDataIntoTables(pdbId, pdbPisaBuInterfaceCompHash, "pdbpisa");

            dbInsert.InsertDataIntoDBtables(ProtCidSettings.buCompConnection, EntryBuCompTables.entryBuCompTables);
            EntryBuCompTables.ClearTables();
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        public void GetBuDomainContents(string pdbId, ref Dictionary <string, int> familyStringGroupIdHash)
        {
            Dictionary <string, Dictionary <int, List <string> > > buProtChainsHash = GetProtChainComponentForEntry(pdbId);

            if (buProtChainsHash.Count == 0)
            {
                return;
            }
            int    groupSeqId       = -1;
            string buFamilyString   = "";
            string protFamilyString = "";

            foreach (string buId in buProtChainsHash.Keys)
            {
                Dictionary <int, List <string> > buEntityChainsHash = buProtChainsHash[buId];
                buFamilyString = "";
                List <int> entityList = new List <int> (buEntityChainsHash.Keys);
                entityList.Sort();
                foreach (int entityId in entityList)
                {
                    List <string> chainCountList   = buEntityChainsHash[entityId];
                    string[]      chainCountFields = chainCountList[0].ToString().Split('_');
                    protFamilyString = GetPfamFamiliesInChain(pdbId, chainCountFields[0]);
                    if (protFamilyString == "")
                    {
                        continue;
                    }
                    buFamilyString += protFamilyString + ";";
                }
                buFamilyString = buFamilyString.TrimEnd(';');
                groupSeqId     = GetGroupSeqID(buFamilyString, ref familyStringGroupIdHash);
                AssignDataIntoTable(groupSeqId, pdbId, buId, buEntityChainsHash);
            }
            dbInsert.InsertDataIntoDBtables(ProtCidSettings.buCompConnection, groupTable);
            dbInsert.InsertDataIntoDBtables(ProtCidSettings.buCompConnection, buGroupTable);
            groupTable.Clear();
            buGroupTable.Clear();
        }
Exemplo n.º 13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="entityId"></param>
        public void UpdateEntryEntityDbRefData(string pdbId, nt entityId, ref int refId, ref int alignId)
        {
            string srcType = "";
            bool dbAccValid = true;
            string[] dbAccessions = GetUnpAccessions(pdbId, entityId, out srcType, true);
            try
            {
                dbAccValid = DoesEntityHaveValidDbAccessions(dbAccessions);
            }
            catch (Exception ex)
            {
                string stop = "";
            }
            if (dbAccValid && srcType != "")
            {
                updateLogWriter.WriteLine("Update " + pdbId + entityId.ToString () + " from " + srcType);
                // delete related data to this entity
                DeleteDbRefData(pdbId, entityId);
                totalNumOfEntitiesUpdated++;

                DataTable residueMapTable = GetEntityResidueMapTable(pdbId, entityId, srcType);
                UpdatePdbDbRefInfoFromDifSrc(residueMapTable, ref refId, ref alignId, srcType);
         /*       if (srcType == "ssmap")
                {
                    UpdatePdbDbRefFromSSmap(residueMapTable, ref refId, ref alignId);
                }
                else if (srcType == "sws")
                {
                    UpdatePdbDbRefFromSws(residueMapTable, ref refId, ref alignId);
                }
                */
                dbInsert.InsertDataIntoDBtables(dbRefTable);
                dbInsert.InsertDataIntoDBtables(dbRefSeqTable);
                dbRefTable.Clear();
                dbRefSeqTable.Clear();
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// update nonredundant cf group table
        /// </summary>
        public void UpdateCfGroupInfo(int[] updateGroups)
        {
            DataTable cfGroupTable = InitializeTable();

            Dictionary <int, Dictionary <int, List <string> > > familyReduntCfHash = GetRedundantCFs(updateGroups);

            foreach (int groupId in updateGroups)
            {
                GetNonReduntCfGroupsInFamily(groupId, familyReduntCfHash[groupId], ref cfGroupTable);
            }
            DeleteObsData(updateGroups);
            DbInsert dbInsert = new DbInsert();

            dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, cfGroupTable);
            //		DbBuilder.dbConnect.DisconnectFromDatabase ();
        }
Exemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="relSeqId"></param>
        private void AddPeptideInterfaceClusterSumInfo(string pfamId, DataTable clusterStatInfoTable)
        {
            string    queryString  = string.Format("Select Distinct ClusterID From PfamPepInterfaceClusters Where PfamID = '{0}';", pfamId);
            DataTable clusterTable = ProtCidSettings.protcidQuery.Query(queryString);

            int[]     pepRelSeqIds      = GetPfamPeptideRelSeqIds(pfamId);
            DataTable pepInterfaceTable = GetRelationPeptideInterfaceTable(pepRelSeqIds);
            DataTable pfamDomainTable   = GetPfamDomainTable(pfamId);
            int       clusterId         = 0;

            foreach (DataRow clusterRow in clusterTable.Rows)
            {
                clusterId = Convert.ToInt32(clusterRow["ClusterID"].ToString());
                GetClusterSumInfo(pfamId, clusterId, pepInterfaceTable, pfamDomainTable, clusterStatInfoTable);
            }
            dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, clusterStatInfoTable);
            clusterStatInfoTable.Clear();
        }
Exemplo n.º 16
0
        /// <summary>
        /// add the cfgroupid for those entries are not in the pfamgroups
        /// temporary added for the domain interface data, should discard later
        /// </summary>
        public void UpdateCfGroupInfoForDebug()
        {
            DbInsert dbInsert = new DbInsert();

            DataTable cfGroupTable = InitializeTable();
            Dictionary <int, string[]> updateGroupEntryHash = ReadUpdateEntries();
            List <int> groupIdList = new List <int> (updateGroupEntryHash.Keys);

            groupIdList.Sort();
            foreach (int groupId in groupIdList)
            {
                string[] updateEntries = updateGroupEntryHash[groupId];
                GetNonReduntCfGroupsInFamilyForDebug(groupId, updateEntries, ref cfGroupTable);

                dbInsert.InsertDataIntoDBtables(ProtCidSettings.protcidDbConnection, cfGroupTable);
                cfGroupTable.Clear();
            }
            //		DbBuilder.dbConnect.DisconnectFromDatabase ();
        }
Exemplo n.º 17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="domainInfo"></param>
 private void InsertDataIntoDbTable(PfamDomainInfo domainInfo)
 {
     if (isUpdate)
     {
         string deleteString = string.Format("Delete From {0}  Where PdbID = '{1}' AND DomainID = {2};",
                                             domainFileInfoTable.TableName, domainInfo.pdbId, domainInfo.domainId);
         dbQuery.Query(deleteString);
     }
     foreach (DomainSegmentInfo segInfo in domainInfo.segmentInfos)
     {
         DataRow fileInfoRow = domainFileInfoTable.NewRow();
         fileInfoRow["PdbId"]     = domainInfo.pdbId;
         fileInfoRow["DomainId"]  = domainInfo.domainId;
         fileInfoRow["EntityID"]  = segInfo.entityId;
         fileInfoRow["AsymChain"] = segInfo.asymChain;
         fileInfoRow["SeqStart"]  = segInfo.seqStart;
         fileInfoRow["SeqEnd"]    = segInfo.seqEnd;
         fileInfoRow["FileStart"] = segInfo.fileStart;
         fileInfoRow["FileEnd"]   = segInfo.fileEnd;
         domainFileInfoTable.Rows.Add(fileInfoRow);
     }
     dbInsert.InsertDataIntoDBtables(domainFileInfoTable);
     domainFileInfoTable.Clear();
 }
Exemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="pfamLigandTable"></param>
        private void RetrieveLigandChainInteractions(string pdbId, DataTable chainLigandTable)
        {
            string gzCoordXmlFile = Path.Combine(ProtCidSettings.dirSettings.coordXmlPath, pdbId + ".xml.gz");

            if (!File.Exists(gzCoordXmlFile))
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue(pdbId + ".xml.gz file not exist");
                return;
            }
            string coordXmlFile = ParseHelper.UnZipFile(gzCoordXmlFile, ProtCidSettings.tempDir);
            // read data from crystal xml file
            XmlSerializer xmlSerializer    = new XmlSerializer(typeof(EntryCrystal));
            FileStream    xmlFileStream    = new FileStream(coordXmlFile, FileMode.Open);
            EntryCrystal  thisEntryCrystal = (EntryCrystal)xmlSerializer.Deserialize(xmlFileStream);

            xmlFileStream.Close();
            File.Delete(coordXmlFile);

            // no coordinates for waters
            ChainAtoms[] chains           = thisEntryCrystal.atomCat.ChainAtomList;
            string[][]   chainLigandNames = GetChainLigandsNames(chains);
            string[]     protChainNames   = chainLigandNames[0]; // the list of protein chains
            string[]     ligandChainNames = chainLigandNames[1]; // the list of ligands, no DNA/RNA
            if (ligandChainNames.Length == 0)
            {
                return;
            }
            Dictionary <string, double> seqPairDistDict = new Dictionary <string, double>();

            foreach (string ligandChainName in ligandChainNames)
            {
                AtomInfo[] ligandAtoms = GetChainAtoms(chains, ligandChainName);
                foreach (string protChainName in protChainNames)
                {
                    AtomInfo[] protChainAtoms = GetChainAtoms(chains, protChainName);

                    Dictionary <string, AtomInfo[]> seqPairContactHash = CalculateAtomDistances(ligandAtoms, protChainAtoms, out seqPairDistDict);
                    foreach (string seqPair in seqPairDistDict.Keys)
                    {
                        string[]   seqIds         = seqPair.Split('_');
                        double     distance       = seqPairDistDict[seqPair];
                        AtomInfo[] atomPair       = seqPairContactHash[seqPair];
                        DataRow    chainLigandRow = chainLigandTable.NewRow();
                        chainLigandRow["PdbID"]  = pdbId;
                        chainLigandRow["AsymID"] = ligandChainName;
                        //    chainLigandRow["Ligand"] = ligandChainName;
                        chainLigandRow["ChainAsymID"]  = protChainName;
                        chainLigandRow["SeqID"]        = seqIds[0];
                        chainLigandRow["ChainSeqID"]   = seqIds[1];
                        chainLigandRow["Distance"]     = distance;
                        chainLigandRow["Atom"]         = atomPair[0].atomName;
                        chainLigandRow["ChainAtom"]    = atomPair[1].atomName;
                        chainLigandRow["Residue"]      = atomPair[0].residue;
                        chainLigandRow["ChainResidue"] = atomPair[1].residue;
                        chainLigandTable.Rows.Add(chainLigandRow);
                    }
                }
            }
            dbInsert.InsertDataIntoDBtables(ProtCidSettings.buCompConnection, chainLigandTable);
            chainLigandTable.Clear();
        }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entries"></param>
        public void PrintBiolAssembliesToFile(string[] entries)
        {
            ProtCidSettings.logWriter.WriteLine("Retrieving biol units info");

            string buFile          = "";
            bool   headerLineExist = false;

            if (entries == null)
            {
                string entryFile = "ProtEntries.txt";
                entries = GetAsuEntries(parsedEntryFile, entryFile, true);
                //        entries = GetMissingEntries();
                buFile = Path.Combine(ProtCidSettings.dirSettings.pfamPath, "biolAssemblies.txt");
            }
            else
            {
                buFile = Path.Combine(ProtCidSettings.dirSettings.pfamPath, "newbiolAssemblies.txt");
            }

            if (File.Exists(buFile))
            {
                headerLineExist = true;
            }

            StreamWriter fileWriter = new StreamWriter(buFile, true);

            if (!headerLineExist)
            {
                string headerLine = GetHeaderLine();
                fileWriter.WriteLine(headerLine);
            }

            StreamWriter parsedEntryWriter = new StreamWriter(parsedEntryFile, true);

            DataTable buTable = null;
            string    line    = "";

            foreach (string pdbId in entries)
            {
                if (isUpdate)
                {
                    DeleteObsoleteBuData(pdbId);
                }
                buTable = new DataTable(buTableName);
                buQuery.GetBiolUnitForPdbEntry(pdbId, "", "", ref buTable);
                dbInsert.InsertDataIntoDBtables(ProtCidSettings.pdbfamDbConnection, buTable);

                foreach (DataRow buRow in buTable.Rows)
                {
                    line = "";

                    foreach (object item in buRow.ItemArray)
                    {
                        line += item.ToString();
                        line += "\t";
                    }
                    fileWriter.WriteLine(line.TrimEnd('\t'));
                }
                fileWriter.Flush();
                parsedEntryWriter.WriteLine(pdbId);
                parsedEntryWriter.Flush();
            }
            fileWriter.Close();
            parsedEntryWriter.Close();

            ParseHelper.ZipPdbFile(buFile);

            ProtCidSettings.logWriter.WriteLine("Done!");
        }
Exemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataFile"></param>
        public void ParsePdbSwsFile(string dataFile)
        {
            CreateDataTableStructures("sws");
            CreateDbTable("sws");

            string       line = "";
            string       preUnpPdbChainString = "";
            string       unpPdbChainString    = "";
            string       prePdbChain          = "";
            string       pdbChain             = "";
            StreamReader dataReader           = new StreamReader(dataFile);
            string       pdbId                 = "";
            string       authorChain           = "";
            string       dbAccession           = "";
            ArrayList    seqNumList            = new ArrayList();
            ArrayList    pdbSeqList            = new ArrayList();
            ArrayList    authSeqNumList        = new ArrayList();
            ArrayList    unpSeqList            = new ArrayList();
            ArrayList    unpSeqNumList         = new ArrayList();
            int          totalNumOfRowsInTable = 10000;
            int          numOfRowsInTable      = 0;
            //       int numOfRowsInDb = 0;
            Hashtable entryEntityHash = new Hashtable();

            while ((line = dataReader.ReadLine()) != null)
            {
                string[] fields = ParseHelper.SplitPlus(line, ' ');
                pdbChain = fields[0] + fields[1];
                if (fields.Length == 8)
                {
                    unpPdbChainString = fields[0] + fields[1] + fields[5];
                }

                if (preUnpPdbChainString == "")
                {
                    preUnpPdbChainString = unpPdbChainString;
                }
                if (prePdbChain == "")
                {
                    prePdbChain = pdbChain;
                }
                if (prePdbChain != pdbChain)
                {
                    unpPdbChainString    = "";
                    preUnpPdbChainString = "";
                }
                if (preUnpPdbChainString != unpPdbChainString || prePdbChain != pdbChain)
                {
                    /*       numOfRowsInDb++;
                     *     if (numOfRowsInDb <= 60000)
                     *     {
                     *         continue;
                     *     }*/
                    DataRow dataRow = pdbUnpDbTable.NewRow();
                    dataRow["PdbID"]            = pdbId;
                    dataRow["AuthorChain"]      = authorChain;
                    dataRow["EntityID"]         = GetEntityIDForAuthorChain(pdbId, authorChain, ref entryEntityHash);
                    dataRow["DbAccession"]      = dbAccession;
                    dataRow["PdbSequence"]      = pdbSeqList.ToString();
                    dataRow["AuthorSeqNumbers"] = FormatArrayListToString(authSeqNumList);
                    dataRow["SeqNumbers"]       = FormatArrayListToString(seqNumList);
                    dataRow["UnpSequence"]      = unpSeqList.ToString();
                    dataRow["unpSeqNumbers"]    = FormatArrayListToString(unpSeqNumList);
                    //     dbInsert.InsertDataIntoDb(dataRow);
                    pdbUnpDbTable.Rows.Add(dataRow);

                    numOfRowsInTable++;

                    if (numOfRowsInTable == totalNumOfRowsInTable)
                    {
                        dbInsert.InsertDataIntoDBtables(pdbUnpDbTable);
                        pdbUnpDbTable.Clear();
                        numOfRowsInTable = 0;
                    }

                    pdbSeqList.Clear();
                    authSeqNumList.Clear();
                    seqNumList.Clear();
                    unpSeqList.Clear();
                    unpSeqNumList.Clear();
                }
                pdbId                = fields[0];
                authorChain          = fields[1];
                preUnpPdbChainString = unpPdbChainString;
                prePdbChain          = pdbChain;
                seqNumList.Add(fields[2]);
                pdbSeqList.Add(threeToOne(fields[3]));
                authSeqNumList.Add(fields[4]);
                if (fields.Length < 8)
                {
                    unpSeqList.Add("-");
                    unpSeqNumList.Add("-");
                }
                else
                {
                    dbAccession = fields[5];
                    unpSeqList.Add(fields[6]);
                    unpSeqNumList.Add(fields[7]);
                }
            }
            dataReader.Close();
            if (pdbUnpDbTable.Rows.Count > 0)
            {
                dbInsert.InsertDataIntoDBtables(pdbUnpDbTable);
                pdbUnpDbTable.Clear();
            }
        }
Exemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        public InterfaceChains[] FindUniqueInterfaces(string pdbId, bool isUpdate)
        {
            string spaceGroup = GetEntrySpaceGroup(pdbId);

            string xmlFile = Path.Combine(ProtCidSettings.dirSettings.coordXmlPath, pdbId + ".xml.gz");

            if (!Directory.Exists(ProtCidSettings.tempDir))
            {
                Directory.CreateDirectory(ProtCidSettings.tempDir);
            }
            string coordXmlFile = ParseHelper.UnZipFile(xmlFile, ProtCidSettings.tempDir);

            InterfaceChains[] entryInterfaces       = null;
            AsuInterfaces     asuInterfacesNonCryst = new AsuInterfaces();

            try
            {
                if (spaceGroup == "NMR")
                {
                    entryInterfaces = asuInterfacesNonCryst.GetAsuInterfacesFromXml(coordXmlFile);
                    if (entryInterfaces == null)
                    {
                        ProtCidSettings.progressInfo.progStrQueue.Enqueue("NMR entry " + pdbId + " is a monomer.");
#if DEBUG
                        ProtCidSettings.logWriter.WriteLine("NMR entry " + pdbId + " is a monomer.");
                        ProtCidSettings.logWriter.Flush();
#endif
                    }
                }
                else
                {
                    ContactInCrystal contactInCrystal = new ContactInCrystal();
                    int numOfChainsInUnitCell         = contactInCrystal.FindInteractChains(coordXmlFile);

                    if (numOfChainsInUnitCell > 64)
                    {
                        ProtCidSettings.progressInfo.progStrQueue.Enqueue("The number of chains of " + pdbId + " in a unit cell: " + numOfChainsInUnitCell.ToString());
#if DEBUG
                        ProtCidSettings.logWriter.WriteLine("The number of chains of " + pdbId + " in a unit cell: " + numOfChainsInUnitCell.ToString());
                        ProtCidSettings.logWriter.Flush();
#endif
                    }

                    if (contactInCrystal.InterfaceChainsList == null)
                    {
                        ProtCidSettings.progressInfo.progStrQueue.Enqueue("No interfaces exist in entry: " + pdbId);
                    }
                    entryInterfaces = contactInCrystal.InterfaceChainsList;
                }
                AssignEntryInterfacesToTable(entryInterfaces, pdbId, spaceGroup);
                AssignEntryInterfaceCompToTable(pdbId, entryInterfaces);

                if (isUpdate)
                {
                    DeleteObsData(pdbId);
                }

                dbInsert.InsertDataIntoDBtables
                    (ProtCidSettings.protcidDbConnection, CrystInterfaceTables.crystInterfaceTables[CrystInterfaceTables.CrystEntryInterfaces]);
                dbInsert.InsertDataIntoDBtables
                    (ProtCidSettings.protcidDbConnection, CrystInterfaceTables.crystInterfaceTables[CrystInterfaceTables.EntryInterfaceComp]);


                CrystInterfaceTables.crystInterfaceTables[CrystInterfaceTables.CrystEntryInterfaces].Clear();
                CrystInterfaceTables.crystInterfaceTables[CrystInterfaceTables.EntryInterfaceComp].Clear();
            }
            catch (Exception ex)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Retrieving interfaces from " + pdbId + " errors: " + ex.Message);
#if DEBUG
                ProtCidSettings.logWriter.WriteLine("Retrieving interfaces from " + pdbId + " errors: " + ex.Message);
                ProtCidSettings.logWriter.Flush();
#endif
            }
            finally
            {
                if (File.Exists(coordXmlFile))
                {
                    File.Delete(coordXmlFile);
                }
            }
            return(entryInterfaces);
        }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="relSeqId"></param>
        public void CompareBuDomainInterfaces(int relSeqId)
        {
            bool isIndividualRelation = false;

#if DEBUG
            if (dataWriter == null)
            {
                dataWriter           = new StreamWriter(BuCompBuilder.BuType + "DomainInterfaceComp" + relSeqId.ToString() + ".txt");
                isIndividualRelation = true;

                ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
                ProtCidSettings.progressInfo.currentOperationLabel = "Compare Domain Interfaces";
            }
#endif
            if (domainInterfaceCompTable == null)
            {
                InitializeTable();
            }

            string tableName = "";
            if (BuCompBuilder.BuType == "asu")
            {
                tableName = BuCompBuilder.BuType + "PfamDomainInterfaces";
            }
            else
            {
                tableName = BuCompBuilder.BuType + "PfamBuDomainInterfaces";
            }
            string queryString = string.Format("Select Distinct PdbID From {0} Where RelSeqID = {1};",
                                               tableName, relSeqId);
            DataTable relEntryTable = dbQuery.Query(ProtCidSettings.buCompConnection, queryString);

            string pdbId = "";
            Dictionary <string, Dictionary <string, DomainInterface[]> > entryBuDomainInterfaceHash = new Dictionary <string, Dictionary <string, DomainInterface[]> > ();
            ProtCidSettings.progressInfo.progStrQueue.Enqueue(relSeqId.ToString());

            if (isIndividualRelation)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Retrieving domain interfaces for each entry.");

                ProtCidSettings.progressInfo.totalOperationNum = relEntryTable.Rows.Count;
                ProtCidSettings.progressInfo.totalStepNum      = relEntryTable.Rows.Count;
            }
            foreach (DataRow entryRow in relEntryTable.Rows)
            {
                pdbId = entryRow["PdbID"].ToString();
                ProtCidSettings.progressInfo.currentFileName = pdbId;
                if (isIndividualRelation)
                {
                    ProtCidSettings.progressInfo.currentOperationNum++;
                    ProtCidSettings.progressInfo.currentStepNum++;
                }
                Dictionary <string, DomainInterface[]> buDomainInterfaceHash = domainInterfaceRetriever.RetrieveDomainInterfaces(relSeqId, pdbId, BuCompBuilder.BuType);
                entryBuDomainInterfaceHash.Add(pdbId, buDomainInterfaceHash);
            }

            List <string> entryList = new List <string> (entryBuDomainInterfaceHash.Keys);
            entryList.Sort();
            if (isIndividualRelation)
            {
                ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
                ProtCidSettings.progressInfo.totalOperationNum = (int)((double)(entryList.Count * (entryList.Count - 1)) / 2.0);
                ProtCidSettings.progressInfo.totalStepNum      = (int)((double)(entryList.Count * (entryList.Count - 1)) / 2.0);

                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Compare Domain-domain interfaces in BUs.");
            }
            for (int i = 0; i < entryList.Count; i++)
            {
                Dictionary <string, DomainInterface[]> buDomainInterfacesHash1 = entryBuDomainInterfaceHash[entryList[i]];
                for (int j = i + 1; j < entryList.Count; j++)
                {
                    if (isIndividualRelation)
                    {
                        ProtCidSettings.progressInfo.currentFileName = entryList[i].ToString() + "_" + entryList[j].ToString();
                        ProtCidSettings.progressInfo.currentOperationNum++;
                        ProtCidSettings.progressInfo.currentStepNum++;
                    }

                    if (IsEntryCompExisting(entryList[i].ToString(), entryList[j].ToString()))
                    {
                        continue;
                    }
                    ProtCidSettings.progressInfo.currentFileName = entryList[i].ToString() + "_" + entryList[j].ToString();

                    Dictionary <string, DomainInterface[]> buDomainInterfacesHash2 = entryBuDomainInterfaceHash[entryList[j]];
                    foreach (string buId1 in buDomainInterfacesHash1.Keys)
                    {
                        DomainInterface[] domainInterfaces1 = (DomainInterface[])buDomainInterfacesHash1[buId1];
                        foreach (string buId2 in buDomainInterfacesHash2.Keys)
                        {
                            DomainInterface[]         domainInterfaces2 = (DomainInterface[])buDomainInterfacesHash2[buId2];
                            DomainInterfacePairInfo[] compPairInfos     =
                                domainInterfaceComp.CompareDomainInterfaces(domainInterfaces1, domainInterfaces2);
                            InsertDataToTable(relSeqId, entryList[i].ToString(), entryList[j].ToString(),
                                              buId1, buId2, compPairInfos);
                        }
                    }
#if DEBUG
                    WriteCompDataToFile(domainInterfaceCompTable);
#endif
                    dbInsert.InsertDataIntoDBtables(ProtCidSettings.buCompConnection, domainInterfaceCompTable);
                    domainInterfaceCompTable.Clear();
                }
            }
            if (isIndividualRelation)
            {
#if DEBUG
                dataWriter.Close();
#endif
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
            }
        }