Bsoft  2.1.0
Bernard's software package
bcatseq.cpp
Go to the documentation of this file.
1 
9 #include "rwmolecule.h"
10 #include "utilities.h"
11 #include "options.h"
12 #include "timer.h"
13 
14 // Declaration of global variables
15 extern int verbose; // Level of output to the screen
16 
17 // Usage assistance
18 const char* use[] = {
19 " ",
20 "Usage: bcatseq [options] input.seq input2.seq",
21 "---------------------------------------------",
22 "Concatenates protein sequences from different files.",
23 "Multiple sequences in the different files must be in the same order.",
24 " ",
25 "Parameters:",
26 "-verbose 7 Verbosity of output.",
27 " ",
28 "Output:",
29 "-output output.embl Output sequence file (default temp.star).",
30 " ",
31 NULL
32 };
33 
34 int main(int argc, char **argv)
35 {
36  // Initialize variables
37  Bstring atom_select("all"); // Selection
38  Bstring catfile("temp.star"); // Default output file
39  Bstring paramfile; // Use default parameter file
40 
41  int i, optind;
42  Boption* option = get_option_list(use, argc, argv, optind);
43  Boption* curropt;
44  for ( curropt = option; curropt; curropt = curropt->next ) {
45  if ( curropt->tag == "output" )
46  catfile = curropt->filename();
47  }
48  option_kill(option);
49 
50  double ti = timer_start();
51 
52  // Read all the sequence files
53  Bmolgroup* catgroup = NULL;
54  Bmolgroup* molgroup = NULL;
55  Bmolecule* catmol = NULL;
56  Bmolecule* mol = NULL;
57  Bstring filename;
58 
59  i = 0;
60  while ( optind < argc ) {
61  filename = argv[optind++];
62  molgroup = read_molecule(filename, atom_select, paramfile);
63  if ( i == 0 ) catgroup = molgroup;
64  else {
65  for ( mol = molgroup->mol, catmol = catgroup->mol; mol; mol = mol->next, catmol = catmol->next ) {
66  catmol->seq += mol->seq;
67  catmol->id += mol->id;
68  catmol->nres += mol->nres;
69  }
70  molgroup_kill(molgroup);
71  }
72  i++;
73  }
74 
75  write_molecule(catfile, catgroup);
76 
77  molgroup_kill(catgroup);
78 
79  if ( verbose & VERB_TIME )
80  timer_report(ti);
81 
82  bexit(0);
83 }
84 
Boption
A class for a command line input option.
Definition: options.h:26
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
Bstring
Definition: Bstring.h:29
Boption::next
Boption * next
Definition: options.h:28
Bmolgroup::mol
Bmolecule * mol
Definition: rwmolecule.h:189
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:280
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
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
options.h
Header file for option handlers.
Bmolecule::nres
long nres
Definition: rwmolecule.h:111
use
const char * use[]
Definition: bcatseq.cpp:18
Bmolecule::seq
Bstring seq
Definition: rwmolecule.h:114
main
int main(int argc, char **argv)
Definition: bcatseq.cpp:34
Boption::tag
Bstring tag
Definition: options.h:29
verbose
int verbose
rwmolecule.h
Header file for reading reflection files.
Bmolecule::next
Bmolecule * next
Definition: rwmolecule.h:108
Bmolecule
Definition: rwmolecule.h:107
timer.h
Utilities for timing functions.
VERB_TIME
#define VERB_TIME
Definition: utilities.h:114
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:61
utilities.h
Header file for general utilities.
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:76
write_molecule
int write_molecule(char *filename, Bmolgroup *molgroup)
Writes a molecule group.
Definition: rwmolecule.cpp:975
Boption::filename
Bstring filename()
Definition: options.h:85
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:111
Bmolgroup
Definition: rwmolecule.h:170
Bmolecule::id
Bstring id
Definition: rwmolecule.h:110