本文整理匯總了C++中SiteContainer::addSequence方法的典型用法代碼示例。如果您正苦於以下問題:C++ SiteContainer::addSequence方法的具體用法?C++ SiteContainer::addSequence怎麽用?C++ SiteContainer::addSequence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SiteContainer
的用法示例。
在下文中一共展示了SiteContainer::addSequence方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: appendAlignmentFromStream
void DCSE::appendAlignmentFromStream(istream& input, SiteContainer& sc) const throw (Exception)
{
// Checking the existence of specified file
if (!input) { throw IOException ("DCSE::read : fail to open file"); }
// Initialization
const Alphabet * alpha = sc.getAlphabet();
string line, name, sequence = "";
line = FileTools::getNextLine(input); // Copy current line in temporary string
//StringTokenizer st(line);
//st.nextToken();
//First line ignored for now!
//int n1 = TextTools::toInt(st.nextToken());
//int n2 = TextTools::toInt(st.nextToken());
//int nbSites = n2 - n1
//cout << nbSpecies << " species and " << nbSites << " sites." << endl;
// Main loop : for all file lines
while (!input.eof())
{
line = FileTools::getNextLine(input); // Copy current line in temporary string
if(line == "") break;
string::size_type endOfSeq = line.find(" ");
if(endOfSeq == line.npos) break;
sequence = string(line.begin(), line.begin() + static_cast<ptrdiff_t>(endOfSeq));
sequence = TextTools::removeWhiteSpaces(sequence);
sequence = TextTools::removeChar(sequence, '{');
sequence = TextTools::removeChar(sequence, '}');
sequence = TextTools::removeChar(sequence, '[');
sequence = TextTools::removeChar(sequence, ']');
sequence = TextTools::removeChar(sequence, '(');
sequence = TextTools::removeChar(sequence, ')');
sequence = TextTools::removeChar(sequence, '^');
name = string(line.begin() + static_cast<ptrdiff_t>(endOfSeq + 1), line.end()),
name = TextTools::removeFirstWhiteSpaces(name);
if(name.find("Helix numbering") == name.npos
&& name.find("mask") == name.npos)
sc.addSequence(BasicSequence(name, sequence, alpha), true);
}
}
示例2: main
int main() {
//ProteicAlphabet* alpha = new ProteicAlphabet;
RNA* alpha = new RNA();
SiteContainer* sites = new VectorSiteContainer(alpha);
BasicSequence seq1("seq1", "----AUGCCG---GCGU----UUU----G--G-CCGACGUGUUUU--", alpha);
BasicSequence seq2("seq2", "---GAAGGCG---G-GU----UUU----GC-GACCGACG--UUUU--", alpha);
sites->addSequence(seq1, false);
sites->addSequence(seq2, false);
cout << sites->getNumberOfSites() << endl;
cout << sites->toString("seq1") << endl;
cout << sites->toString("seq2") << endl;
SiteContainerTools::removeGapOnlySites(*sites);
cout << endl;
cout << sites->getNumberOfSites() << endl;
cout << sites->toString("seq1") << endl;
cout << sites->toString("seq2") << endl;
return (sites->getNumberOfSites() == 30 ? 0 : 1);
}
示例3: appendAlignmentFromStream
void Clustal::appendAlignmentFromStream(std::istream& input, SiteContainer & sc) const throw (Exception)
{
// Checking the existence of specified file
if (!input) { throw IOException ("Clustal::read : fail to open file"); }
const Alphabet * alpha = sc.getAlphabet();
vector<BasicSequence> sequences;
string lineRead("");
Comments comments(1);
comments[0] = FileTools::getNextLine(input); // First line gives file generator.
lineRead = FileTools::getNextLine(input); // This is the first sequence of the first block.
string::size_type beginSeq = 0;
unsigned int count = 0;
for (size_t i = lineRead.size(); i > 0; i--) {
char c = lineRead[i-1];
if (c == ' ') {
count++;
if (count == nbSpacesBeforeSeq_) {
beginSeq = i - 1 + nbSpacesBeforeSeq_;
break;
}
}
else count = 0;
}
if (beginSeq == 0) throw IOException("Clustal::read. Bad intput file.");
unsigned int countSequences = 0;
//Read first sequences block:
bool test = true;
do {
sequences.push_back(BasicSequence(TextTools::removeSurroundingWhiteSpaces(lineRead.substr(0, beginSeq - nbSpacesBeforeSeq_)), lineRead.substr(beginSeq), alpha));
getline(input, lineRead, '\n');
countSequences++;
test = !TextTools::isEmpty(lineRead) && !TextTools::isEmpty(lineRead.substr(0, beginSeq - nbSpacesBeforeSeq_));
}
while (input && test);
// Read other blocks
lineRead = FileTools::getNextLine(input); // Read first sequence of next block.
while (!TextTools::isEmpty(lineRead)) {
// Read next block:
for (unsigned int i = 0; i < countSequences; ++i) {
// Complete sequences
if (TextTools::isEmpty(lineRead))
throw IOException("Clustal::read. Bad intput file.");
sequences[i].append(lineRead.substr(beginSeq));
getline(input, lineRead, '\n');
}
//At this point, lineRead is the first line after the current block.
lineRead = FileTools::getNextLine(input);
}
for (unsigned int i = 0; i < countSequences; ++i)
sc.addSequence(sequences[i], checkNames_);
sc.setGeneralComments(comments);
}