NCBI C++ ToolKit
prosplign_demo.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: prosplign_demo.cpp 92223 2020-12-23 19:05:13Z grichenk $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Vyacheslav Chetvernin
27  *
28  * File Description: ProSplign sample application
29  *
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbiapp.hpp>
35 #include <objmgr/scope.hpp>
37 #include <serial/objostrasn.hpp>
38 #include <serial/serial.hpp>
41 
43 
44 
46 
48 {
49 public:
50  virtual void Init(void);
51  virtual int Run();
52 };
53 
55 {
56  unique_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);
57  arg_desc->AddKey("protein", "proteinSeqEntryID",
58  "Seq-id of the protein",
60  arg_desc->AddKey("genomic", "genomicSeqEntryID",
61  "Seq-id of the genomic sequence",
63  arg_desc->AddKey("start", "start",
64  "genomic region start",
66  arg_desc->AddKey("stop", "stop",
67  "genomic region stop",
69 
70  arg_desc->AddFlag("t", "produce alignment text");
71 
72  // Program description
73  string prog_description = "Example of the ProSplign usage\n";
74  arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
75  prog_description, false);
76 
77  arg_desc->AddFlag("no_introns", "alignment without introns");
80 
81  // Pass argument descriptions to the application
82  //
83 
84  SetupArgDescriptions(arg_desc.release());
85 }
86 
88 {
90 
91  const CArgs& args = GetArgs();
92 
94 
96 
97  CScope scope(*obj_mgr);
98  scope.AddDefaults();
99  /* examples
100 plus strand:
101 prosplign_demo -protein EAT35703.1 -genomic NW_001262488.1 -start 10353 -stop 12115
102 minus strand:
103 prosplign_demo -protein NP_002346.1 -genomic NT_009714.16 -start 1851937 -stop 1861227
104 
105  */
106 
107  CSeq_id protein(args["protein"].AsString());
108  CSeq_id genomic(args["genomic"].AsString());
109  CSeq_loc seqloc(genomic, args["start"].AsInteger(), args["stop"].AsInteger(),eNa_strand_unknown);
110 
111  CProSplign prosplign(CProSplignScoring(args),args["no_introns"]);
112  CProSplignOutputOptions output_options(args);
113  CRef<CSeq_align> alignment = prosplign.FindAlignment(scope, protein, seqloc,
114  output_options
115  );
116 
117  if (args["t"]) {
118  CProSplignText::Output(*alignment, scope, cout, 80);
119  } else {
120  cout << MSerial_AsnText << *alignment << endl;
121  }
122 
123  return 0;
124 }
125 
128 
129 int main(int argc, const char* argv[])
130 {
131  return CProSplignApp().AppMain(argc, argv);
132 }
CArgDescriptions –.
Definition: ncbiargs.hpp:541
CArgs –.
Definition: ncbiargs.hpp:379
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
Definition: gbloader.cpp:366
virtual int Run()
Run the application.
virtual void Init(void)
Initialize the application.
Output filtering parameters.
Definition: prosplign.hpp:156
static void SetupArgDescriptions(CArgDescriptions *argdescr)
Definition: prosplign.cpp:194
static void SetupArgDescriptions(CArgDescriptions *argdescr)
Definition: prosplign.cpp:109
static void Output(const objects::CSeq_align &seqalign, objects::CScope &scope, ostream &out, int width, const string &matrix_name="BLOSUM62")
Outputs formatted text.
Definition: Info.cpp:596
spliced protein to genomic alignment
Definition: prosplign.hpp:299
CRef< objects::CSeq_align > FindAlignment(objects::CScope &scope, const objects::CSeq_id &protein, const objects::CSeq_loc &genomic, CProSplignOutputOptions output_options=CProSplignOutputOptions())
Aligns protein to a region on genomic sequence.
Definition: prosplign.hpp:326
CScope –.
Definition: scope.hpp:92
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:305
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
Definition: ncbiapp.cpp:819
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
Definition: ncbiapp.cpp:1195
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eString
An arbitrary string.
Definition: ncbiargs.hpp:589
@ eInteger
Convertible into an integer number (int or Int8)
Definition: ncbiargs.hpp:592
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define USING_SCOPE(ns)
Use the specified namespace.
Definition: ncbistl.hpp:78
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
The Object manager core.
int main(int argc, const char *argv[])
USING_NCBI_SCOPE
Modified on Tue Apr 23 07:38:47 2024 by modify_doxy.py rev. 669887