63 arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
64 "Make alignment scoring method files");
66 arg_desc->AddDefaultKey(
"out",
"output",
"File name for scoring method",
69 arg_desc->AddOptionalKey(
"sm",
"matrix",
"name of score matrix to use",
71 arg_desc->SetConstraint
73 "blosum45",
"blosum62",
"blosum80",
"pam30",
"pam70",
"pam250"));
75 arg_desc->AddOptionalKey(
"aa",
"accession",
76 "Amino Acid Index Database accession number",
78 arg_desc->AddDefaultKey(
"in",
"aaindex_file",
79 "Amino Acid Index Database input file.",
96 if (sm ==
"blosum45") {
99 " Matrix made by matblas from blosum45.iij\\\n"
100 " BLOSUM Clustered Scoring Matrix in 1/3 Bit Units\\\n"
101 " Blocks Database = /data/blocks_5.0/blocks.dat\\\n"
102 " Cluster Percentage: >= 45\\\n"
103 " Entropy = 0.3795, Expected = -0.2789";
104 }
else if (sm ==
"blosum62") {
107 " Matrix made by matblas from blosum62.iij\\\n"
108 " BLOSUM Clustered Scoring Matrix in 1/2 Bit Units\\\n"
109 " Blocks Database = /data/blocks_5.0/blocks.dat\\\n"
110 " Cluster Percentage: >= 62\\\n"
111 " Entropy = 0.6979, Expected = -0.5209";
112 }
else if (sm ==
"blosum80") {
115 " Matrix made by matblas from blosum80.iij\\\n"
116 " BLOSUM Clustered Scoring Matrix in 1/2 Bit Units\\\n"
117 " Blocks Database = /data/blocks_5.0/blocks.dat\\\n"
118 " Cluster Percentage: >= 80\\\n"
119 " Entropy = 0.9868, Expected = -0.7442";
120 }
else if (sm ==
"pam30") {
123 " This matrix was produced by \\\"pam\\\" Version 1.0.6 [28-Jul-93]\\\n"
124 " PAM 30 substitution matrix, scale = ln(2)/2 = 0.346574\\\n"
125 " Expected score = -5.06, Entropy = 2.57 bits\\\n"
126 " Lowest score = -17, Highest score = 13";
127 }
else if (sm ==
"pam70") {
130 " This matrix was produced by \\\"pam\\\" Version 1.0.6 [28-Jul-93]\\\n"
131 " PAM 70 substitution matrix, scale = ln(2)/2 = 0.346574\\\n"
132 " Expected score = -2.77, Entropy = 1.60 bits\\\n"
133 " Lowest score = -11, Highest score = 13";
134 }
else if (sm ==
"pam250") {
137 " This matrix was produced by \\\"pam\\\" Version 1.0.7 [01-Feb-98]\\\n"
138 " using Dayhoff et al. (1978) mutability data.\\\n"
139 " PAM 250 substitution matrix, scale = ln(2)/3 = 0.231049\\\n"
140 " Expected score = -0.844, Entropy = 0.354 bits\\\n"
141 " Lowest score = -8, Highest score = 17";
146 out_map[
"Name"] = sm;
147 out_map[
"Builtin"] = sm;
148 out_map[
"Description"] = desc.
empty() ? sm : desc;
157 for (
int i = 0;
i < l; ++
i) {
159 for (
int j = 0; j < l; ++j) {
173 if ( ! out_map[name].
empty()) {
174 out << name <<
" = " << out_map[name] << endl;
181 const string& m_line,
184 out_map[
"Method"] =
"MatrixScore";
191 list<string>::iterator tok_it;
192 tok_it = find(toks.begin(), toks.end(),
"=");
193 if (tok_it == toks.end())
196 string row_bases(*tok_it);
198 tok_it = find(++tok_it, toks.end(),
"=");
199 if (tok_it == toks.end())
202 string col_bases(*tok_it);
205 int cols = col_bases.size();
206 string symbols(1, col_bases[0]);
207 for (
int i = 1;
i < cols; ++
i) {
208 char c = col_bases[
i];
209 if (
isupper((
unsigned char) c) || c ==
'-') {
214 out_map[
"Columns"] = symbols;
219 int rows = row_bases.
size();
220 for (
int r = 0;
r < rows; ++
r) {
221 if (! getline(
in, line))
223 out_rows += row_bases[
r];
228 out_map[
"TableRows"] = out_rows;
238 out_map[
"Method"] =
"ColumnScore";
248 ITERATE(list<string>, score_it, scores) {
251 out_rows += *score_it;
255 out_map[
"TableRows"] = out_rows;
264 while (getline(
in, line)) {
265 if (line ==
"H " + accession)
269 cerr <<
"Accession \"" << accession <<
"\" not found." << endl;
276 while (getline(
in, line)) {
284 current_key =
"Description";
285 out_map[current_key] = line;
292 current_key =
"Description";
293 out_map[current_key] +=
"\\\n " + line;
296 if ( ! current_key.empty()) {
297 out_map[current_key] +=
"\\\n " +line;
307 cerr <<
"Bad format in M section at accession \""
308 << accession <<
"\"" << endl;
314 cerr <<
"Bad format in I section at accession \""
315 << accession <<
"\"" << endl;
323 cerr <<
"No I or M section at accession \""
324 << accession <<
"\"" << endl;
334 if (args[
"sm"] && args[
"aa"] ) {
335 string msg =
"Options -sm and -aa are mutually exclusive.\n";
348 out_line[
"Method"] =
"MatrixScore";
349 out_line[
"Type"] =
"Protein";
350 out_line[
"MinimumColor"] =
"yellow3";
351 out_line[
"MaximumColor"] =
"royal blue";
355 }
else if (args[
"aa"]) {
356 if (!
s_ReadAAIndex(args[
"aa"].AsString(), args[
"in"].AsInputFile(), out_line)) {
362 out <<
"[Info]" << endl;
368 out <<
"[Table]" << endl;
378 out <<
"[TableRows]" << endl;
379 out << out_line[
"TableRows"];
int Run(void)
Run the application.
void Init(void)
Initialize the application.
std::ofstream out("events_result.xml")
main entry point for tests
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.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
const CArgDescriptions * GetArgDescriptions(void) const
Get argument descriptions (set by SetupArgDescriptions)
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
virtual string & PrintUsage(string &str, bool detailed=false) const
Print usage message to end of specified string.
@ eInputFile
Name of file (must exist and be readable)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
static bool sReadAA_I(CNcbiIstream &in, map< string, string > &out_map)
static const string kAAIndexOrder("ARNDCQEGHILKMFPSTWYV")
int NcbiSys_main(int argc, ncbi::TXChar *argv[])
static void s_BuiltInSM(const string &sm, map< string, string > &out_map)
static void sWriteLine(CNcbiOstream &out, map< string, string > &out_map, const string &name)
static bool sReadAA_M(CNcbiIstream &in, const string &m_line, map< string, string > &out_map)
bool s_ReadAAIndex(const string &accession, CNcbiIstream &in, map< string, string > &out_map)
static string s_FormatAA(int aa)
constexpr bool empty(list< Ts... >) noexcept
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Process information in the NCBI Registry, including working with configuration files.
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
const SNCBIPackedScoreMatrix NCBISM_Pam30
const SNCBIPackedScoreMatrix NCBISM_Blosum62
const SNCBIPackedScoreMatrix NCBISM_Pam250
const SNCBIPackedScoreMatrix NCBISM_Blosum80
const SNCBIPackedScoreMatrix NCBISM_Pam70
const SNCBIPackedScoreMatrix NCBISM_Blosum45
The standard matrices.
const TNCBIScore * scores
strlen(symbols) x strlen(symbols)
const char * symbols
order of residues
static char line1[1024 *16]
static char line2[1024 *16]