/* * $Id: SendSummary.cpp,v 1.1 2005/07/26 17:11:46 chenj Exp $ * * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information (NCBI) * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government do not place any restriction on its use or reproduction. * We would, however, appreciate having the NCBI and the author cited in * any work or product based on this material * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * =========================================================================== * * Author: Jie Chen * Source file for VSMmdb.cgi * * $Log: SendSummary.cpp,v $ * Revision 1.1 2005/07/26 17:11:46 chenj * Making linux VSMmdb.cgi * * * */ #include "SendSummary.hpp" #include "SHGlobal.hpp" static string tmp_dir = "/tmp/"; using namespace ncbi; using namespace SHProjNS; static void CreateIbutn(string& urlstr, string& dispOp, unsigned refT, CCgiContext& ctx) { static VSMmdbConf thisConf; ctx.GetResponse().out() << "\n" << "" << "\n"; } static void PrintActionButtons(CCgiContext& ctx) { CCgiResponse& resp = ctx.GetResponse(); static DataInfo Dinfo; static VSMmdbConf thisConf; static ImgInfo Iinfo; string urlstr, dispOp; string altstr= "Click to view 3D structure"; resp.out() <<"
\n" << "\n" << "
\n \n \n" << " \n \n \n\n \n \n
\n" << "\n" <<"\n" << " \n" << "  of \n" << "\n" << " with \n" << "Cn3D" << "New\n" << "\n" << " \n"; urlstr = "'" + thisConf.IbutHelpF + "_Cn3D.html'"; dispOp = "'resizable=yes, scrollbars=yes, width=420, height=200'"; CreateIbutn(urlstr, dispOp, 15, ctx); resp.out() << "
\n" << " \n \n\n" << "
\n\n"; if ( Dinfo.JobType == "Biostr" ) { resp.out() << "

\n" << "
\n"; if ( !Iinfo.prot_ch_cnt) return; string errmsg, wmsg, wmsgH; DownloadErrWarnMsgs((long long)Dinfo.GrpID, errmsg, wmsg, wmsgH); if ( !wmsg.empty() || !wmsgH.empty() ) { resp.out() << "\n" << "Warning message from data parsing"; } resp.out() << " \n \n\n"; altstr = "Click to launch VAST neighbor searching"; resp.out()<< "
\n\n" << " \n " <<"Click the \"Start\" button to launch the VAST search.\n\n"; resp.out() << "
\n" << "\n" << " \n \n \n \n \n\n \n \n
\n" << "\n" << "\n" << " \n  " << "the VAST Calculation\n" << "
\n" << " \n \n" << "
\n"; } /* resp.out() << " \n   \n" << " \n \nBack to the HomePage\n \n \n"; */ } // PrintActionButtons static void PrintChainsMap (BiostrucPtr bsp, PDNMS ModelStruc, unsigned short chain1, unsigned short cnt, CCgiContext& ctx, bool VastLink=0) { BiostrucFeaturePtr domain_bfp = 0; bool hasDomain = FALSE; unsigned *DomIdx; unsigned short imgsize=0, i, chain2; PMSD pmsd; PDNMM pdnmm, pdnmm1; IntervalHead **DomHead; CCgiResponse& resp = ctx.GetResponse(); static DataInfo Dinfo; static VSMmdbConf thisConf; pmsd = (PMSD) ModelStruc->data.ptrvalue; pdnmm = pmsd->pdnmmHead; if (pdnmm == 0) return; DomHead = NewDataType(cnt+1); for (i=0; i< cnt+1; i++) DomHead[i] = NULL; CalDomIdx(pdnmm, &DomIdx); GetDomFeaPtr(bsp, &hasDomain, &domain_bfp); CheckDomColIdx(domain_bfp, pdnmm, DomHead, DomIdx, hasDomain, FALSE); // GroupingChains(pmsd); pdnmm = pmsd->pdnmmHead; pdnmm1 = PdnmmforChainX(pdnmm, chain1); pdnmm = pdnmm1; chain2 = MIN(cnt, chain1+ChainPerImg-1); resp.out() << "\n"; static ImgInfo Iinfo; Iinfo.ismap = true; Iinfo.chbeg = chain1; Iinfo.chend = chain2; Iinfo.subset = Dinfo.subset; unsigned short y =ModelMapOrImg(0,pmsd, DomHead, DomIdx, ctx, VastLink); // imgsize = y + FontBH + 80; imgsize = y + 50; resp.out() << "\n" << "\n"; delete [] DomIdx; } /* end PrintChainsMap */ static void SumTab(CCgiContext& ctx, vector< vector > vvstr, bool isStr) { CCgiResponse& resp = ctx.GetResponse(); static DataInfo Dinfo; static ImgConf thisConf; static ImgInfo Iinfo; /* vector < vector > vvstr; GetChnInfo(Iinfo.id, vvstr); if ( !vvstr.size() ) { Iinfo.prot_ch_cnt = 0; return; } */ DomIntvlData dip[100]; resp.out() << " \n \n" << " \n" << " \n" << " \n"; if (isStr) { } else resp.out() << " \n"; resp.out() << " \n\n"; unsigned sdi, line_cnt=1, total_nbr=0; for (unsigned i=0; i< vvstr.size(); i++) { unsigned chnNo = ToUnsigned(vvstr[i][0]); unsigned domintvl_no = GetVSDomIntvlData(Dinfo.JobID, chnNo, dip, 100); for (unsigned j=0; j< domintvl_no; j++) { // if (!j && isStr && domintvl_no > 1) continue; if (dip[j].domNo >= 10000) continue; sdi = DomNo2Sdi(Iinfo.id, chnNo, dip[j].domNo); total_nbr = GetVSNumOfAllNbrs(sdi); resp.out() << " \n \n"; if (!isStr && total_nbr) { resp.out() << " \n"; else resp.out() << "domain " <\n"; resp.out() << " \n"; if (!isStr) { resp.out() << " \n" << " \n\n"; } line_cnt ++; } } resp.out() << "
" << "Chain ID" << "Domains" << "Residue Range" << "No. of Neighbors
[" << vvstr[i][1] << "]\n" << ""; } else resp.out() << " \n"; if ( !dip[j].domNo ) // dip[0].domNo = j = 0; resp.out() << "entire chain" << dip[j].frm << " - " << dip[j].tu; if (j) { for (unsigned k=j+1; k< domintvl_no; k++) { if (dip[j].domNo == dip[k].domNo) { resp.out() << ", " << dip[k].frm << " - " << dip [k].tu; dip[k].domNo += 10000; } } } resp.out() << ""<< total_nbr << "
\n\n"; } // SumTab() void SendSummaryPageText(CCgiContext& ctx, bool VastLink, bool JobDone) { CCgiRequest& req = ctx.GetRequest(); CCgiResponse& response = ctx.GetResponse(); static DataInfo Dinfo; static VSMmdbConf thisConf; static ImgInfo Iinfo; BiostrucPtr bsp; PDNMS ModelStruc; PMSD pmsdThis = 0; BiostrucSourcePtr pbssThis = 0; ValNodePtr pvnThis = 0; BiostrucHistoryPtr pbshThis = 0; // char* pcAuthors = 0; // bsp = FetchBS((char*)bFile.c_str(), 1, 2, 1000, POWER_VIEW); bsp = VSOpenBSP(Iinfo.id, 2, 1000); if (bsp == 0) { string strtmp = "Missing Biostruc data for reqid = " + ReqId2Str(Dinfo.ReqID) + ". Please inform chenj@ncbi.nlm.nih.gov for this problem. Thanks!"; PrtMes::PrintErrorHeader(&response, "Vast Search", 1); PrtMes::PrintMsgWithTail(&response, strtmp); exit(1); } ModelStruc = MakeAModelstruc(bsp); if (ModelStruc == 0) { PrtMes::PrintErrorHeader(&response, "Vast Search", 1); PrtMes::PrintMsgWithTail(&response, "ModelStruc==NULL.\nPlease inform chenj@ncbi.nlm.nih.gov.\n"); return; } pmsdThis = (PMSD) ModelStruc->data.ptrvalue; pvnThis =ValNodeFindNext(pmsdThis->pbsBS->descr,NULL,BiostrucDescr_history); if (pvnThis) { pbshThis = (BiostrucHistoryPtr) pvnThis->data.ptrvalue; pbssThis = pbshThis->data_source; // how to delete pbshThis and pbssThis } string urlstr = "" ; string dispOp = ""; unsigned chaincnt = ChainCount(pmsdThis); unsigned chbeg = 1; // (CurPage-1)*ChainPerImg +1; response.out() << "\n\n" << " \n \n \n\n"; vector< vector > vvstr; GetChnInfo(Iinfo.id, vvstr); Iinfo.prot_ch_cnt = 1; if ( !vvstr.size() ) Iinfo.prot_ch_cnt = 0; if (!VastLink) { response.out() << " \n \n" << " \n\n" << " \n\n" << " \n \n \n\n"; if (Iinfo.prot_ch_cnt) response.out()<< " \n \n\n"; if (Iinfo.prot_ch_cnt) { response.out() << " \n \n\n" << " \n \n \n\n"; } else { response.out() << " \n \n \n\n"; } response.out() << " \n \n \n\n"; response.out() << " \n \n \n"; PrintActionButtons(ctx); response.out() << " \n \n" << " \n \n \n"; ctx.GetResponse().out() << "
 
" << "Data Parsing Done
 
\n" << "Your structure data has been uploaded. Request ID: " << "" << Dinfo.GrpID << "\n" << "
\n" << "Bookmark this page to return later.\n"; response.out() << "


\n" << "Query Chains/Domains Summary

\n"; SumTab(ctx, vvstr, 1); response.out() << "
\n" << "VAST Chains Summary: " << "No protein chains submitted for VAST Search.\n"; urlstr= "'" + thisConf.IbutHelpF + "_NulCh.html'"; dispOp = "'resizable=yes, scrollbars=yes, width=400, height=200'"; CreateIbutn(urlstr, dispOp, 15, ctx); response.out() << "
\n"; PrintChainsMap(bsp, ModelStruc, chbeg, chaincnt, ctx, VastLink); response.out() << "
The \n"; if (Iinfo.prot_ch_cnt) response.out() << "table and "; response.out() << "graphics above indicate the individual chains and 3D domains identified in your structure. You may view them in " << "Cn3D\n" <<" to verify whether the data parsing is correct by clicking \"View 3D Structure\" below.\n"; urlstr = "'" + thisConf.IbutHelpF + "_Graph.html'"; dispOp = "'resizable=yes, scrollbars=yes, width=420, height=200'"; CreateIbutn(urlstr, dispOp, 15, ctx); response.out() << "
 
\nBack to the HomePage\n
\n" << "
\n"; } else { string errmsg; if (HaveErrmsgFromVSCal(Dinfo.GrpID, errmsg)) { response.out() << " \n" << " VAST Search Error Report\n" << " \n\n" << "  \n \n\n" << " \n \n" << "Your VAST search has stopped due to the following error.\n" << " \n" << " " << errmsg << "" << " \n" << " \n   \n" << " \n

\n" << " \n \nBack to the HomePage\n \n \n"; } else if (JobDone) { response.out() << " \n" << " VAST Search Done\n \n\n" << "  \n \n\n" << " \n \n" << "Your VAST search has finished successfully. Follow links on the Query Structure Summary to see results.\n" << " \n"; /* urlstr = "'" + thisConf.IbutHelpF + "_VSlink.html'"; dispOp = "'resizable=yes, scrollbars=yes, width=420, height=200'"; CreateIbutn(urlstr, dispOp, 15, ctx); */ response.out() << "

\n\n" << " \n \n" << "Query Structure Summary

" << " \n \n\n \n \n"; SumTab(ctx, vvstr, 0); response.out() << " \n \n\n"; /* << "

\n\n" << "
\n\n"; */ string showImg = req.GetEntry("showImg_fin").GetValue(); if ("Yes" == showImg) { /* response.out() << " " << "Query Structure Summary
\n" */ response.out() << "
\n\n" << " \n\n \n \n"; PrintChainsMap(bsp, ModelStruc, chbeg, chaincnt, ctx, VastLink); response.out() << " \n \n\n" << " \n \n" << "The graphics above indicate the individual chains and 3D domains identified in your structure. You may view them in " << "Cn3D\n" <<" by clicking \"View 3D Structure\" below. " << "You may also click each of them to look at their VAST neighbors.\n"; urlstr = "'" + thisConf.IbutHelpF + "_Graph.html'"; dispOp = "'resizable=yes, scrollbars=yes, width=420, height=200'"; CreateIbutn(urlstr, dispOp, 15, ctx); /* response.out() << " \n \n" << "
\n\n"; */ VastLink=false; PrintActionButtons(ctx); response.out() << "
\n\n" << "  \n\n" << " \n" << "Close the graphical Summary.\n \n" << " \n   \n" << " \n \n" << "Back to the HomePage\n \n \n" << "\n\n"; } else { response.out() << "

\n\n" << "
\n\n" << " \n \n" << "View" << " the Summary (graphical).\n \n \n" << " \n   \n" << " \n \n" << "Back to the HomePage\n \n \n" << "\n\n"; } } else { unsigned DomCnt = TotalDom(Dinfo.JobID); sqmInit(); string subTime = sqmGetReqTime(GrpId2ReqId(Dinfo.GrpID)); sqmFree(); string curTime = CTime(CTime::eCurrent).AsString(); string subsetstr = GetSubsetName4Grpid(Dinfo.GrpID); unsigned estT = 3 + (int)((DomCnt-1)*2.5); if (subsetstr == "All") estT *= 10; unsigned subH = atoi(subTime.substr(11,2).c_str()); unsigned subM = atoi(subTime.substr(14,2).c_str()); unsigned curH = atoi(curTime.substr(11,2).c_str()); unsigned curM = atoi(curTime.substr(14,2).c_str()); if (curH < subH) curH += 24; unsigned waiT = (curH-subH)*60 + (curM-subM); unsigned refT; ostringstream output; string refMsg; if ( estT <= waiT ) { if ( waiT < 60 ) { refT = 5; output << "Your job needs more time to finish, its status will be checked automatically after " << "" << refT << " minutes."; } else if (waiT < 120) { refT = 10; output << "Your job hasn't finised after running for 1 hour, its status will be checked automatically after " << "" << refT << " minutes."; } else { refT = 0; output << "Your job has been running longer than 2 hours, it may need more time to finish, please " << "check your job status later manually."; } } else { refT = estT - waiT; output << "\n \n" << " \n" << " \n \n" << " \n" << " \n \n\n" << " \n \n\n" << "
" << "Estimated completion Time: " << "" << refT << " minutes.
 " << "(actual time depends on the number of chains, " << "domains, and the size of the query protein; " << "highly populated folds such as a TIM barrel " << "will take a longer time).
" << "The job status will be checked automatically after " << "" < minutes.
\n\n"; } if (refT) { /* response.out() << "\n"; */ response.out() << "\n"; } response.out() << " \n " << "VAST Search in Progress
\n" << " \n \n\n" << "  \n\n" << " \n" << "Your VAST Search job was submitted at " << subTime << "(EDT). Request ID: " <\n\n" << " " << output.str() << "\n\n" << "  \n\n" << " \n \n" << "Bookmark this page to return and manually \n" << "check later.\n \n \n\n"; /* << "check later.\n Request ID: " << Dinfo.GrpID << ".\n \n \n\n" << " \n \nOr click " << "here to check previous jobs.\n \n \n\n" << " \n   \n"; */ string showImg = req.GetEntry("showImg_mid").GetValue(); if ( "Yes" == showImg ) { response.out() << "
\n\n" << " \n" << "Query Structure Summary
" << " \n\n" << " \n \n"; PrintChainsMap(bsp, ModelStruc, chbeg, chaincnt, ctx, VastLink); response.out() << " \n \n\n" << " \n \n" << "The graphics above indicate the individual chains and 3D domains identified in your structure. You may view them in " << "Cn3D\n" <<" by clicking \"View 3D Structure\" below. "; urlstr = "'" + thisConf.IbutHelpF + "_Graph.html'"; dispOp = "'resizable=yes, scrollbars=yes, width=420, height=200'"; CreateIbutn(urlstr, dispOp, 15, ctx); VastLink=false; PrintActionButtons(ctx); response.out() << "
\n\n" << "  \n\n" << " \n" << "Close the graphical Summary .\n \n" << " \n   \n"; } else { response.out() << "
\n\n" << "  \n\n" << " \n \n" << "View" << " the Query Structure Summary.\n \n \n" << "  \n\n"; } response.out() << " \n \nBack to the HomePage\n \n \n" << "\n\n"; } } // ViewNbr return; } // SendSummaryPage