52 "Demo application using xalgoalign library");
54 argdescr->AddDefaultKey
55 (
"matrix",
"matrix",
"scoring matrix",
60 "the first input sequence in fasta file",
64 "the second input sequence in fasta file",
67 argdescr->AddDefaultKey
69 "End-space free alignment. Format: lrLR where each character "
70 "can be z (free end) or x (regular end) representing "
71 "left and right ends. First sequence's ends are specified first.",
75 argdescr->AddDefaultKey
77 "gap preference: earlier or later",
81 argdescr->AddDefaultKey
82 (
"Wm",
"match",
"match bonus (nucleotide sequences)",
86 argdescr->AddDefaultKey
87 (
"Wms",
"mismatch",
"mismatch penalty (nucleotide sequences)",
91 argdescr->AddDefaultKey
92 (
"Wg",
"gap",
"gap opening penalty",
96 argdescr->AddDefaultKey
97 (
"Ws",
"space",
"gap extension (space) penalty",
101 argdescr->AddDefaultKey
102 (
"band",
"band",
"Band width in banded alignment",
105 argdescr->AddDefaultKey
107 "Band shift in banded alignment "
108 "(specify negative value to indicate second sequence)",
111 argdescr->AddFlag(
"sw",
112 "run local alignment (Smith-Waterman)");
114 argdescr->AddFlag(
"mm",
115 "Use linear-memory alignment algorithm (Myers & Miller)");
117 argdescr->AddFlag(
"mt",
"Use multiple threads");
120 argdescr->AddOptionalKey
123 argdescr->AddOptionalKey
126 argdescr->AddOptionalKey
128 "Generate gapped FastA output for the aligner sequences",
131 argdescr->AddOptionalKey
136 argdescr->SetConstraint(
"matrix", paa_st);
143 argdescr->SetConstraint(
"esf", paa_esf);
147 argdescr->SetConstraint(
"gp", paa_gp);
162 unique_ptr<ofstream> pofs0 (
new ofstream (filename.c_str()) );
169 "Cannot write to file" + filename);
179 const bool bMM = args[
"mm"];
180 const bool bMT = args[
"mt"];
182 bool output_type1 ( args[
"o1"] );
183 bool output_type2 ( args[
"o2"] );
184 bool output_asn ( args[
"oasn"] );
185 bool output_fasta ( args[
"ofasta"] );
187 int band (args[
"band"].AsInteger());
188 int shift(args[
"shift"].AsInteger());
192 eInconsistentParameters,
193 "Mutliple thread mode supported "
194 "for Myers-Miller method only (invoke with -mm)");
197 if(bMM && band >= 0) {
199 eInconsistentParameters,
200 "-mm and -band are inconsistent with each other");
207 "This application was built without multithreading support. "
208 "To run in multiple threads, please re-configure and rebuild"
209 " with proper options.");
226 pnwaligner =
new CMMAligner(&v1[0], v1.size(), &
v2[0],
v2.size(), psm);
229 pnwaligner =
new CNWAligner(&v1[0], v1.size(), &
v2[0],
v2.size(), psm);
234 Uint1 where = shift >= 0? 0: 1;
239 unique_ptr<CNWAligner> aligner (pnwaligner);
242 aligner->SetWm (args[
"Wm"]. AsInteger());
243 aligner->SetWms (args[
"Wms"].AsInteger());
244 aligner->SetScoreMatrix(
NULL);
246 aligner->SetWg (args[
"Wg"]. AsInteger());
247 aligner->SetWs (args[
"Ws"]. AsInteger());
249 aligner->SetScoreMatrix(psm);
254 pmma -> EnableMultipleThreads();
257 unique_ptr<ofstream> pofs1;
258 unique_ptr<ofstream> pofs2;
259 unique_ptr<ofstream> pofsAsn;
260 unique_ptr<ofstream> pofsFastA;
263 pofs1.reset(
open_ofstream (args[
"o1"].AsString()).release());
267 pofs2.reset(
open_ofstream (args[
"o2"].AsString()).release());
271 pofsAsn.reset(
open_ofstream (args[
"oasn"].AsString()).release());
275 pofsFastA.reset(
open_ofstream (args[
"ofasta"].AsString()).release());
279 string ends = args[
"esf"].AsString();
280 bool L1 = ends[0] ==
'z';
281 bool R1 = ends[1] ==
'z';
282 bool L2 = ends[2] ==
'z';
283 bool R2 = ends[3] ==
'z';
284 aligner->SetEndSpaceFree(L1, R1, L2, R2);
287 aligner->SetSmithWaterman(args[
"sw"]);
289 if( args[
"gp"].AsString() ==
"earlier" ) {
291 }
else if (args[
"gp"].AsString() ==
"later") {
297 int score = aligner->Run();
298 cerr <<
"Score = " << score << endl;
303 const size_t line_width = 100;
320 if(pofsFastA.get()) {
325 if(!output_type1 && !output_type2
326 && !output_asn && !output_fasta)
341 vector<char>* sequence)
const
343 vector<char>& vOut = *sequence;
346 ifstream ifs(filename.c_str());
352 if(
str[0] ==
'>' ) {
368 copy(s.begin(), s.end(), back_inserter(vOut));
380 int main(
int argc,
const char* argv[])
virtual int Run()
Run the application.
CRef< objects::CSeq_id > x_ReadFastaFile(const string &filename, vector< char > *sequence) const
virtual void Exit()
Cleanup on application exit.
virtual void Init()
Initialize the application.
static const char * str(char *buf, int n)
static TScore GetDefaultWg(void)
static TScore GetDefaultWms(void)
static TScore GetDefaultWs(void)
void SetShift(Uint1 where, size_t offset)
static TScore GetDefaultWm(void)
void HideStdArgs(THideStdArgs hide_mask)
Set the hide mask for the Hide Std Flags.
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
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.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ fHideLogfile
Hide log file description.
@ fHideConffile
Hide configuration file description.
@ fHideVersion
Hide version description.
CArgAllow_Strings * Allow(const string &value)
Add allowed string values.
@ eString
An arbitrary string.
@ eInteger
Convertible into an integer number (int or Int8)
@ eDS_Default
Try standard log file (app.name + ".log") in /log/, use stderr on failure.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Reset(void)
Reset reference object.
uint8_t Uint1
1-byte (8-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & ToUpper(string &str)
Convert string to upper case – string& version.
#define GetProgramName
Avoid name clash with the NCBI C Toolkit.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
unique_ptr< ofstream > open_ofstream(const string &filename)
int main(int argc, const char *argv[])
const SNCBIPackedScoreMatrix NCBISM_Blosum62