5 * Created by Thomas Ryabin on 4/24/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "readseqsphylip.h"
14 /*******************************************************************************/
15 bool ReadPhylip::isSeq(string seq) {
16 string validChars[] = {"A","G","C","T","U","N","-"};
18 for(int i = 0; i < seq.length(); i++) {
20 string c = seq.substr(i,1);
21 for(int k = 0; k < 7; k++)
22 if(c.compare(validChars[k]) == 0) {
33 /*******************************************************************************/
34 ReadPhylip::ReadPhylip(string file) : ReadSeqs(file) { }
35 /*******************************************************************************/
36 ReadPhylip::~ReadPhylip(){
37 // for(int i = 0; i < sequencedb.getNumSeqs(); i++)
38 // delete sequencedb.get(i);
40 /*******************************************************************************/
41 void ReadPhylip::read() {
50 int numSeqs = atoi(temp.c_str());
52 int numLetters = atoi(temp.c_str());
54 bool firstDone = false;
58 while(!filehandle.eof()) {
68 letterCount += sequence.length();
71 for(int i = 0; i < numCols; i++) {
78 Sequence newSeq(name, sequence);
79 sequencedb.add(newSeq);
85 for(int i = 0; i < numCols; i++) {
89 letterCount += temp.length();
90 if(letterCount == numLetters && count == 0) {
95 if(!(last && count == 0))
96 sequencedb.set(count, sequencedb.get(count).getUnaligned() + sequence);
97 if(letterCount == numLetters && count == 0)
103 if(count == numSeqs) {
111 /*********************************************************************************/
112 SequenceDB* ReadPhylip::getDB() {