Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.abitu.ru/en2002/closed/viewwork.html?work=102
Дата изменения: Fri May 5 15:25:15 2006
Дата индексирования: Tue Oct 2 02:31:47 2012
Кодировка: koi8-r

Поисковые слова: arp 220


Программа поиска сложносоставленной вариабельной матрицы в геноме.


Представляем вам заголовочный файл программы. Здесь собраны функции,
необходимые для работы программы.

#ifndef VIGG0_H
#define VIGG0_H

int FindMatrix(string &InputString, string &SearchString1, string
&SearchString2);
void Invert (string &In);
void ComplementaryStr(string &In);
void Swap(string &objA, string &objB);

class Integer_Node
{
int Node_handles;
Integer_Node *Node_next;

public:

Integer_Node(int new_carry): Node_handles(new_carry), Node_next(NULL) {};
~Integer_Node();

void SetNext(Integer_Node *set_next_node) {Node_next = set_next_node; };
Integer_Node *GetNext() const {return Node_next; };

int GetHandle () {return Node_handles; };

void InsertNode(Integer_Node *handle_new);
};

Integer_Node::~Integer_Node()
{
delete Node_next;
Node_next=NULL;
};

void Integer_Node::InsertNode(Integer_Node *handle_new)
{
if(Node_next == NULL)
{
this->Node_next = handle_new;
}
else
{
// cout<<"Data:\thandle_new->GetHandle()->Start: "< >GetHandle()->Start< // cout<<"\tthis->GetHandle()->Start: "<GetHandle()->Start< // cout<<"\tNode_next->GetHandle()->Start: "<Node_next->GetHandle()-
>Start< if (handle_new->GetHandle() >= this->GetHandle() && handle_new-
>GetHandle() < Node_next->GetHandle())
{
handle_new->SetNext(this->Node_next);
this->Node_next=handle_new;
}
else
{
Node_next->InsertNode(handle_new);
};
};
};

class String_Node
{
string Node_handles;
String_Node *Node_next;

public:

String_Node(string new_carry): Node_handles(new_carry), Node_next(NULL)
{};
~String_Node();

void SetNext(String_Node *set_next_node) {Node_next = set_next_node; };
String_Node *GetNext() const {return Node_next; };

string GetHandle () {return Node_handles; };

void InsertNode(String_Node *handle_new);
};

String_Node::~String_Node()
{
delete Node_next;
Node_next=NULL;
};

void String_Node::InsertNode(String_Node *handle_new)
{
if(Node_next == NULL)
{
this->Node_next = handle_new;
}
else
{
Node_next->InsertNode(handle_new);
};
};

void Invert(string &In)
{
unsigned int a=0;
char aux;
while (a < In.size()-1-a)
{
aux=In[a];
In[a]=In[In.size()-1-a];
In[In.size()-1-a]=aux;
a++;
};
};

void ComplementaryStr(string &In)
{
unsigned int a=0;
string temp=In;
while (a < In.size())
{
switch (In[a])
{
case 'a': temp[a]='t'; break;
case 'c': temp[a]='g'; break;
case 'g': temp[a]='c'; break;
case 't': temp[a]='a'; break;
};
a++;
};
In = temp;
};

void Swap(string &objA, string &objB)
{
string *temp = new string;
*temp = objA;
objA = objB;
objB = *temp;
delete temp;
};

string GetLine(fstream &stream)
{
string out;
char ch_ins;
while ((ch_ins = stream.get()) != EOF)
{
if (ch_ins == 10)
{
return out;
};
out.append(1, ch_ins);
};
if (out != "")
return out;
else
return "=EndOfFile=";
};

int Power(const int Base, int Power)
{
int temp1, temp2=Base;
if (Power==0)
{
return 1;
};
for (temp1=1; temp1 {
temp2=temp2*Base;
};
return temp2;
};

int StrToInt(string input)
{
unsigned int StrToInt_count1=0, output=0;
for (StrToInt_count1=0; StrToInt_count1 < input.size();
StrToInt_count1++)
{
switch (input[input.size()-1 - StrToInt_count1])
{
case '0': output+= 0; break;
case '1': output+= 1 * Power(10, StrToInt_count1); break;
case '2': output+= 2 * Power(10, StrToInt_count1); break;
case '3': output+= 3 * Power(10, StrToInt_count1); break;
case '4': output+= 4 * Power(10, StrToInt_count1); break;
case '5': output+= 5 * Power(10, StrToInt_count1); break;
case '6': output+= 6 * Power(10, StrToInt_count1); break;
case '7': output+= 7 * Power(10, StrToInt_count1); break;
case '8': output+= 8 * Power(10, StrToInt_count1); break;
case '9': output+= 9 * Power(10, StrToInt_count1); break;
default: output+= 0;
};
};
return output;
};

/*int FindMatrix(string &InputString, string &SearchString1, string
&SearchString2)
{
while (1)
{
AuxInteger1=InputString.find(SearchString1, AuxInteger2);
if (AuxInteger1 == -1)
{ return -1; }
else
{
// cout<<"SearchString 1 detected..."< BeginOut=AuxInteger1;
AuxInteger2=AuxInteger1+SearchString1.size();
AuxInteger1=InputString.find(SearchString2, AuxInteger2);
if (AuxInteger1 != -1)
{
// cout<<"SearchString 2 detected\t("< AuxInteger2<<")"< if ((AuxInteger1-AuxInteger2) == 12 || (AuxInteger1-
AuxInteger2) == 23)
{ return BeginOut+1; }
else
{
if ((AuxInteger1-AuxInteger2) > 0 && (AuxInteger1-
AuxInteger2) < 35)
{
Beep(750, 3);
cout<<"Relative Match\tInterval: "< AuxInteger2< };
}
}
else
{
return -1;
};
};
};
};*/

#endif

А вот основной код программы.

#include
#include
#include
#include

#define MAIN_STRING_MAX_CAPACITY 70000
#define MAIN_STRING_MIN_CAPACITY 100
#define REP_STR_ADD 1000
#define REP_STR_LEN 2200

#define SITE1_DEF "SITE1"
#define SITE2_DEF "SITE2"
#define SPACE_DEF "SPACE"

#define BRACKET_OPEN '<'
#define BRACKET_CLOSE '>'
#define BRACKET_COMMA ','

#include "vigg0.h"

short OrigCount=0;
int AuxInteger1=0, AuxInteger2=0, BeginOut=0;
bool ComplementScanActive=true, SoundBool=false;
char input_dir[80], input_report[20], input_sites[80];

int i_del;

void main(int argc, char *argv[])
{
cout<<"CODE:\tVIGG-0 / Algorithm B"< cout<<"UPDATE:\t21.12.2002"< cout<<"DESCRIPT:\tIG & TCR RSS searching program. Multiple files input
allowed."<
cout<<"Specify the working directory:\t"; cin>>input_dir;
cout<<"Specify the name for report file:\t"; cin>>input_report;
cout<<"Specify the file with sites data:\t"; cin>>input_sites;
cout<<"Do checking for complement sites? (NO=0)\t";
cin>>ComplementScanActive;
cout<<"Want new locus scan start signal? (NO=0)\t"; cin>>SoundBool;
cout<
//---PARAMETERS CHECK
/* switch (argc)
{
case 2: argv[2]="report.txt"; argv[3]="raw_report.txt"; break;
case 3: argv[3]="raw_report.txt"; break;
case 4: break;
default:
cout<<"Usage: program.exe [Directory with files to scan]
[Report file]\n";
exit(1);
break;
};*/

//-DIRECTORY OPERATIONS
DIR *dir;
struct dirent *ent;
if (( dir = opendir(input_dir) ) == NULL)
{
perror("ERROR");
cout<<"Put EXE file in directory with files for scanning\nProgram
takes 3 parameters:\nThe first is neccesary and it's a directory in which
you have been put this program\nOther 2 parameters are report files names
(text & table)";
exit(1);
};
//-D
fstream rep_raw(input_report);

rep_raw.clear();

String_Node *SN_Site1 = new String_Node("");
String_Node *SN_Site2 = new String_Node("");
Integer_Node *IN_Space = new Integer_Node(NULL);

String_Node *SN_Aux1 = new String_Node("");
Integer_Node *IN_Aux1 = new Integer_Node(NULL);

fstream site_data(input_sites);
if ( !site_data.is_open() )
{
cout<<"Error opening file...\n";
exit(1);
}
else
{
cout<<"Reading sites information...\n";
string SI_line, SI_str_aux1;

int SI_aux1, SI_i1;

while ((SI_line = GetLine(site_data)) != "=EndOfFile=")
{

if (SI_line.find( SITE1_DEF, 0) != -1)
{
if ((SI_aux1 = SI_line.find(BRACKET_OPEN, 0)) != -1)
{
for (SI_i1 = SI_aux1+1; SI_i1 < SI_line.size(); SI_i1++)
{
if (SI_line[SI_i1] == BRACKET_COMMA || SI_line[SI_i1] ==
BRACKET_CLOSE)
{
SN_Aux1 = new String_Node(SI_str_aux1);
SN_Site1->InsertNode(SN_Aux1);
SI_str_aux1.clear();
SI_i1++;
};
SI_str_aux1.append(1, SI_line[SI_i1]);
};
};
};

SI_str_aux1.clear();

if (SI_line.find( SITE2_DEF, 0) != -1)
{
if ((SI_aux1 = SI_line.find(BRACKET_OPEN, 0)) != -1)
{
for (SI_i1 = SI_aux1+1; SI_i1 < SI_line.size(); SI_i1++)
{
if (SI_line[SI_i1] == BRACKET_COMMA || SI_line[SI_i1] ==
BRACKET_CLOSE)
{
SN_Aux1 = new String_Node(SI_str_aux1);
SN_Site2->InsertNode(SN_Aux1);
SI_str_aux1.clear();
SI_i1++;
};
SI_str_aux1.append(1, SI_line[SI_i1]);
};
};
};

SI_str_aux1.clear();
if (SI_line.find( SPACE_DEF, 0) != -1)
{
if ((SI_aux1 = SI_line.find(BRACKET_OPEN, 0)) != -1)
{
for (SI_i1 = SI_aux1+1; SI_i1 < SI_line.size(); SI_i1++)
{
if (SI_line[SI_i1] == BRACKET_COMMA || SI_line[SI_i1] ==
BRACKET_CLOSE)
{
int SI_int_aux1 = StrToInt(SI_str_aux1);
IN_Aux1 = new Integer_Node(SI_int_aux1);
IN_Space->InsertNode(IN_Aux1);
SI_str_aux1.clear();
SI_i1++;
};
SI_str_aux1.append(1, SI_line[SI_i1]);
};
};
};

}; // WHILE ends

cout<<"Reading completed.\n";
site_data.close();

};


rep_raw<<"File\tLocus\tLoc.pos\tAbs.pos\tComplement\tSpacer\tMatrix\tSequenc
e cut\n";

while((ent=readdir(dir)) != NULL)
{

cout<<"\nOPENING STREAM:\t"<d_name< fstream dna(ent->d_name);

bool AuxBoolean1=false, IsRNA=false, Translated1=false;
string SearchString1="cacagtg", SearchString2="acaaaaacc", RepStr,
SearchStr2_matrix;
string MainString, InitStringMatrix, TermStringMatrix="$$",
InitializationString="ORIGIN", TerminationString="//";
char AuxChar1, AuxChar2, RNAorDNAFilteringFactor, chLineStart=13;
unsigned int AuxInteger3=0, Ai4=0, Ai5=0, iInterval=6;
unsigned int LocPos=0, AbsPos=0, ConsCount=0, TickStart=0, TickEnd=0;
int iCount1;
fstream &FileStreamName = dna;

String_Node *SN_aux1 = new String_Node("");
String_Node *SN_aux2 = new String_Node("");
Integer_Node *IN_aux1 = new Integer_Node(0);

IsRNA ? RNAorDNAFilteringFactor='u' : RNAorDNAFilteringFactor='t';

while ((AuxChar1=FileStreamName.get()) != EOF)
{
if (AuxChar1 == EOF)
{ cout<<"FAILURE\n"; break; };

InitStringMatrix.append(1, AuxChar1);
// AbsPos+=1;
if (InitStringMatrix.size() > InitializationString.size() )
{
InitStringMatrix.erase(0,1);
};
if (InitStringMatrix==InitializationString)
{
OrigCount++;
MainString.clear();
AuxInteger1 = 0; AuxInteger2 = 0; AuxInteger3 = 0; Ai5 = 0;
TickStart=GetTickCount(); TickEnd=TickStart;
cout<<"\nLOCUS #"< "< if(SoundBool)
{
Beep(750, 3);
};
LocPos=0;
AuxBoolean1 = true;
};

if (AuxBoolean1) //Если запись включена
{
while ((AuxChar2=FileStreamName.get()) != EOF) //Считывая по
одному символу
{

TermStringMatrix.append(1, AuxChar2); //Добавлять в
терминальную матрицу

if (TermStringMatrix.size() > TerminationString.size() ) //В
случае превышения объема терминальной матрицы
{
TermStringMatrix.erase(0,1); //Удалить первый символ
};

if (AuxChar2 == 'a' ||
AuxChar2 == 'c' ||
AuxChar2 == 'g' ||
AuxChar2 == 'n' ||
AuxChar2 == RNAorDNAFilteringFactor) //Если символ -
допустимый символ сиквенса
{
MainString.append(1, AuxChar2); //Добавить символ в главную
матрицу

if ((MainString.size() >= MAIN_STRING_MAX_CAPACITY)) //Если
главная матрица превышает заданный объем
{
search:
if (!Translated1)
{SN_aux1 = SN_Site1->GetNext();}
else
{SN_aux1 = SN_Site2->GetNext();};

while (SN_aux1 != NULL) //Искать консенсус 1
{
SearchString1 = SN_aux1->GetHandle();
if (Translated1)
{
ComplementaryStr(SearchString1);
Invert(SearchString1);
};
AuxInteger1=MainString.find(SearchString1,
AuxInteger3); //Записать результат поиска
if (AuxInteger1 == -1) //Если ничего не найдено
{
SN_aux1 = SN_aux1->GetNext();
AuxInteger3=0;
continue; //Прервать цикл поиска консенсуса 1
}
else //Если что-то найдено
{
AuxInteger2=AuxInteger1; //Ai2 - Это начало
конс.1
AuxInteger3=AuxInteger1 + 1; //Ai3 - это конец
конс.1
Ai5=AuxInteger3; //Ai5 - конец конс.1 - точка
начала поиска след. конс.2
Ai4 = AuxInteger1 + SearchString1.size();

/* if (!Translated1)
{ SN_aux2 = SN_Site2->GetNext(); }
else
{ SN_aux2 = SN_Site1->GetNext(); };*/

IN_aux1 = IN_Space->GetNext();

while (IN_aux1 != NULL) //Поиск консенсуса 2
{
if (!Translated1)
{ SN_aux2 = SN_Site2->GetNext(); }
else
{ SN_aux2 = SN_Site1->GetNext(); };

SearchString2.clear();
// SearchString2.assign(MainString, (IN_aux1->GetHandle()+Ai4),
(SN_aux2->GetHandle().size()));
for (iCount1=0; iCount1 < SN_aux2-
>GetHandle().size(); iCount1++)
{
SearchString2.append(1, MainString[IN_aux1-
>GetHandle()+Ai4+iCount1]);
};

while (SN_aux2 != NULL)
{
// SearchStr2_matrix.clear();
SearchStr2_matrix = SN_aux2->GetHandle();

if (Translated1)
{
ComplementaryStr(SearchStr2_matrix);
Invert(SearchStr2_matrix);
};

if (SearchString2 == SearchStr2_matrix)
{
ConsCount+=1;

cout<<"Order #";
cout< cout<<"\t"< >GetHandle()<<">-"< cout<<" Locus: ";
cout.width(3);
cout< cout<<" Abs.pos: ";
cout.width(9);
cout< cout< экран

if (AuxInteger2 > REP_STR_ADD)
//Проверить, можно ли добавить в начало заданное число добавочных п.о.
{ RepStr.assign(MainString, AuxInteger2 -
REP_STR_ADD, REP_STR_LEN); } //Если да, то добавить столько, сколько
заказали
else
{ RepStr.assign(MainString, 0,
REP_STR_LEN); }; //А если нет, то добавить что есть

rep_raw<d_name<<"\t"
< < < < <GetHandle()<<"\t"
< >GetHandle()<<">-"< < < break;
};
SN_aux2 = SN_aux2->GetNext();
};

IN_aux1 = IN_aux1->GetNext();

};
// SN_aux1 = SN_aux1->GetNext();
};
}; //Кончаем искать конс.1

if (!Translated1 && ComplementScanActive)
{
Translated1 = true;
AuxInteger1 = 0; AuxInteger2 = 0; AuxInteger3 = 0;
Ai5=0;
goto search;
}
else
{
Translated1 = false;
};

AbsPos+=MainString.size()-MAIN_STRING_MIN_CAPACITY;
LocPos+=MainString.size()-MAIN_STRING_MIN_CAPACITY;
MainString.erase(0, MainString.size() -
MAIN_STRING_MIN_CAPACITY);
AuxInteger3=0;
Ai5=0;
};
if (!AuxBoolean1)
{
TickEnd=GetTickCount();
int Gen_time=TickEnd-TickStart, TimeH, TimeM, TimeS, TimeSs;
TimeH = Gen_time/3600000;
Gen_time-=TimeH*3600000;
TimeM = Gen_time/60000;
Gen_time-=TimeM*60000;
TimeS = Gen_time/1000;
Gen_time-=TimeS*1000;
TimeSs = Gen_time;
cout<<"\nLOCUS #"< time - "<<
cout.width(2); cout.fill('0');
cout< cout<<":";
cout.width(2);
cout< cout<<":";
cout.width(2);
cout< cout<<",";
cout.width(3);
cout< cout< cout.fill(' ');

break;
};
}; //if (char = alphabet) ends

if (TermStringMatrix==TerminationString)
{
AuxBoolean1=false;
AuxInteger1=0;
AuxInteger2=0;
TermStringMatrix.clear();
goto search;
};
};
};
};

OrigCount=0;

};
};