#ifndef ALIGNMENT_H #define ALIGNMENT_H #include "Alphabet/Alphabet.h" #include "AlphabetTuple/AlphabetTuple.h" #include class alignment { private: void alloc(void); // allocate arrays based on num_seqs and width void alloc_for_a2m(istream &in); // read the a2m file from in, retaining only width and num_seqs // then call alloc to allocate space for second pass read. inline void clear(void) // set all pointers to 0 { alignmentID = NULL; Filename = NULL; names = NULL; data=NULL; weights=NULL; insert_before=NULL; num_seqs=0; width=0; }; void delete_all(void); // remove all arrays, and clear pointers public: const Alphabet *alphabet; char *Filename; char *alignmentID; // just up to first ; of ID field int width; // number of characters per sequence int num_seqs; // number of sequences char **names; // array of num_seqs names Base **data; // array of sequences data[num_seqs][width] char **insert_before; // non-zero if there is an insertion before // data[i][j] (array has width+1 positions) float *weights; // array of num_seqs sequence weights alignment(void) {clear();} ~alignment(void) {delete_all();} void read_a2m(const char *full_filename, const AlphabetTuple *alpha); // open an read SAM-style alignment // (a FASTA file with . and lowercase in insert positions) // only the match positions are used, insertions are just counted. inline double total_weight(void) const { if (!weights) return 0; double total=0.; for (int i=num_seqs-1; i>=0; i--) total += weights[i]; return total; } // report the weights in a format suitable for SAM void report_weights(ostream &out) const; inline int alphabet_size(void) const { return alphabet->norm_length(); } // Returns a newly allocated copy of the first sequence of data. // This sequence is taken to be the alignemnts guide sequence. Base *first_sequence(void) const; }; // CHANGE LOG // 20 July 1997 Kevin Karplus // borrowed and rewritten from estimate-dist, keeping only a2m format. // 21 April 2004 Sol Katzman // Changed first_sequence to Base* from char* // 24 May 2004 Kevin Karplus // inlined simple functions #endif