Esempio n. 1
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);*/
        }
Esempio n. 2
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();
        }
Esempio n. 3
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;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userGroupName"></param>
        /// <param name="userGroupSeqId"></param>
        /// <param name="userEntries"></param>
        public void FindInterfaceClustersInUserGroup(string userGroupName, int userGroupSeqId, string[] userEntries)
        {
            ProtCidSettings.progressInfo.Reset();
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Clutering interfaces in the user group");
            ProtCidSettings.progressInfo.progStrQueue.Enqueue(userGroupName + "  " + userGroupSeqId.ToString());

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

            updateSuperGroupHash.Add(userGroupSeqId, updatedGroupHash);
            Dictionary <int, string> superGroupNameHash = new Dictionary <int, string> ();

            superGroupNameHash.Add(userGroupSeqId, userGroupName);

            List <int> updateSuperGroupList = new List <int> (updateSuperGroupHash.Keys);

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

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

            superGroupClassifier.AddChainRelGroupsBasedOnPfam(updateSuperGroupHash, superGroupNameHash);

            // 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));
                File.Delete(nonAlignedPairFile);
            }

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

            interGroupRepEntryComp.UpdateEntryComparisonInSuperGroups(updateSuperGroupHash);

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

            interfaceCluster.ClusterUserDefinedGroupInterfaces(updateSuperGroups);

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

            superClusterStat.UpdateSupergroupInterfaceClustersSumInfo(updateSuperGroups, userEntries, "pfam", false);

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

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

            clusterFileCompress.CompressGroupClusterInterfaceFiles(updateSuperGroups, updateClusterReverseListFile);

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

            seqFastaGen.UpdateSeqFastaFiles(updateSuperGroups);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
        }