示例#1
0
        /// <summary>
        /// update entry-related data
        /// it is not necessary to recompute entry data from scratch
        /// </summary>
        /// <param name="updateEntries"></param>
        public void UpdateEntryInterfaceData(string[] updateEntries)
        {
            DbBuilderHelper.Initialize();
            if (updateEntries == null)
            {
                //              string lsFile = @"D:\Qifang\ProjectData\DbProjectData\PDB\newls-pdb_entry.txt";
                //               updateEntries = GetUpdateEntries(lsFile);
                updateEntries = GetUpdateEntries();
            }

            ProtCidSettings.logWriter.WriteLine("1. Compute interfaces from crystals");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("1. Compute interfaces from crystals");
            CrystInterfaceBuilder interfaceBuilder = new CrystInterfaceBuilder();

            interfaceBuilder.ComputeEntryCrystInterfaces(updateEntries);
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.logWriter.WriteLine("2. Generate interface files, calculate ASA and contacts in interfaces");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("2. Generate interface files, calculate ASA and contacts in interfaces");
            interfaceBuilder.GenerateEntryInterfaceFiles(updateEntries);
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.logWriter.WriteLine("3. Compare cryst interfaces with PDB/PISA BU and ASU Interfaces");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("3. Compare cryst interfaces with PDB/PISA BU and ASU Interfaces");
            // compare cryst interfaces and BU interfaces for each entry
            EntryCrystBuInterfaceComp crystBuInterfaceComp = new EntryCrystBuInterfaceComp();

            crystBuInterfaceComp.UpdateEntryCrystBuInterfaces(updateEntries);
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");

            ProtCidSettings.logWriter.WriteLine("4. Update crc-crc hh alignments");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("4. Update crc-crc hh alignments");
            Alignments.GroupEntryAlignments groupAlignment = new InterfaceClusterLib.Alignments.GroupEntryAlignments();
            groupAlignment.UpdateCrcHhAlignments();
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
            DbBuilderHelper.UpdateIndexes("CrystBuInterfaceComp", ProtCidSettings.protcidDbConnection);
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.progressInfo.currentOperationIndex++;
        }
示例#2
0
        public void PrintNonAlignedPairsFile()
        {
            DbBuilderHelper.Initialize();

            StreamReader  dataReader             = new StreamReader("RepEntriesInterGroupCompLog.txt");
            StreamWriter  dataWriter             = new StreamWriter("NonAlignedPairs.txt");
            StreamWriter  noInterfaceEntryWriter = new StreamWriter("NoInterfaceEntries.txt");
            string        line = "";
            List <string> noInterfaceEntryList = new List <string> ();

            while ((line = dataReader.ReadLine()) != null)
            {
                if (line.IndexOf("not aligned pair") > -1)
                {
                    string[] fields        = line.Split(' ');
                    string[] entityChains1 = GetPolypeptideChains(fields[1]);
                    string[] entityChains2 = GetPolypeptideChains(fields[3]);
                    foreach (string entityChain1 in entityChains1)
                    {
                        foreach (string entityChain2 in entityChains2)
                        {
                            dataWriter.WriteLine(fields[1] + entityChain1 + "\t" + fields[3] + entityChain2);
                        }
                    }
                }
                else
                {
                    int index = line.IndexOf("no cryst interfaces");
                    if (index > -1)
                    {
                        string pdbId = line.Substring(index - 5, 4);
                        if (!noInterfaceEntryList.Contains(pdbId))
                        {
                            noInterfaceEntryList.Add(pdbId);
                            noInterfaceEntryWriter.WriteLine(pdbId);
                        }
                    }
                }
            }
            dataReader.Close();
            dataWriter.Close();
            noInterfaceEntryWriter.Close();
        }
		private SchemaObjectCollection LoadAURolesInner(string[] unitIds, string[] schemaRoleIDs, bool normalOnly, DateTime timePoint)
		{
			string sql = @"SELECT O.* FROM SC.SchemaObject O INNER JOIN SC.AURoleSnapshot S
ON O.ID = S.ID AND O.VersionStartTime = S.VersionStartTime AND O.SchemaType = S.SchemaType
INNER JOIN SC.SchemaMembers R ON O.ID = R.MemberID AND O.SchemaType = R.MemberSchemaType
 WHERE";
			IConnectiveSqlClause inBuilder = DbBuilderHelper.In("S.SchemaRoleID", schemaRoleIDs);

			IConnectiveSqlClause inBuilder2 = DbBuilderHelper.In("R.ContainerID", unitIds);

			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();

			if (normalOnly) where.NormalFor("O.Status").NormalFor("R.Status");

			var timeCondition1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "S.");
			var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "O.");

			sql += new ConnectiveSqlClauseCollection(timeCondition1, timeCondition2, where, inBuilder, inBuilder2).ToSqlString(TSqlBuilder.Instance);

			return LoadSchemaObjects(sql);
		}
示例#4
0
        /// <summary>
        ///
        /// </summary>
        public void UpdatePfamChainClusterFiles()
        {
            ProtCidSettings.dataType = "pfam";

            DbBuilderHelper.Initialize();
            ProtCidSettings.progressInfo.Reset();

            //           int[] updateSuperGroups = GetUpdateClusterChainGroups ();
            int[] updateSuperGroups = { 3171, 9125, 13844, 16380, 28272, 29578 };
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating super groups clustering.");
            ChainInterfaceCluster interfaceCluster = new ChainInterfaceCluster();

            interfaceCluster.UpdateSuperGroupClusters(updateSuperGroups);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating the summary data.");
            ChainClusterStat superClusterStat = new ChainClusterStat();

            superClusterStat.UpdateSupergroupInterfaceClustersSumInfo(updateSuperGroups, "pfam", true);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating tar interface files.");
            InterfaceFilesReverser interfaceFileReverse = new InterfaceFilesReverser();
            string updateClusterReverseFileList         = interfaceFileReverse.ReverseClusterInterfaceFiles(updateSuperGroups);

            string updateClusterReverseFileList1     = "ReverseInterfacesInCluster.txt";
            ChainClusterCompress clusterFileCompress = new ChainClusterCompress();

            clusterFileCompress.CompressGroupClusterInterfaceFiles(updateSuperGroups, updateClusterReverseFileList1);
            clusterFileCompress.UpdateCrystInterfaceFilesNotInClusters(false);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating sequence files.");
            SeqFastaGenerator seqFastaGen = new SeqFastaGenerator();

            seqFastaGen.UpdateSeqFastaFiles(updateSuperGroups);

            InterfaceImageGen imageGen = new InterfaceImageGen();

            imageGen.UpdateClusterInterfaceImages(updateSuperGroups);
        }
示例#5
0
        public void ClusterPkinaseInterfaces()
        {
            ProtCidSettings.dataType = "pfam";
            DbBuilderHelper.Initialize();

            string pfamId = "";

            string[] pkinaseEntries  = null;
            string   groupArchString = "";
            int      userGroupSeqId  = 111111;

            pfamId          = "Pkinase";
            pkinaseEntries  = GetPfamEntries(pfamId);
            groupArchString = pfamId;
            userGroupSeqId  = 111111;
            chainRelInterfaceBuilder.FindInterfaceClustersInUserGroup(groupArchString, userGroupSeqId, pkinaseEntries);

            pfamId          = "Pkinase_Tyr";
            pkinaseEntries  = GetPfamEntries(pfamId);
            groupArchString = pfamId;
            userGroupSeqId  = userGroupSeqId + 1;
            chainRelInterfaceBuilder.FindInterfaceClustersInUserGroup(groupArchString, userGroupSeqId, pkinaseEntries);
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateChainInterfaceQscores()
        {
            ProtCidSettings.dataType = "pfam";

            DbBuilderHelper.Initialize();
            ProtCidSettings.progressInfo.Reset();
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating Q scores of SuperGroups");

            ChainGroupRepEntryComp interGroupRepEntryComp = new ChainGroupRepEntryComp();

            interGroupRepEntryComp.CompareMissingEntryPairs();

/*
 *          ProtCidSettings.logWriter.WriteLine(DateTime.Today.ToShortTimeString());
 *          ProtCidSettings.logWriter.WriteLine("Updating Q scores of chain interfaces in  chain groups.");
 *          ProtCidSettings.logWriter.Flush();
 *
 *          Hashtable updatedGroupHash = GetUpdatedGroups();
 *          Hashtable updateSuperGroupHash = null;
 *
 *          if (updateSuperGroupHash == null)
 *          {
 *              updateSuperGroupHash = new Hashtable();
 *              StreamReader dataReader = new StreamReader("UpdateSuperGroups.txt");
 *              string line = "";
 *              int superGroupId = -1;
 *              Hashtable updateGroupEntryHash = null;
 *              while ((line = dataReader.ReadLine()) != null)
 *              {
 *                  if (line == "")
 *                  {
 *                      continue;
 *                  }
 *                  if (line.Substring(0, 1) == "#")
 *                  {
 *                      if (superGroupId != -1)
 *                      {
 *                          updateSuperGroupHash.Add(superGroupId, updateGroupEntryHash);
 *                      }
 *                      superGroupId = Convert.ToInt32(line.Substring(1, line.Length - 1));
 *                      updateGroupEntryHash = new Hashtable();
 *                  }
 *                  if (line.IndexOf(":") > -1)
 *                  {
 *                      string[] fields = line.Split(':');
 *                      string[] entries = fields[1].Split(',');
 *                      updateGroupEntryHash.Add(Convert.ToInt32(fields[0]), entries);
 *                  }
 *              }
 *              if (superGroupId > -1)
 *              {
 *                  updateSuperGroupHash.Add(superGroupId, updateGroupEntryHash);
 *              }
 *              dataReader.Close();
 *          }
 *          ArrayList updateSuperGroupList = new ArrayList(updateSuperGroupHash.Keys);
 *          updateSuperGroupList.Sort();
 *          int[] updateSuperGroups = new int[updateSuperGroupList.Count];
 *          updateSuperGroupList.CopyTo(updateSuperGroups);
 *
 *          // number of calculations in the order: 189798, 2812822, 331348, 287770, 102644, 372940, 124384
 *          int[] excludedChainGroups = { 7, 744, 762, 1379, 1620, 4116, 4949 };
 *
 *          ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating the interface comparisons between groups.");
 *          ChainGroupRepEntryComp interGroupRepEntryComp = new ChainGroupRepEntryComp();
 *  //        interGroupRepEntryComp.UpdateEntryComparisonInSuperGroups(updateSuperGroupHash);
 *          int bigChainGroupId = 4949;
 *          interGroupRepEntryComp.UpdateEntryComparisonInSuperGroup (updateSuperGroupHash, bigChainGroupId);*/
        }
示例#7
0
        public void BuildChainInterfaceClusters(int operationStep)
        {
            ProtCidSettings.dataType = "pfam";

            DbBuilderHelper.Initialize();
            switch (operationStep)
            {
            case 1:
                try
                {
                    ChainGroupsClassifier chainGroupClassifier = new ChainGroupsClassifier();
                    chainGroupClassifier.CombineFamilyGroups();
                }
                catch (Exception ex)
                {
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue("Classify chain relations error: " +
                                                                      ex.Message);
                    ProtCidSettings.logWriter.WriteLine("Classify chain relations error: " +
                                                        ex.Message);
                    ProtCidSettings.logWriter.Flush();
                }

                break;
            //     goto case 2;


            case 2:
                ChainGroupRepEntryComp interGroupRepEntryComp = new ChainGroupRepEntryComp();
                interGroupRepEntryComp.CompareTwoEntries("5uvz", "2dww");
                interGroupRepEntryComp.CompareInterGroupRepEntryInterfacesInChainGroups();
                //     interGroupRepEntryComp.PrintMissingAlignInterGroupRepEntries();

                Alignments.GroupEntryAlignments groupAlign = new Alignments.GroupEntryAlignments();
                groupAlign.GetRepChainPairsToBeAligned();

                //             interGroupRepEntryComp.CompareMissingEntryPairs();
                break;
            //  goto case 3;

            case 3:
                ChainInterfaceCluster interfaceCluster = new ChainInterfaceCluster();
                interfaceCluster.ClusterChainGroupInterfaces();

                /*    int[] abSuperGroupIds = { 744};
                 *  interfaceCluster.UpdateSuperGroups(abSuperGroupIds);  */
                break;
            //       goto case 4;

            case 4:
                ChainClusterStat superClusterStat = new ChainClusterStat();
//                    superClusterStat.PrintChainClusterTextFilesFromDb ();
                superClusterStat.PrintSupergroupInterfaceClusters("pfam");
                //    goto case 5;
                break;

            case 5:
                InterfaceFilesReverser interfaceFileReverse = new InterfaceFilesReverser();
                //    interfaceFileReverse.UpdateIsSymmetry();
                string clusterReverseFileList = interfaceFileReverse.ReverseClusterInterfaceFiles();
#if DEBUG
                /////////////////////////////////////
                // the clusterReverseFileList is still a problem, file not exist exception, probably due to change the current directory
                // but I can not detect where the problem is.
                // should fix it.
                ////////////////////////////////////
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("The current working directory: " + System.Environment.CurrentDirectory);
                ProtCidSettings.logWriter.WriteLine("The current working directory: " + System.Environment.CurrentDirectory);
                FileInfo fileInfo = new FileInfo(clusterReverseFileList);
                ProtCidSettings.logWriter.WriteLine("The directory of clusterReverseFileList file: " + fileInfo.DirectoryName);
#endif

                clusterReverseFileList = Path.Combine(ProtCidSettings.applicationStartPath, clusterReverseFileList);
                ChainClusterCompress clusterFileCompress = new ChainClusterCompress();
                clusterFileCompress.CompressClusterInterfaceFiles(clusterReverseFileList);
                // copy the interface files for those not in any clusters
                // save disk space in the web server
                clusterFileCompress.RetrieveCrystInterfaceFilesNotInClusters(false);

                InterfaceImageGen imageGen = new InterfaceImageGen();
                imageGen.GenerateInterfaceImages();

                //   goto case 6;
                break;

            case 6:
                SeqFastaGenerator seqFastaGen = new SeqFastaGenerator();
                seqFastaGen.WriteSequencesToFastaFiles();
                break;
            //   goto case 7;

            case 7:
                BiolUnitSumInfo buSumInfo = new BiolUnitSumInfo();
                //             buSumInfo.UpdateBiolUnits();
                buSumInfo.RetrieveBiolUnits();
                break;

            default:
                break;
            }
            DbBuilderHelper.UpdateIndexes("PfamSuper", ProtCidSettings.protcidDbConnection);

            ProtCidSettings.progressInfo.threadFinished = true;
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateChainInterfaceClusters()
        {
            ProtCidSettings.dataType = "pfam";

            DbBuilderHelper.Initialize();
            ProtCidSettings.progressInfo.Reset();
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating PFAM SuperGroup Interfaces Data.");

            //          ChainClusterStat clusterStat = new ChainClusterStat();
            //          clusterStat.UpdateMinSeqIdentityInDb();

            ProtCidSettings.logWriter.WriteLine(DateTime.Today.ToShortTimeString());
            ProtCidSettings.logWriter.WriteLine("Updating PFAM SuperGroup Interfaces Data.");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Update biological units and entrypfamarch data for protcid");

            Dictionary <int, string[]> updatedGroupHash = GetUpdatedGroups();
            Dictionary <int, Dictionary <int, string[]> > updateSuperGroupHash = null;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating Super Groups.");
//            ChainGroupsClassifier superGroupClassifier = new ChainGroupsClassifier();
//            updateSuperGroupHash = superGroupClassifier.UpdateFamilySuperGroups(updatedGroupHash);

            if (updateSuperGroupHash == null)
            {
                updateSuperGroupHash = new Dictionary <int, Dictionary <int, string[]> > ();
                StreamReader dataReader   = new StreamReader("UpdateSuperGroups.txt");
                string       line         = "";
                int          superGroupId = -1;
                Dictionary <int, string[]> updateGroupEntryHash = null;
                while ((line = dataReader.ReadLine()) != null)
                {
                    if (line == "")
                    {
                        continue;
                    }
                    if (line.Substring(0, 1) == "#")
                    {
                        if (superGroupId != -1)
                        {
                            updateSuperGroupHash.Add(superGroupId, updateGroupEntryHash);
                        }
                        superGroupId         = Convert.ToInt32(line.Substring(1, line.Length - 1));
                        updateGroupEntryHash = new Dictionary <int, string[]> ();
                    }
                    if (line.IndexOf(":") > -1)
                    {
                        string[] fields  = line.Split(':');
                        string[] entries = fields[1].Split(',');
                        updateGroupEntryHash.Add(Convert.ToInt32(fields[0]), entries);
                    }
                }
                if (superGroupId > -1)
                {
                    updateSuperGroupHash.Add(superGroupId, updateGroupEntryHash);
                }
                dataReader.Close();
            }
            List <int> updateSuperGroupList = new List <int> (updateSuperGroupHash.Keys);

            updateSuperGroupList.Sort();
            int[] updateSuperGroups = new int[updateSuperGroupList.Count];
            updateSuperGroupList.CopyTo(updateSuperGroups);

            string[] updateEntries = GetUpdateEntries(updateSuperGroupHash);

            // clear the any existing file to make sure the file containing only those from
            // the comparison between groups.
            string nonAlignedPairFile = "NonAlignedEntryPairs.txt";

            if (File.Exists(nonAlignedPairFile))
            {
                // before delete, make a copy
                File.Copy(nonAlignedPairFile, Path.Combine(ProtCidSettings.dirSettings.fatcatPath, nonAlignedPairFile), true);
                File.Delete(nonAlignedPairFile);
            }

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating the interface comparisons between groups.");
            ChainGroupRepEntryComp interGroupRepEntryComp = new ChainGroupRepEntryComp();

            interGroupRepEntryComp.UpdateEntryComparisonInSuperGroups(updateSuperGroupHash);
            //        interGroupRepEntryComp.CompareMissingEntryPairs();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating super groups clustering.");
            ChainInterfaceCluster interfaceCluster = new ChainInterfaceCluster();

            interfaceCluster.UpdateSuperGroupClusters(updateSuperGroups);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating the summary data.");
            ChainClusterStat superClusterStat = new ChainClusterStat();

            superClusterStat.UpdateSupergroupInterfaceClustersSumInfo(updateSuperGroups, updateEntries, "pfam", true);
//            superClusterStat.UpdateProtCidChainMetaData("pfam", updateEntries, updateSuperGroups);


            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating tar interface files.");
            InterfaceFilesReverser interfaceFileReverse = new InterfaceFilesReverser();
            string updateClusterReverseFileList         = interfaceFileReverse.ReverseClusterInterfaceFiles(updateSuperGroupHash);

            //       string updateClusterReverseFileList = "ReverseInterfacesInCluster.txt";
            updateClusterReverseFileList = Path.Combine(ProtCidSettings.applicationStartPath, updateClusterReverseFileList);

            //          string updateClusterReverseFileList = "ReverseInterfacesInCluster.txt";
            ChainClusterCompress clusterFileCompress = new ChainClusterCompress();

            clusterFileCompress.CompressGroupClusterInterfaceFiles(updateSuperGroups, updateClusterReverseFileList);
            clusterFileCompress.UpdateCrystInterfaceFilesNotInClusters(updateSuperGroups, false);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating sequence files.");
            ProtCidSettings.logWriter.WriteLine("Updating sequence files.");
            SeqFastaGenerator seqFastaGen = new SeqFastaGenerator();

            seqFastaGen.UpdateSeqFastaFiles(updateSuperGroups);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Update biological units and entrypfamarch data for protcid");
            ProtCidSettings.logWriter.WriteLine("Update biological units and entrypfamarch data for protcid");
            BiolUnitSumInfo buSumInfo = new BiolUnitSumInfo();

            buSumInfo.UpdateBiolUnits(updateEntries);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating cluster interface images.");
            ProtCidSettings.logWriter.WriteLine("Updating cluster interface images.");
            InterfaceImageGen imageGen = new InterfaceImageGen();

            imageGen.UpdateClusterInterfaceImages(updateSuperGroups);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating indexes for super groups tables");
            ProtCidSettings.logWriter.WriteLine("Updating indexes for super groups tables");
            DbBuilderHelper.UpdateIndexes("PfamSuper", ProtCidSettings.protcidDbConnection);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Update Done!");
            ProtCidSettings.progressInfo.threadFinished = true;
            ProtCidSettings.logWriter.Flush();
        }
示例#9
0
 public void AddSymmetryIndexes()
 {
     DbBuilderHelper.Initialize();
     ChainInterfaces.InterfaceSymmetry interfaceSym = new ChainInterfaces.InterfaceSymmetry();
     interfaceSym.CalculateInterfaceSymmetryJindex();
 }
示例#10
0
        /// <summary>
        /// build from current database by adding update/new pdb entries
        /// but rebuild entry-based groups due to new PFAM version
        /// regroup crystal forms
        /// </summary>
        public void BuildEntryInterfaceGroups(int step)
        {
            DbBuilderHelper.Initialize();
            ProtCidSettings.progressInfo.Reset();
            ProtCidSettings.progressInfo.totalOperationNum = 8;
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Building entry-based groups, includes 8 steps: ");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("1.Calculate entry interfaces");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("2. Generate interface files, calculate ASA.");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("3. Compare cryst interfaces with PDB/PQS/PISA BU and ASU Interfaces");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("4. Classify PDB entries into homologous groups");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("5. Retrieve chain alignments in groups");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("6. Calculate similarity Q scores in an entry group.");
            //     ProtCidSettings.progressInfo.progStrQueue.Enqueue("7. Compare interfaces of entries in entry groups.");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("7. Deal With Redundant Crystal Forms.");

            ProtCidSettings.logWriter.WriteLine(DateTime.Today.ToShortTimeString());
            ProtCidSettings.logWriter.WriteLine("Build entry-based group data.");

// update entry-related data, it is not necessary to recompute entry data from scratch
            string[] updateEntries = GetMissBuCompEntries();
            CrystInterfaceBuilder interfaceBuilder = new CrystInterfaceBuilder();

            switch (step)
            {
            case 1:
                ProtCidSettings.logWriter.WriteLine("1. Compute interfaces from crystals");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("1. Compute interfaces from crystals");
                interfaceBuilder.ComputeEntryCrystInterfaces(updateEntries);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                goto case 2;

            case 2:
                ProtCidSettings.logWriter.WriteLine("2. Generate interface files, calculate ASA and contacts in interfaces");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("2. Generate interface files, calculate ASA and contacts in interfaces");
                interfaceBuilder.GenerateEntryInterfaceFiles(updateEntries);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                break;

            case 3:
                ProtCidSettings.logWriter.WriteLine("3. Compare cryst interfaces with PDB/PISA BU and ASU Interfaces");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("3. Compare cryst interfaces with PDB/PISA BU and ASU Interfaces");
                // compare cryst interfaces and BU interfaces for each entry
                EntryCrystBuInterfaceComp crystBuInterfaceComp = new EntryCrystBuInterfaceComp();
                crystBuInterfaceComp.UpdateEntryCrystBuInterfaces(updateEntries);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
                DbBuilderHelper.UpdateIndexes("CrystBuInterfaceComp", ProtCidSettings.protcidDbConnection);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                break;

            case 4:
                // group entries, rebuild group tables: PfamHomoSeqInfo, PfamHomoGroupEntryAlign, PfamHomoRepEntryAlign
                ProtCidSettings.logWriter.WriteLine("4. Classify PDB entries into homologous groups.");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("4. Classify PDB entries into homologous groups");
                PfamEntryClassifier pfamClassifier = new PfamEntryClassifier();
                pfamClassifier.ClassifyPdbPfamGroups();
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
                DbBuilderHelper.UpdateIndexes("PFAMHOMO", ProtCidSettings.protcidDbConnection);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                break;

            case 5:
                // retrieve chain alignments from HH, and fatcat alignments
                ProtCidSettings.logWriter.WriteLine("5. Retrieve chain alignments in groups");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("5. Retrieve chain alignments in groups");
                Alignments.GroupEntryAlignments groupAlignment = new InterfaceClusterLib.Alignments.GroupEntryAlignments();
                groupAlignment.UpdateCrcHhAlignments();
                groupAlignment.RetrieveChainAlignmentsInGroups();
                //        groupAlignment.GetRepChainPairsToBeAligned();
                //       groupAlignment.GetRepEntryChainAlignFilesFromMissingEntityAlign();
                //        groupAlignment.UpdateFatcatAlignmentsFromFile("");
                //         int[] updateGroups = { 10400 };
                //         groupAlignment.UpdateGroupEntryAlignments (updateGroups);
                //         groupAlignment.UpdateMissingChainAlignmentsInGroups (null);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
                DbBuilderHelper.UpdateIndexes("PFAMHOMO", ProtCidSettings.protcidDbConnection);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                break;

            case 6:
                // compare entry interfaces in entry groups
                ProtCidSettings.logWriter.WriteLine("6. Calculate similarity Q scores in a entry-grouped group");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("6. Calculate similarity Q scores in a entry-grouped group");
                HomoGroupInterfacesFinder.modifyType = "build";
                HomoGroupInterfacesFinder groupInterfaceFinder = new HomoGroupInterfacesFinder();
                groupInterfaceFinder.DetectHomoGroupInterfaces(null);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
                DbBuilderHelper.UpdateIndexes("INTERFACE", ProtCidSettings.protcidDbConnection);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                break;

            case 7:
                // group crystal forms based on Q scores of entry interfaces in an entry group
                ProtCidSettings.logWriter.WriteLine("7. Detecting redundant crystal forms");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("6. Detecting redundant crystal forms");
                RedundantCrystForms reduntCrystForm = new RedundantCrystForms();
                reduntCrystForm.CheckReduntCrystForms();
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.currentOperationIndex++;
                // distinct crystal forms
                ProtCidSettings.logWriter.WriteLine("8. Cluster crystal forms in entry groups");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Non-Redundant Crystal Forms");
                NonredundantCfGroups nonreduntCfGroups = new NonredundantCfGroups();
                nonreduntCfGroups.UpdateCfGroupInfo();

                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
                DbBuilderHelper.UpdateIndexes("REDUN", ProtCidSettings.protcidDbConnection);
                break;

            default:
                break;
            }
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Build entry-based groups Done!");
            ProtCidSettings.logWriter.WriteLine("Build entry-based groups Done!");
            ProtCidSettings.logWriter.Flush();
        }
示例#11
0
        /// <summary>
        /// update database
        /// </summary>
        public void UpdatePfamInterfaces()
        {
            DbBuilderHelper.Initialize();
            ProtCidSettings.progressInfo.Reset();
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Updating PFAM Interfaces Data.");

            string line = "";

            string[] updateEntries = null;
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Get the entries to be updated from XML file directory.");
            //           string lsFile = "EntriesNotInEntryLevelGroups.txt";
            updateEntries = GetUpdateEntries();
            //           updateEntries = GetUpdateEntries(lsFile);


            if (updateEntries.Length == 0)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("No update needed.");
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
                ProtCidSettings.progressInfo.threadFinished = true;
                return;
            }
// Update entry interfaces,
            // generate interface files, calculate surface area,
            // then compare crystal interfaces to interfaces in PDB/PISA BAs
//            UpdateEntryInterfaceData(updateEntries);

            //           updateEntries = GetUpdateEntriesFromPfamUpdate();

            // classify these groups
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Update classification of homologous groups");
            PfamEntryClassifier        pfamClassifier  = new PfamEntryClassifier();
            Dictionary <int, string[]> updateGroupHash = null;

            updateGroupHash = pfamClassifier.UpdatePdbPfamGroups(updateEntries);

            ProtCidSettings.progressInfo.currentOperationIndex++;

            if (updateGroupHash == null)
            {
                updateGroupHash = new Dictionary <int, string[]>();
            }
            // divide into two groups

            /*          int groupIdDivide = 7000;
             *        ProtCidSettings.progressInfo.progStrQueue.Enqueue("This is for groupId >= 7000");
             *        ProtCidSettings.logWriter.WriteLine("This is for groupid >= 7000.");*/
            if (updateGroupHash.Count == 0)
            {
                int          groupId           = 0;
                StreamReader updateGroupReader = new StreamReader("updateGroups.txt");
                //		string line = "";
                while ((line = updateGroupReader.ReadLine()) != null)
                {
                    string[] fields = line.Split(' ');
                    groupId = Convert.ToInt32(fields[0]);
                    //           if (groupId >= groupIdDivide)

                    string[] entries = new string[fields.Length - 1];
                    Array.Copy(fields, 1, entries, 0, entries.Length);
                    updateGroupHash.Add(groupId, entries);
                }
                updateGroupReader.Close();
            }

            int[] updateGroups = new int[updateGroupHash.Count];
            updateGroupHash.Keys.CopyTo(updateGroups, 0);
            Array.Sort(updateGroups);

            // update xtal interfaces for these groups
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Retrieve alignments in a group");
            Alignments.GroupEntryAlignments groupAlignment = new InterfaceClusterLib.Alignments.GroupEntryAlignments();
            try
            {
                groupAlignment.UpdateChainAlignmentsInGroups(updateGroups);
            }
            catch (Exception ex)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue(ex.Message);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Stop the updating alignments and return.");
                ProtCidSettings.logWriter.WriteLine(ex.Message);
                ProtCidSettings.logWriter.WriteLine("Stop the updating alignments and return.");
                ProtCidSettings.logWriter.Flush();
                return;
            }
            ProtCidSettings.progressInfo.currentOperationIndex++;

            // update xtal interfaces for these groups
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Build crystal, detect common interfaces in a group");
            HomoGroupInterfacesFinder.modifyType = "update";
            HomoGroupInterfacesFinder groupInterfaceFinder = new HomoGroupInterfacesFinder();

            try
            {
                groupInterfaceFinder.UpdateHomoGroupInterfaces(updateGroupHash);
            }
            catch (Exception ex)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue(ex.Message);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Stop the updating group interfaces comparing and return.");
                ProtCidSettings.logWriter.WriteLine(ex.Message);
                ProtCidSettings.logWriter.WriteLine("Stop the updating group interfaces comparing and return.");
                ProtCidSettings.logWriter.Flush();
                return;
            }
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("6. Detecting redundant crystal forms");
            RedundantCrystForms reduntCrystForm = new RedundantCrystForms();

            try
            {
                reduntCrystForm.UpdateReduntCrystForms(updateGroups);
            }
            catch (Exception ex)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue(ex.Message);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Stop the updating redundant cryst forms and return.");
                ProtCidSettings.logWriter.WriteLine(ex.Message);
                ProtCidSettings.logWriter.WriteLine("Stop the updating redundant cryst forms and return.");
                ProtCidSettings.logWriter.Flush();
                return;
            }
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
            ProtCidSettings.progressInfo.currentOperationIndex++;
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Non-Redundant Crystal Forms");
            NonredundantCfGroups nonreduntCfGroups = new NonredundantCfGroups();

            try
            {
                nonreduntCfGroups.UpdateCfGroupInfo(updateGroups);
            }
            catch (Exception ex)
            {
                ProtCidSettings.progressInfo.progStrQueue.Enqueue(ex.Message);
                ProtCidSettings.progressInfo.progStrQueue.Enqueue("Stop the updating CF groups and return.");
                ProtCidSettings.logWriter.WriteLine(ex.Message);
                ProtCidSettings.logWriter.WriteLine("Stop the updating CF groups and return.");
                ProtCidSettings.logWriter.Flush();
                return;
            }
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Recomputing indices.");
            DbBuilderHelper.UpdateIndexes("RedundantCfGroups", ProtCidSettings.protcidDbConnection);
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");

            ProtCidSettings.logWriter.Close();
            ProtCidSettings.progressInfo.threadFinished = true;
        }