21 AlignedSequenceLoader::AlignedSequenceLoader(
GBDATA *
gb_main) :
41 size_t occurrences[MSA_len];
42 for (
size_t i = 0; i < MSA_len; i++) occurrences[i] = 0;
44 cout <<
"loading marked species: ";
62 string *seq_as_vec =
new string[MSA_len];
64 for (string::iterator i = sequence.begin(); i != sequence.end(); ++i) {
96 vector<string> seq_vector(&seq_as_vec[0], &seq_as_vec[k]);
99 seqs->push_back(seq_vector);
103 cout <<
"done. Total number of species: " << seqs->size() << endl;
106 cleanSeqs(occurrences, MSA_len);
121 VecVecType* AlignedSequenceLoader::getSequences() {
130 AlignedSequenceLoader::~AlignedSequenceLoader() {
139 size_t AlignedSequenceLoader::getMsaLen() {
150 const vector<size_t>& AlignedSequenceLoader::getPositionMap() {
163 void AlignedSequenceLoader::cleanSeqs(
const size_t *occurrences,
long len) {
165 cout <<
"cleaning-up sequences of empty positions... " << endl;
168 size_t num_of_bases = 0;
169 for (
int i = 0; i < len; i++) {
170 if (occurrences[i] != 0) {
175 cout <<
"number of non-empty positions in MSA: " << num_of_bases
176 <<
". Filtered out " << len - num_of_bases <<
" positions." << endl;
180 cout <<
"computing position map..." << endl;
181 position_map.resize(num_of_bases, 0);
184 for (
int i = 0; i < len; i++) {
185 if (occurrences[i] != 0) {
186 position_map.at(j) = i;
191 for (VecVecType::iterator
seq = seqs->begin();
seq != seqs->end(); ++
seq) {
193 vector<string> sequence(num_of_bases,
"");
195 for (
int i = 0; i < len; ++i) {
196 if (occurrences[i] != 0) {
197 sequence.at(jj) =
seq->at(i);
202 clean_seqs->push_back(sequence);
208 cout <<
"clean-up done." << endl;
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
const char * GBS_global_string(const char *templat,...)
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
GB_ERROR GB_push_transaction(GBDATA *gbd)
GB_ERROR GB_await_error()
static void error(const char *msg)
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
vector< vector< string > > VecVecType
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
char * GBT_get_default_alignment(GBDATA *gb_main)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)