Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="domainInfo"></param>
        private AtomInfo[] ChangeDomainAtomsSeqAtomIds(PfamDomainInfo domainInfo)
        {
            int       atomSeqNo      = 1;
            int       residueSeqNo   = 1;
            int       atomSeqId      = 0;
            int       preAtomSeqId   = 0;
            ArrayList domainAtomList = new ArrayList();

            foreach (DomainSegmentInfo segInfo in domainInfo.segmentInfos)
            {
                atomSeqId    = 0;
                preAtomSeqId = 0;

                segInfo.fileStart = residueSeqNo;
                segInfo.fileEnd   = residueSeqNo + segInfo.seqEnd - segInfo.seqStart;
                for (int i = 0; i < segInfo.atoms.Length; i++)
                {
                    segInfo.atoms[i].atomId = atomSeqNo;
                    atomSeqNo++;
                    if (atomSeqNo > 99999) // the maximum atom seq id is 5-digit
                    {
                        atomSeqNo = 1;
                    }
                    atomSeqId = Convert.ToInt32(segInfo.atoms[i].seqId);
                    if (preAtomSeqId == 0)
                    {
                        preAtomSeqId = atomSeqId;
                    }
                    if (preAtomSeqId == atomSeqId)
                    {
                        segInfo.atoms[i].seqId = residueSeqNo.ToString();
                    }
                    else
                    {
                        residueSeqNo           = residueSeqNo + atomSeqId - preAtomSeqId;
                        segInfo.atoms[i].seqId = residueSeqNo.ToString();
                        preAtomSeqId           = atomSeqId;
                    }
                }
                domainAtomList.AddRange(segInfo.atoms);
                residueSeqNo = segInfo.fileEnd + 1;
            }
            AtomInfo[] domainAtoms = new AtomInfo[domainAtomList.Count];
            domainAtomList.CopyTo(domainAtoms);
            return(domainAtoms);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        /// <param name="domainInfo"></param>
        /// <param name="chainInfo"></param>
        /// <returns></returns>
        private string WritePfamDomainToFile(string pdbId, PfamDomainInfo domainInfo)
        {
            string remarkString = "HEADER   " + pdbId + "\r\n";

            remarkString += "REMARK   1   PFAM    " + domainInfo.domainId + "\r\n";
            remarkString += ("REMARK   2   PFAM ACC: " + domainInfo.pfamAcc + ", " +
                             " PFAM ID: " + domainInfo.pfamId + "\r\n");

            AtomInfo[] domainAtoms = ChangeDomainAtomsSeqAtomIds(domainInfo);
            if (domainAtoms.Length == 0)
            {
                logWriter.WriteLine(pdbId + domainInfo.domainId + " no coordinates.");
                logWriter.Flush();
                return("");
            }

            string domainInfoRemark = FormatDomainSegmentInfoRemark(domainInfo.segmentInfos);

            remarkString += domainInfoRemark;

            string seqResRecord = FormatDomainSeqResRecord(domainInfo.segmentInfos);

            remarkString += (seqResRecord + "\r\n");

            string hashDir = pdbId.Substring(1, 2);

            if (!Directory.Exists(Path.Combine(pfamDomainFileDir, hashDir)))
            {
                Directory.CreateDirectory(Path.Combine(pfamDomainFileDir, hashDir));
            }

            InsertDataIntoDbTable(domainInfo);

            string fileName = Path.Combine(pfamDomainFileDir, hashDir + "\\" + pdbId + domainInfo.domainId + ".pfam");

            WriteAtomsToFile(fileName, fileChain, remarkString, domainAtoms);
            ParseHelper.ZipPdbFile(fileName);
            return(fileName + ".gz");
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="domainInfo"></param>
 private void InsertDataIntoDbTable(PfamDomainInfo domainInfo)
 {
     if (isUpdate)
     {
         string deleteString = string.Format("Delete From {0}  Where PdbID = '{1}' AND DomainID = {2};",
                                             domainFileInfoTable.TableName, domainInfo.pdbId, domainInfo.domainId);
         dbQuery.Query(deleteString);
     }
     foreach (DomainSegmentInfo segInfo in domainInfo.segmentInfos)
     {
         DataRow fileInfoRow = domainFileInfoTable.NewRow();
         fileInfoRow["PdbId"]     = domainInfo.pdbId;
         fileInfoRow["DomainId"]  = domainInfo.domainId;
         fileInfoRow["EntityID"]  = segInfo.entityId;
         fileInfoRow["AsymChain"] = segInfo.asymChain;
         fileInfoRow["SeqStart"]  = segInfo.seqStart;
         fileInfoRow["SeqEnd"]    = segInfo.seqEnd;
         fileInfoRow["FileStart"] = segInfo.fileStart;
         fileInfoRow["FileEnd"]   = segInfo.fileEnd;
         domainFileInfoTable.Rows.Add(fileInfoRow);
     }
     dbInsert.InsertDataIntoDBtables(domainFileInfoTable);
     domainFileInfoTable.Clear();
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdbId"></param>
        public string[] GenerateEntryPfamDomainFiles(string pdbId)
        {
            DataTable entryPfamTable = GetEntryPfamDomainTable(pdbId);

            if (entryPfamTable.Rows.Count == 0) // no pfam domain definition for the entry
            {
                return(null);
            }
            ArrayList entryDomainInfoList = new ArrayList();
            ArrayList domainList          = new ArrayList();

            foreach (DataRow domainRow in entryPfamTable.Rows)
            {
                string domainId = domainRow["DomainID"].ToString();
                if (!domainList.Contains(domainId))
                {
                    domainList.Add(domainId);
                }
            }
            string    domainFile          = "";
            Hashtable entityChainInfoHash = new Hashtable();

            foreach (string domainId in domainList)
            {
                domainFile = Path.Combine(pfamDomainFileDir, pdbId.Substring(1, 2) + "\\" +
                                          pdbId + domainId + ".pfam.gz");
                if (File.Exists(domainFile))
                {
                    continue;
                }
                DataRow[]      domainRows = entryPfamTable.Select(string.Format("DomainID = '{0}'", domainId), "HmmStart ASC");
                PfamDomainInfo domainInfo = new PfamDomainInfo();
                domainInfo.pdbId    = pdbId;
                domainInfo.domainId = domainId;
                domainInfo.pfamAcc  = domainRows[0]["Pfam_ACC"].ToString().TrimEnd();
                domainInfo.pfamId   = domainRows[0]["Pfam_ID"].ToString().TrimEnd();
                DomainSegmentInfo[] segmentInfos = new DomainSegmentInfo[domainRows.Length];
                int count = 0;
                foreach (DataRow domainRow in domainRows)
                {
                    DomainSegmentInfo segmentInfo = new DomainSegmentInfo();
                    segmentInfo.entityId = Convert.ToInt32(domainRow["EntityId"].ToString());
                    string[] chainInfos = GetAsymAuthorChainWithMaxCoord(pdbId, segmentInfo.entityId, ref entityChainInfoHash);
                    segmentInfo.asymChain  = chainInfos[0];
                    segmentInfo.authChain  = chainInfos[1];
                    segmentInfo.seqStart   = Convert.ToInt32(domainRow["SeqStart"].ToString());
                    segmentInfo.seqEnd     = Convert.ToInt32(domainRow["SeqEnd"].ToString());
                    segmentInfo.hmmStart   = Convert.ToInt32(domainRow["HmmStart"].ToString());
                    segmentInfo.hmmEnd     = Convert.ToInt32(domainRow["HmmEnd"].ToString());
                    segmentInfo.alignStart = Convert.ToInt32(domainRow["AlignStart"].ToString());
                    segmentInfo.alignEnd   = Convert.ToInt32(domainRow["AlignEnd"].ToString());
                    segmentInfos[count]    = segmentInfo;
                    count++;
                }
                domainInfo.segmentInfos = segmentInfos;
                entryDomainInfoList.Add(domainInfo);
            }
            PfamDomainInfo[] entryDomainInfos = new PfamDomainInfo[entryDomainInfoList.Count];
            entryDomainInfoList.CopyTo(entryDomainInfos);
            string[] domainFiles = GenerateEntryPfamDomainFiles(pdbId, entryDomainInfos);
            return(domainFiles);
        }