src/algo/align/prosplign/demo/prosplign_demo.cpp

Go to the documentation of this file.
00001 /* $Id: prosplign_demo.cpp 123150 2008-03-28 19:25:10Z chetvern $
00002  * ===========================================================================
00003  *
00004  *                            PUBLIC DOMAIN NOTICE                          
00005  *               National Center for Biotechnology Information
00006  *                                                                          
00007  *  This software/database is a "United States Government Work" under the   
00008  *  terms of the United States Copyright Act.  It was written as part of    
00009  *  the author's official duties as a United States Government employee and 
00010  *  thus cannot be copyrighted.  This software/database is freely available 
00011  *  to the public for use. The National Library of Medicine and the U.S.    
00012  *  Government have not placed any restriction on its use or reproduction.  
00013  *                                                                          
00014  *  Although all reasonable efforts have been taken to ensure the accuracy  
00015  *  and reliability of the software and data, the NLM and the U.S.          
00016  *  Government do not and cannot warrant the performance or results that    
00017  *  may be obtained by using this software or data. The NLM and the U.S.    
00018  *  Government disclaim all warranties, express or implied, including       
00019  *  warranties of performance, merchantability or fitness for any particular
00020  *  purpose.                                                                
00021  *                                                                          
00022  *  Please cite the author in any work or product based on this material.   
00023  *
00024  * ===========================================================================
00025  *
00026  * Author:  Vyacheslav Chetvernin
00027  *
00028  * File Description: ProSplign sample application
00029  *                   
00030 */
00031 
00032 #include <ncbi_pch.hpp>
00033 #include <corelib/ncbiapp.hpp>
00034 #include <objmgr/object_manager.hpp>
00035 #include <objmgr/scope.hpp>
00036 #include <objects/seqloc/Seq_loc.hpp>
00037 #include <serial/objostrasn.hpp>
00038 #include <serial/serial.hpp>
00039 #include <objects/seqalign/Seq_align.hpp>
00040 #include <objtools/data_loaders/genbank/gbloader.hpp>
00041 
00042 #include <algo/align/prosplign/prosplign.hpp>
00043 
00044 
00045 BEGIN_NCBI_SCOPE
00046 
00047 class CProSplignApp: public CNcbiApplication
00048 {
00049 public:
00050     virtual void Init(void);
00051     virtual int  Run();
00052 };
00053 
00054 void CProSplignApp::Init(void)
00055 {
00056     auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
00057     arg_desc->AddKey("protein", "proteinSeqEntryID",
00058                              "Seq-id of the protein",
00059                              CArgDescriptions::eString);
00060     arg_desc->AddKey("genomic", "genomicSeqEntryID",
00061                              "Seq-id of the genomic sequence",
00062                              CArgDescriptions::eString);
00063     arg_desc->AddKey("start", "start",
00064                      "genomic region start",
00065                      CArgDescriptions::eInteger);
00066     arg_desc->AddKey("stop", "stop",
00067                      "genomic region stop",
00068                      CArgDescriptions::eInteger);
00069     
00070     arg_desc->AddFlag("full", "do not remove bad pieces");
00071     arg_desc->AddFlag("t", "produce alignment text");
00072 
00073     // Program description
00074     string prog_description = "Example of the ProSplign usage\n";
00075     arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
00076                               prog_description, false);
00077  
00078     // Pass argument descriptions to the application
00079     //
00080     
00081     SetupArgDescriptions(arg_desc.release());
00082 }
00083 
00084 int CProSplignApp::Run()
00085 { 
00086     USING_SCOPE(objects);
00087 
00088     const CArgs& args = GetArgs();
00089 
00090     CRef<CObjectManager> obj_mgr = CObjectManager::GetInstance();
00091 
00092     CGBDataLoader::RegisterInObjectManager(*obj_mgr);
00093 
00094     CScope scope(*obj_mgr);
00095     scope.AddDefaults();
00096     /* examples
00097 plus strand:
00098 prosplign_demo -protein EAT35703.1 -genomic NW_001262488.1 -start 10353 -stop 12115
00099 minus strand:
00100 prosplign_demo -protein NP_002346.1 -genomic NT_009714.16 -start 1851937 -stop 1861227
00101 
00102     */
00103 
00104     CSeq_id protein(args["protein"].AsString());
00105     CSeq_id genomic(args["genomic"].AsString());
00106     CSeq_loc seqloc(genomic, args["start"].AsInteger(), args["stop"].AsInteger(),eNa_strand_unknown);
00107 
00108     CProSplign prosplign;
00109     CRef<CSeq_align> alignment = prosplign.FindAlignment(scope, protein, seqloc,
00110                                                          CProSplignOutputOptions(args["full"]?
00111                                                                                  CProSplignOutputOptions::ePassThrough:
00112                                                                                  CProSplignOutputOptions::eWithHoles
00113                                                                                  )
00114                                                          );
00115 
00116     if (args["t"]) {
00117         CProSplignText::Output(*alignment, scope, cout, 80);
00118     } else {
00119         cout << MSerial_AsnText << *alignment << endl;
00120     }
00121 
00122     return 0;
00123 }
00124 
00125 END_NCBI_SCOPE
00126 USING_NCBI_SCOPE;
00127 
00128 int main(int argc, const char* argv[]) 
00129 {
00130     return CProSplignApp().AppMain(argc, argv);
00131 }
00132 
00133 

Generated on Wed Dec 9 03:53:37 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:17:45 2009 by modify_doxy.py rev. 173732