/// <summary>
        ///
        /// </summary>
        public void BuildPfamPeptideInterfaceClusters()
        {
            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Retrieve Pfam-Peptide interfaces and cluster interfaces");
            ProtCidSettings.logWriter.WriteLine("Retrieve Pfam-Peptide interfaces and cluster interfaces");

            // retreive peptide interfaces
            PfamPeptideInterfaces pfamPepInterfaces = new PfamPeptideInterfaces();

            pfamPepInterfaces.RetrievePfamPeptideInterfaces();
            //         pfamPepInterfaces.GetPfamPeptideInPdbMetaData();

            // write peptide interfaces into PDB format files
            PfamPepInterfaceWriter pepInterfaceWriter = new PfamPepInterfaceWriter();

            pepInterfaceWriter.GeneratePfamPeptideInterfaceFiles();

            // calculate the SA by NACCESS
            DomainInterfaceSA pepInterfaceSa = new DomainInterfaceSA();

            pepInterfaceSa.domainInterfaceTableName = "PfamPeptideInterfaces";
            pepInterfaceSa.CalculateDomainInterfaceSAs();

            // common hmm positions
            PfamHmmSites commonHmmSites = new PfamHmmSites();

            // common hmm positions between peptide interfaces
            commonHmmSites.CountPeptideInterfaceHmmSites();
            // common hmmm positions between domain and peptide interfaces
            //   commonHmmSites.CountPfamCommonHmmSites();

            // Peptide-peptide RMSD
            PeptideInterfaceRmsd pepInterfaceRmsd = new PeptideInterfaceRmsd();

            pepInterfaceRmsd.CalculateDomainInterfacePeptideRmsd();
            pepInterfaceRmsd.CalculateMissingPfamDomainInterfacePeptideRmsd();

            // cluster peptide interfaces, them compress the peptide interfaces into tar files
            PeptideInterfaceCluster pepCluster = new PeptideInterfaceCluster();

            pepCluster.ClusterPeptideInterfaces();

            PeptideInterfaceClusterStat pepClusterStat = new PeptideInterfaceClusterStat();

            pepClusterStat.GetPepInterfaceClusterStat();

            PepClusterInterfaceCompress pepClusterFileCompress = new PepClusterInterfaceCompress();

            pepClusterFileCompress.CompressClusterPeptideInterfaceFiles();

            PfamPepSeqFasta pepSeqFasta = new PfamPepSeqFasta();

            pepSeqFasta.PrintPfamPeptideClusterSequences();

            PfamPepInterfaceFileCompress fileCompress = new PfamPepInterfaceFileCompress();

            fileCompress.CompressPfamPeptideInterfaces();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Clustering peptide interfaces done!");
            ProtCidSettings.logWriter.WriteLine("Clustering peptide interfaces done! ");
        }
        public void UpdateSomePfamPeptideInteractionsDebug()
        {
            string[] updateEntries = GetMissingPfamPepInterfacesEntries();
            //     string[] updateEntries = {"4tq1" };
            PfamPeptideInterfaces         pfamPepInterfaces   = new PfamPeptideInterfaces();
            Dictionary <string, string[]> updatePfamEntryDict = pfamPepInterfaces.UpdatePfamPeptideInterfaces(updateEntries);

            //        PeptideInterfaceClusterStat pepClusterStat1 = new PeptideInterfaceClusterStat();
            //        pepClusterStat1.AddNumCFs();


            string[] updatePfamIds = { "MHC_II_alpha" };

            ProtCidSettings.logWriter.WriteLine("Update peptide interface clusters");
            // cluster peptide interfaces,
            PeptideInterfaceCluster pepCluster = new PeptideInterfaceCluster();

            pepCluster.UpdatePeptideInterfaceClusters(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            // the pymol sessions for each pfam-peptide interface clusters
            ProtCidSettings.logWriter.WriteLine("Compress peptide interface files of clusters");
            PepClusterInterfaceCompress pepClusterFileCompress = new PepClusterInterfaceCompress();

            pepClusterFileCompress.UpdateClusterPeptideInterfaceFiles(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Sequences for peptide interface clusters");
            // the sequences for both pfam domains and peptides
            PfamPepSeqFasta pepSeqFasta = new PfamPepSeqFasta();

            pepSeqFasta.UpdatePfamPeptideClusterSequences(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Update peptide interface clusters");
            // the summary info for the updated pfams
            PeptideInterfaceClusterStat pepClusterStat = new PeptideInterfaceClusterStat();

            pepClusterStat.UpdatePepInterfaceClusterStat(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            // update pfam-peptide interfaces, align pfam domains, peptides are not aligned
            ProtCidSettings.logWriter.WriteLine("Compress all Pfam-peptide interfaces");
            PfamPepInterfaceFileCompress fileCompress = new PfamPepInterfaceFileCompress();

            fileCompress.UpdatePfamPeptideInterfaces(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Update pfam-peptide data done!");
            ProtCidSettings.logWriter.Flush();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="updateEntries"></param>
        public void UpdatePfamPeptideInteractions(string[] updateEntries)
        {
            // retreive peptide interfaces
            PfamPeptideInterfaces pfamPepInterfaces = new PfamPeptideInterfaces();

            ProtCidSettings.logWriter.WriteLine("Update Pfam-peptide interfaces");
            ProtCidSettings.logWriter.WriteLine("#entries=" + updateEntries.Length);
            ProtCidSettings.logWriter.Flush();

            Dictionary <string, string[]> updatePfamEntryDict = pfamPepInterfaces.UpdatePfamPeptideInterfaces(updateEntries);
            //       Dictionary<string, string[]> updatePfamEntryDict = ReadUpdatePfamPepEntryHash();
            List <string> updatePfamIdList = new List <string>(updatePfamEntryDict.Keys);

            updatePfamIdList.Sort();
            string[] updatePfamIds = new string[updatePfamIdList.Count];
            updatePfamIdList.CopyTo(updatePfamIds);
            string[] updatePepEntries = GetUpdateEntriesFromHash(updatePfamEntryDict);

            ProtCidSettings.logWriter.WriteLine("Update Pfam-peptide in pdb meta data.");
            pfamPepInterfaces.UpdatePfamPeptideInPdbMetaData(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Update Pfam-peptide coordinate interface files.");
            // write peptide interfaces into PDB format files
            PfamPepInterfaceWriter pepInterfaceWriter = new PfamPepInterfaceWriter();

            pepInterfaceWriter.UpdatePfamPeptideInterfaceFiles(updatePepEntries);
            //           pepInterfaceWriter.WriteDomainPeptideInterfaceFiles();
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            // calculate the SA by NACCESS
            ProtCidSettings.logWriter.WriteLine("Update surface areas of pfam-peptide interfaces.");
            DomainInterfaceSA pepInterfaceSa = new DomainInterfaceSA();

            pepInterfaceSa.domainInterfaceTableName = "PfamPeptideInterfaces";
            pepInterfaceSa.UpdateDomainInterfaceSAs(updatePepEntries);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Update peptide interface hmm sites");
            // common hmm positions
            PfamHmmSites commonHmmSites = new PfamHmmSites();

            // common hmm positions between peptide interfaces
            commonHmmSites.UpdatePeptideInterfaceHmmSites(updatePepEntries);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            // Peptide-peptide RMSD
            ProtCidSettings.logWriter.WriteLine("Update peptide RMSDs");
            PeptideInterfaceRmsd pepInterfaceRmsd = new PeptideInterfaceRmsd();

            pepInterfaceRmsd.UpdateDomainInterfacePeptideRmsd(updatePfamEntryDict);
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Update peptide interface clusters");
            // cluster peptide interfaces,
            PeptideInterfaceCluster pepCluster = new PeptideInterfaceCluster();

            pepCluster.UpdatePeptideInterfaceClusters(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            // the pymol sessions for each pfam-peptide interface clusters
            ProtCidSettings.logWriter.WriteLine("Compress peptide interface files of clusters");
            PepClusterInterfaceCompress pepClusterFileCompress = new PepClusterInterfaceCompress();

            pepClusterFileCompress.UpdateClusterPeptideInterfaceFiles(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Sequences for peptide interface clusters");
            // the sequences for both pfam domains and peptides
            PfamPepSeqFasta pepSeqFasta = new PfamPepSeqFasta();

            pepSeqFasta.UpdatePfamPeptideClusterSequences(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            ProtCidSettings.logWriter.WriteLine("Update peptide interface clusters");
            // the summary info for the updated pfams
            PeptideInterfaceClusterStat pepClusterStat = new PeptideInterfaceClusterStat();

            pepClusterStat.UpdatePepInterfaceClusterStat(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Done!");
            ProtCidSettings.logWriter.Flush();

            // update pfam-peptide interfaces, align pfam domains, peptides are not aligned
            ProtCidSettings.logWriter.WriteLine("Compress all Pfam-peptide interfaces");
            PfamPepInterfaceFileCompress fileCompress = new PfamPepInterfaceFileCompress();

            fileCompress.UpdatePfamPeptideInterfaces(updatePfamIds);
            ProtCidSettings.logWriter.WriteLine("Update pfam-peptide data done!");
            ProtCidSettings.logWriter.Flush();
        }