Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbList"></param>
        /// <param name="userGroupName"></param>
        public void FindCommonInterfaceInGroup(string[] pdbList, string userGroupName)
        {
            Initialize();

            ProtCidSettings.progressInfo.Reset();
            int groupId = 111111;

            int[] updateGroups = new int [1];
            updateGroups[0] = groupId;

            ClearPreviousUserData(groupId);

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("1. Classify PDB entries into homologous groups");
            HomoEntryClassifier entryClassifier = new HomoEntryClassifier(groupId);

            entryClassifier.ClassifyHomoEntries(pdbList, userGroupName);
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("2. Build crystal, detect common interfaces in a group");
            HomoGroupInterfacesFinder interfaceFinder = new HomoGroupInterfacesFinder();

            HomoGroupInterfacesFinder.modifyType = "update";
            interfaceFinder.DetectHomoGroupInterfaces(updateGroups);
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("3. Generate interface files, calculate ASA in interfaces");
            CrystInterfaceProcessor interfaceProcessor = new CrystInterfaceProcessor();

            interfaceProcessor.GenerateEntryInterfaceFiles(pdbList);
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("4. Compare cryst interfaces with PDB/PISA BUs and ASU Interfaces");
            EntryCrystBuInterfaceComp buInterfaceComp = new EntryCrystBuInterfaceComp();

            buInterfaceComp.CompareEntryCrystBuInterfaces(pdbList);
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("5. Deal With Redundant Crystal Forms.");
            RedundantCrystForms reduntCf = new RedundantCrystForms();

            reduntCf.UpdateReduntCrystForms(updateGroups);
            NonredundantCfGroups nonreduntCfGroups = new NonredundantCfGroups();

            nonreduntCfGroups.UpdateCfGroupInfo(updateGroups);
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("6. Cluster cryst common interfaces");
            InterfaceCluster interfaceCluster = new InterfaceCluster();

            interfaceCluster.UpdateInterfaceClusters(updateGroups);
            ProtCidSettings.progressInfo.currentOperationIndex++;

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("7. Print cryst common interfaces");
            ClusterStat clusterStat = new ClusterStat();

            clusterStat.PrintCrystInterfaceClusters(groupId, ProtCidSettings.dataType);

            ProtCidSettings.progressInfo.threadFinished = true;
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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;
        }