📄 proteinseq.cpp
字号:
// ProteinSeq.cpp: implementation of the ProteinSeq class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Perm.h"
#include "ProteinSeq.h"
using namespace std;
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ProteinSeq::ProteinSeq(CString& initialStr, int energe){
originStr = initialStr;
sequence = parseString(initialStr, 0);
length = sequence.GetLength();
sequence.MakeUpper();
recorderEnerge = energe;
reversed = false;
}
ProteinSeq::~ProteinSeq(){
}
int ProteinSeq::getLength() const{
return length;
}
int ProteinSeq::getRecorderEnergy() const{
return recorderEnerge;
}
CString ProteinSeq::getSequence() const{
return sequence;
}
CString ProteinSeq::getOriginStr() const{
return originStr;
}
CString ProteinSeq::parseString(const CString& origin, int startPoint){
CString temp("");
if( startPoint >= origin.GetLength() )
return temp;
int tempPoint = startPoint;
int i, count = 1;
bool init = true;
int match = 1;
CString buffer("");
CString totalBuffer("");
switch(origin.GetAt(startPoint)) {
case 'H': case 'P': case 'p': case 'h':
startPoint++;
while( startPoint < origin.GetLength() && isdigit(origin.GetAt(startPoint)) ){
if(init){
count = origin.GetAt(startPoint)-48;
init = false;
}
else{
count = count*10 + origin.GetAt(startPoint)-48;
}
startPoint++;
}
for( i=0; i < count ; i++)
temp += origin.GetAt(tempPoint);
return temp += parseString(origin, startPoint);
break;
case '(':
while(true){
startPoint++;
if(origin.GetAt(startPoint) == ')')
match--;
if(match ==0 )
break;
if(origin.GetAt(startPoint) == '(')
match++;
}
buffer = origin.Mid(tempPoint+1, startPoint-tempPoint-1);
buffer = parseString(buffer,0);
startPoint++;
while( startPoint < origin.GetLength() && isdigit(origin.GetAt(startPoint)) ){
if(init){
count = origin.GetAt(startPoint)-48;
init = false;
}
else{
count = count*10 + origin.GetAt(startPoint)-48;
}
startPoint++;
}
for( i=0; i < count ; i++)
totalBuffer += buffer;
if(startPoint == origin.GetLength())
return temp += totalBuffer;
else{
count = origin.GetLength() - startPoint;
return temp += totalBuffer + parseString(origin.Right(count), 0);
}
break;
default:
return temp;
}
}
bool ProteinSeq::isReversed() const{
return reversed;
}
void ProteinSeq::reverseSeq(){
if(reversed)
reversed = false;
else
reversed = true;
sequence.MakeReverse();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -