5 * Created by Alan You on 8/11/08.
6 * Copyright 2008 Hudson Alpha. All rights reserved.
28 Peak::Peak(string line)
30 istringstream outStream;
32 vector<string> fields;
34 split(line,delim,fields);
36 this->chrom = fields[0];
37 this->startBP = atoi(fields[1].c_str());
38 this->endBP = atoi(fields[2].c_str());
39 this->score = strtod(fields[3].c_str(), NULL);
40 this->length = this->endBP - this->startBP;
44 Peak::Peak(const Peak& p)
46 this->startBP = p.startBP;
47 this->endBP = p.endBP;
48 this->length = p.length;
49 this->chrom = p.chrom;
50 this->score = p.score;
51 this->sequence = p.sequence;
61 cout << "Chromosome:\t\t" << this->chrom.c_str() << endl;
62 cout << "Starting Base Pair:\t" << this->startBP << endl;
63 cout << "Ending Base Pair:\t" << this->endBP << endl;
64 cout << "Sequence Length:\t" << this->length << endl;
65 cout << "Sequence Score:\t\t" << this->score << endl;
66 cout << "Sequence:\t\t" << this->sequence << endl;
69 void Peak::printToFile(ofstream &outputFile)
71 outputFile << "Chromosome:\t\t" << this->chrom.c_str() << endl;
72 outputFile << "Starting Base Pair:\t" << this->startBP << endl;
73 outputFile << "Ending Base Pair:\t" << this->endBP << endl;
74 outputFile << "Sequence Length:\t" << this->length << endl;
75 outputFile << "Sequence Score:\t\t" << this->score << endl;
76 outputFile << "Sequence:\t\t" << this->sequence << endl;
80 bool Peak::operator<(const Peak& that) const
82 if (this->chrom == that.chrom) { return(this->startBP < that.startBP);
83 } else { return(this->chrom < that.chrom); }
86 bool Peak::operator>(const Peak& that) const
88 if (this->chrom == that.chrom) { return(this->startBP > that.startBP);
89 } else { return(this->chrom > that.chrom); }
93 Peak& Peak:: operator=(const Peak& that)
97 this->chrom = that.chrom;
98 this->startBP = that.startBP;
99 this->endBP = that.endBP;
100 this->length = that.length;
101 this->score = that.score;
102 this->sequence = that.sequence;