Пример #1
0
        /// <summary>
        ///
        /// </summary>
        public void CompressBigRelations()
        {
            int[] relSeqIds = { 2055, 2124, 2178, 11619, 11642, 14647, 14811 };


            ProtCidSettings.dirSettings.seqFastaPath = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\fasta", "\\DomainFasta");

            webFastaFileDir = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\DomainFasta", "\\WebDomainFasta");

            List <string> seqFastaFileList = new List <string>();
            string        relationSeqFile  = "";
            string        srcRelSeqFile    = "";
            string        destRelSeqFile   = "";
            //      string relationFolder = "";
            string relationName = "";

            foreach (int relSeqId in relSeqIds)
            {
                seqFastaFileList.Clear();
                string[] relFastaFiles = Directory.GetFiles(ProtCidSettings.dirSettings.seqFastaPath, "Cluster" + relSeqId.ToString() + "A_*.fasta");
                foreach (string fastaFile in relFastaFiles)
                {
                    FileInfo fileInfo = new FileInfo(fastaFile);
                    seqFastaFileList.Add(fileInfo.Name);
                }
                relFastaFiles = Directory.GetFiles(ProtCidSettings.dirSettings.seqFastaPath, "Cluster" + relSeqId.ToString() + "B_*.fasta");
                foreach (string fastaFile in relFastaFiles)
                {
                    FileInfo fileInfo = new FileInfo(fastaFile);
                    seqFastaFileList.Add(fileInfo.Name);
                }
                seqFastaFileList.Add("Group" + relSeqId.ToString() + "A.fasta");
                if (File.Exists(Path.Combine(ProtCidSettings.dirSettings.seqFastaPath, "Group" + relSeqId.ToString() + "B.fasta")))
                {
                    seqFastaFileList.Add("Group" + relSeqId.ToString() + "B.fasta");
                }
                string[] seqFastaFiles = new string[seqFastaFileList.Count];
                seqFastaFileList.CopyTo(seqFastaFiles);

                //           relationFolder = MoveSeqFastaFilesToGroupFolder (seqFastaFiles, ProtCidSettings.dirSettings.seqFastaPath, relSeqId);

                //   relationSeqFile = TarFastaFilesOnFolder (relSeqId, relationFolder);
                relationName = DownloadableFileName.GetDomainRelationName(relSeqId);
                string seqTarFile = "Seq_" + relationName + ".tar.gz";
                fileCompress.RunTar(seqTarFile, seqFastaFiles, ProtCidSettings.dirSettings.seqFastaPath, true);

                // move the tar file to the web folder
                srcRelSeqFile  = Path.Combine(ProtCidSettings.dirSettings.seqFastaPath, relationSeqFile);
                destRelSeqFile = Path.Combine(webFastaFileDir, relationSeqFile);
                if (File.Exists(destRelSeqFile))
                {
                    File.Delete(destRelSeqFile);
                }
                File.Move(srcRelSeqFile, destRelSeqFile);
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        public string GenerateDomainGroupIdFileNameMatch()
        {
            string       domainGroupIdNameLsFile = Path.Combine(ProtCidSettings.dirSettings.interfaceFilePath, "DomainGroupIdNameMap.txt");
            StreamWriter lsFileWriter            = new StreamWriter(domainGroupIdNameLsFile);
            string       queryString             = "Select Distinct RelSeqID From PfamDomainFamilyRelation;";
            DataTable    domainGroupTable        = ProtCidSettings.protcidQuery.Query(queryString);
            int          relSeqId  = 0;
            string       groupName = "";

            foreach (DataRow domainGroupRow in domainGroupTable.Rows)
            {
                relSeqId  = Convert.ToInt32(domainGroupRow["RelSeqID"].ToString());
                groupName = DownloadableFileName.GetDomainRelationName(relSeqId);
                lsFileWriter.Write(relSeqId + "\t" + groupName + "\n");
            }
            lsFileWriter.Close();
            return(domainGroupIdNameLsFile);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateClusterDomainSequencesForDebug(int[] relSeqIds)
        {
            ProtCidSettings.dirSettings.seqFastaPath = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\fasta", "\\DomainFasta");
            if (!Directory.Exists(ProtCidSettings.dirSettings.seqFastaPath))
            {
                Directory.CreateDirectory(ProtCidSettings.dirSettings.seqFastaPath);
            }

            webFastaFileDir = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\DomainFasta", "\\WebDomainFasta");
            if (!Directory.Exists(webFastaFileDir))
            {
                Directory.CreateDirectory(webFastaFileDir);
            }

            StreamWriter lsFileWriter    = new StreamWriter(Path.Combine(webFastaFileDir, "relSeq-newls.txt"), true);
            string       relationSeqFile = "";

            ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
            ProtCidSettings.progressInfo.totalOperationNum = relSeqIds.Length;
            ProtCidSettings.progressInfo.totalStepNum      = relSeqIds.Length;

            string srcRelSeqFile  = "";
            string destRelSeqFile = "";
            string relationName   = "";

            foreach (int relSeqId in relSeqIds)
            {
                ProtCidSettings.progressInfo.currentFileName = relSeqId.ToString();
                ProtCidSettings.progressInfo.currentOperationNum++;
                ProtCidSettings.progressInfo.currentStepNum++;

                try
                {
                    string[] fastaSeqFiles = GetRelationClusterSeqFastaFiles(relSeqId);

                    relationName    = DownloadableFileName.GetDomainRelationName(relSeqId);
                    relationSeqFile = "Seq_" + relationName + ".tar.gz";
                    fileCompress.RunTar(relationSeqFile, fastaSeqFiles, ProtCidSettings.dirSettings.seqFastaPath, true);


                    lsFileWriter.WriteLine(relationSeqFile);
                    lsFileWriter.Flush();

                    // move the tar file to the web folder
                    srcRelSeqFile  = Path.Combine(ProtCidSettings.dirSettings.seqFastaPath, relationSeqFile);
                    destRelSeqFile = Path.Combine(webFastaFileDir, relationSeqFile);
                    if (File.Exists(destRelSeqFile))
                    {
                        File.Delete(destRelSeqFile);
                    }
                    File.Move(srcRelSeqFile, destRelSeqFile);
                }
                catch (Exception ex)
                {
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue(relSeqId.ToString() + " Writing sequences to fasta files errors: " + ex.Message);
                    ProtCidSettings.logWriter.WriteLine(relSeqId.ToString() + " Writing sequences to fasta files errors: " + ex.Message);
                    ProtCidSettings.logWriter.Flush();
                }
            }

            lsFileWriter.Close();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        public void PrintClusterDomainSequences()
        {
            ProtCidSettings.dirSettings.seqFastaPath = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\fasta", "\\DomainFasta");
            if (!Directory.Exists(ProtCidSettings.dirSettings.seqFastaPath))
            {
                Directory.CreateDirectory(ProtCidSettings.dirSettings.seqFastaPath);
            }

            webFastaFileDir = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\DomainFasta", "\\WebDomainFasta");
            if (!Directory.Exists(webFastaFileDir))
            {
                Directory.CreateDirectory(webFastaFileDir);
            }

            StreamWriter lsFileWriter    = new StreamWriter(Path.Combine(webFastaFileDir, "relSeq-ls.txt"), true);
            string       relationSeqFile = "";

            string    queryString   = "Select Distinct RelSeqID From PfamDomainInterfaceCluster;";
            DataTable relSeqIdTable = ProtCidSettings.protcidQuery.Query(queryString);

            int relSeqId = 0;

            ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
            ProtCidSettings.progressInfo.totalOperationNum = relSeqIdTable.Rows.Count;
            ProtCidSettings.progressInfo.totalStepNum      = relSeqIdTable.Rows.Count;

            queryString = "Select PdbID, EntityID, AsymID, Sequence From AsymUnit WHere PolymerType = 'polypeptide';";
            DataTable entitySeqTable = ProtCidSettings.pdbfamQuery.Query(queryString);

            queryString = "Select PdbID, DomainID, EntityID, SeqStart, SeqEnd, Pfam_ID, Pfam_Acc From PdbPfam;";
            DataTable domainTable = ProtCidSettings.pdbfamQuery.Query(queryString);

            string srcRelSeqFile  = "";
            string destRelSeqFile = "";
            string relationName   = "";

            foreach (DataRow relSeqIdRow in relSeqIdTable.Rows)
            {
                relSeqId     = Convert.ToInt32(relSeqIdRow["RelSeqID"].ToString());
                relationName = DownloadableFileName.GetDomainRelationName(relSeqId);

                ProtCidSettings.progressInfo.currentFileName = relSeqId.ToString();
                ProtCidSettings.progressInfo.currentOperationNum++;
                ProtCidSettings.progressInfo.currentStepNum++;

                try
                {
                    relationSeqFile = "Seq_" + relationName + ".tar.gz";
                    if (!File.Exists(relationSeqFile))
                    {
                        string[] fastaSeqFiles = PrintRelationClusterSeqFasta(relSeqId, entitySeqTable, domainTable);

                        relationSeqFile = fileCompress.RunTar(relationSeqFile, fastaSeqFiles, ProtCidSettings.dirSettings.seqFastaPath, true);
                    }
                    lsFileWriter.WriteLine(relationSeqFile);
                    lsFileWriter.Flush();

                    // move the tar file to the web folder
                    srcRelSeqFile  = Path.Combine(ProtCidSettings.dirSettings.seqFastaPath, relationSeqFile);
                    destRelSeqFile = Path.Combine(webFastaFileDir, relationSeqFile);
                    if (File.Exists(destRelSeqFile))
                    {
                        File.Delete(destRelSeqFile);
                    }
                    File.Move(srcRelSeqFile, destRelSeqFile);
                }
                catch (Exception ex)
                {
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue(relSeqId.ToString() + " Writing sequences to fasta files errors: " + ex.Message);
                    ProtCidSettings.logWriter.WriteLine(relSeqId.ToString() + " Writing sequences to fasta files errors: " + ex.Message);
                    ProtCidSettings.logWriter.Flush();
                }
            }

            lsFileWriter.Close();

            ProtCidSettings.progressInfo.progStrQueue.Enqueue("Done!");
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateClusterDomainSequences(int[] relSeqIds)
        {
            ProtCidSettings.dirSettings.seqFastaPath = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\fasta", "\\DomainFasta");
            if (!Directory.Exists(ProtCidSettings.dirSettings.seqFastaPath))
            {
                Directory.CreateDirectory(ProtCidSettings.dirSettings.seqFastaPath);
            }

            webFastaFileDir = ProtCidSettings.dirSettings.seqFastaPath.Replace("\\DomainFasta", "\\WebDomainFasta");
            if (Directory.Exists(webFastaFileDir))
            {
                Directory.Delete(webFastaFileDir, true);
            }
            Directory.CreateDirectory(webFastaFileDir);

            StreamWriter lsFileWriter    = new StreamWriter(Path.Combine(webFastaFileDir, "relSeq-newls.txt"), true);
            string       relationSeqFile = "";

            ProtCidSettings.progressInfo.ResetCurrentProgressInfo();
            ProtCidSettings.progressInfo.totalOperationNum = relSeqIds.Length;
            ProtCidSettings.progressInfo.totalStepNum      = relSeqIds.Length;

            string    queryString    = "Select PdbID, EntityID, AsymID, Sequence From AsymUnit WHere PolymerType = 'polypeptide';";
            DataTable entitySeqTable = ProtCidSettings.pdbfamQuery.Query(queryString);

            queryString = "Select PdbID, DomainID, EntityID, SeqStart, SeqEnd, Pfam_ID, Pfam_Acc From PdbPfam;";
            DataTable domainTable = ProtCidSettings.pdbfamQuery.Query(queryString);

            string srcRelSeqFile  = "";
            string destRelSeqFile = "";
            string relationName   = "";

            foreach (int relSeqId in relSeqIds)
            {
                ProtCidSettings.progressInfo.currentFileName = relSeqId.ToString();
                ProtCidSettings.progressInfo.currentOperationNum++;
                ProtCidSettings.progressInfo.currentStepNum++;

                try
                {
                    DeleteRelationSeqFiles(relSeqId);  // delete the old files
                    string[] fastaSeqFiles = PrintRelationClusterSeqFasta(relSeqId, entitySeqTable, domainTable);
                    // the length of parameters of Cmd.exe cannot be longer than 8191
                    relationName    = DownloadableFileName.GetDomainRelationName(relSeqId);
                    relationSeqFile = "Seq_" + relationName + ".tar.gz";
                    fileCompress.RunTar(relationSeqFile, fastaSeqFiles, ProtCidSettings.dirSettings.seqFastaPath, true);


                    lsFileWriter.WriteLine(relationSeqFile);
                    lsFileWriter.Flush();

                    // move the tar file to the web folder
                    srcRelSeqFile  = Path.Combine(ProtCidSettings.dirSettings.seqFastaPath, relationSeqFile);
                    destRelSeqFile = Path.Combine(webFastaFileDir, relationSeqFile);
                    if (File.Exists(destRelSeqFile))
                    {
                        File.Delete(destRelSeqFile);
                    }
                    File.Move(srcRelSeqFile, destRelSeqFile);
                }
                catch (Exception ex)
                {
                    ProtCidSettings.progressInfo.progStrQueue.Enqueue(relSeqId.ToString() + " Writing sequences to fasta files errors: " + ex.Message);
                    ProtCidSettings.logWriter.WriteLine(relSeqId.ToString() + " Writing sequences to fasta files errors: " + ex.Message);
                    ProtCidSettings.logWriter.Flush();
                }
            }

            lsFileWriter.Close();

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