| Bsoft 2.0.5 Bernard's software package

bcormut.cpp
Go to the documentation of this file.
1
9 #include "seq_analysis.h"
10 #include "rwmolecule.h"
11 #include "rwimg.h"
12 #include "utilities.h"
13 #include "options.h"
14 #include "timer.h"
15
16 // Declaration of global variables
17 extern int verbose; // Level of output to the screen
18
19 // Usage assistance
20 const char* use[] = {
21 " ",
22 "Usage: bcormut [options] input.pir output.pir",
23 "---------------------------------------------",
24 "Analyzes for correlated mutations in aligned protein sequences.",
25 "The -cutoff option must be used to do the correlated mutation analysis.",
26 "All sequence numbers and position numbers start at 1.",
27 "Sequence numbering is according to the input, including gaps.",
28 "Example: bcormut -verbose 7 -cutoff 0.4 -image coeff.map -datatype byte seq.pir",
29 " ",
30 "Actions:",
31 "-cutoff 0.3 Correlated mutations: cutoff to report.",
32 " ",
33 "Parameters:",
34 "-verbose 7 Verbosity of output.",
35 "-datatype b Set the output image data type.",
36 "-reference 3 Reference sequence (default 1).",
37 " ",
38 "Input:",
39 "-properties file.star Property file (default = internal values).",
40 " ",
41 "Output:",
42 "-image file.map Correlation coefficient matrix as an image.",
43 " ",
44 NULL
45 };
46
47 int main(int argc, char **argv)
48 {
49 // Initialize variables
50 DataType nudatatype(Unknown_Type); // Conversion to new type
51 int refseq(0); // Reference sequence
52 double cutoff(0.8); // Cutoff for scoring functions
53 Bstring atom_select("ALL"); // Selection/options
54
55 // Initialize the file names and image structure
56 Bstring imgfile;
57 Bstring propfile;
58 Bimage* pimg = NULL;
59
60 int i, j, optind;
61 Boption* option = get_option_list(use, argc, argv, optind);
62 Boption* curropt;
63 for ( curropt = option; curropt; curropt = curropt->next ) {
64 if ( curropt->tag == "datatype" )
65 nudatatype = curropt->datatype();
66 if ( curropt->tag == "reference" ) {
67 if ( ( refseq = curropt->value.integer() ) < 1 )
68 cerr << "-reference: A reference sequence number must be specified!" << endl;
69 else
70 refseq--; // Sequence numbers start at 1 as far as the user is concerned
71 }
72 if ( curropt->tag == "cutoff" )
73 if ( ( cutoff = curropt->value.real() ) < 1 )
74 cerr << "-cutoff: A cutoff must be specified!" << endl;
75 if ( curropt->tag == "properties" )
76 propfile = curropt->filename();
77 if ( curropt->tag == "image" )
78 imgfile = curropt->filename();
79 }
80 option_kill(option);
81
82 double ti = timer_start();
83
84 // Read the molecule file
85 Bstring filename(argv[optind++]);
86 Bmolgroup* molgroup = read_molecule(filename, atom_select, propfile);
87 if ( !molgroup ) {
88 cerr << "Error: No input file read!" << endl;
89 bexit(-1);
90 }
91
92 if ( refseq < 0 ) refseq = 0;
93 // if ( refseq >= molgroup->num ) refseq = 0;
94
95 j = 0;
96 for ( i=0; i<molgroup->maxlen; i++ )
97 j += molgroup->seqflag[i];
98
99 if ( verbose & VERB_PROCESS )
100 cout << "Alignment positions flagged: " << j << endl;
101
102 pimg = seq_correlated_mutation(molgroup, refseq, cutoff, propfile);
103
104 if ( optind < argc )
105 write_molecule(argv[optind], molgroup);
106
107 molgroup_kill(molgroup);
108
109 if ( imgfile.length() && pimg ) {
110 pimg->change_type(nudatatype);
111 pimg->label(get_cmd_line(argc, argv));
112 write_img(imgfile, pimg, 0);
113 }
114
115 delete pimg;
116
117 if ( verbose & VERB_TIME )
118 timer_report(ti);
119
120 bexit(0);
121 }
122
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1743
Bstring::real
double real()
Definition: Bstring.cpp:545
write_molecule
int write_molecule(char *filename, Bmolgroup *molgroup)
Writes a molecule group.
Definition: rwmolecule.cpp:975
DataType
DataType
Base data type specifier.
Definition: utilities.h:146
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
Bmolgroup::seqflag
int * seqflag
Definition: rwmolecule.h:188
Boption::tag
Bstring tag
Definition: options.h:29
seq_correlated_mutation
Bimage * seq_correlated_mutation(Bmolgroup *molgroup, int refseqnum, double cutoff, Bstring &simfile)
Correlated mutation analysis of an alignment.
Definition: seq_analysis.cpp:676
Bstring::length
long length() const
Definition: Bstring.cpp:263
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
main
int main(int argc, char **argv)
Definition: bcormut.cpp:47
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
get_cmd_line
string get_cmd_line(int argc, char **argv)
Returns the command line as a string.
Definition: utilities.cpp:36
Boption::filename
Bstring filename()
Definition: options.h:85
timer.h
Utilities for timing functions.
Bimage
General image parameter class.
Definition: Bimage.h:163
verbose
int verbose
rwmolecule.h
Header file for reading reflection files.
Bmolgroup
Definition: rwmolecule.h:170
Boption
A class for a command line input option.
Definition: options.h:26
Bimage::label
void label(string s)
Definition: Bimage.h:235
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
Bmolgroup::maxlen
long maxlen
Definition: rwmolecule.h:180
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:280
seq_analysis.h
Header file for sequence analysis functions.
use
const char * use[]
Definition: bcormut.cpp:20
Boption::datatype
DataType datatype()
Definition: options.h:93
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Bstring::integer
long integer()
Definition: Bstring.cpp:539
Unknown_Type
Definition: utilities.h:147
rwimg.h
Header file for 2D and 3D image I/O.
options.h
Header file for option handlers.
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
read_molecule
Bmolgroup * read_molecule(const char *filename, const char *select, const char *paramfile)
The generalized function for reading molecular files.
Definition: rwmolecule.cpp:818