www.pudn.com > Genecircus20070919.rar > data_container.h
// data_container.h: interface for the data_container class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DATA_CONTAINER_H__203D7DAC_4470_45CF_9198_1B23A5988252__INCLUDED_)
#define AFX_DATA_CONTAINER_H__203D7DAC_4470_45CF_9198_1B23A5988252__INCLUDED_
#include "wx_pch.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
using namespace std;
class Calculate_Base_Pair
{
public:
Calculate_Base_Pair(){
xi = 0;
yi = 0;
};
double x;//valude of one of gene
double y;
unsigned int xi; // index of x
unsigned int yi; // index y
unsigned int maId;
};
typedef std::vector < Calculate_Base_Pair > Pair_Vector;
class Sort_X : std::binary_function < Calculate_Base_Pair, Calculate_Base_Pair, bool >
{
public:
bool operator() ( const Calculate_Base_Pair & a, const Calculate_Base_Pair & b ) const
{
if ( a.x != b.x )
{
return ( a.x < b.x );
}
else
{
return ( a.maId < b.maId );
}
}
};
class Sort_Y : std::binary_function < Calculate_Base_Pair, Calculate_Base_Pair, bool >
{
public:
bool operator() ( const Calculate_Base_Pair & a, const Calculate_Base_Pair & b ) const
{
if ( a.y != b.y )
{
return ( a.y < b.y );
}
else
{
return ( a.maId < b.maId );
}
}
};
class Pixel
{
public:
double val, pval;
public:
/** deliminator btw Pixels when they are written to a stream */
static const char * DELIMINATOR;
Pixel( double v = 0.0, double pv = 0.0 )
{
Set_Value( v );
Set_PValue( pv );
}
double Get_Value() const
{
return val;
}
double Get_PValue() const
{
return pval;
}
void Set_Value( double v )
{
val = v;
}
void Set_PValue( double pv )
{
pval = pv;
}
};
typedef std::vector < Pixel > Microarray;
struct A_Gene_in_a_Condition{
Microarray a_micro;
wxString name;
};
typedef std::vector < A_Gene_in_a_Condition > ALL_Microarray_Set;
class connect_matrix
{
public:
connect_matrix(){
lnext = NULL;
hnext = NULL;
mi = 0.0;
}
public:
int mark, utype; // utype =0 / 1 / 2, mark是访问标记, 未访问为0
connect_matrix * lnext; //指向同一层下一结点的指针
double mi; // utype = 1, mi data
connect_matrix * hnext; // utype = 2,
wxString name;
};
/*
class pvalue_matirx :connect_matrix
{
double mitoptwo[2];//Only save the bigest two
};
*/
typedef std::vector p;
typedef std::vector pvalue_vector;
typedef std::vector mi;
typedef std::vector mi_vector;
typedef std::vector index;
typedef std::vector y_index;
typedef std::vector xy_index;//connect matrix; for rebuild networks
using namespace boost;
class Microarray_Set
{
public:
Microarray_Set(){
original_data = NULL;
Path_name = "";
number_sample = -1;
mi_matrix = new connect_matrix();
mi_matrix->lnext = NULL;
head_mi_matrix = mi_matrix;
pvalue_temp_for_saveandparlle = new pvalue_result();
pvalue_temp_for_saveandparlle->ms = this;
temp_number = 0;
}
~Microarray_Set(){
if(original_data != NULL)
delete [] original_data;
delete pvalue_temp_for_saveandparlle;
mi_matrix = head_mi_matrix;
while(mi_matrix->lnext != NULL){
head_mi_matrix = mi_matrix->lnext;
if(mi_matrix->hnext == NULL)
delete mi_matrix;
else{
connect_matrix * temp;connect_matrix * temp_temp;
temp = mi_matrix;
temp_temp = mi_matrix->hnext;
delete temp;
do{
temp = temp_temp;
temp_temp = temp_temp->lnext;
delete temp;
}while(temp_temp->lnext != NULL);
delete temp_temp;
}
mi_matrix = head_mi_matrix;
}
delete mi_matrix;
}
bool Get_original_one_gene(wxString data);
int number_sample;
wxString Path_name;
unsigned char * original_data;
Pair_Vector gene_pairs;//One pairs of gene
ALL_Microarray_Set micro_set;//All gene data
ALL_Microarray_Set micro_set1;//All gene data
connect_matrix * mi_matrix;
connect_matrix * head_mi_matrix;
pvalue_vector pvalue;
mi_vector mivector;
int temp_number;
index index_temp;//save connect matrix; frist control
index index_temp_second;
xy_index xyindex;
void delete_maxtri(){
connect_matrix * temp = head_mi_matrix;
mi_matrix = head_mi_matrix->lnext;
if(mi_matrix != NULL){
while(mi_matrix->lnext != NULL){
head_mi_matrix = mi_matrix->lnext;
if(mi_matrix->hnext == NULL)
delete mi_matrix;
else{
connect_matrix * temp;connect_matrix * temp_temp;
temp = mi_matrix;
temp_temp = mi_matrix->hnext;
delete temp;
do{
temp = temp_temp;
temp_temp = temp_temp->lnext;
delete temp;
}while(temp_temp->lnext != NULL);
delete temp_temp;
}
mi_matrix = head_mi_matrix;
}
}
if(mi_matrix != NULL)
delete mi_matrix;
head_mi_matrix = temp;
mi_matrix = head_mi_matrix;
}
bool get_original_data(wxString Path_name);
// pre_claculate_prepare_data();
int Getindexofonegene(wxString name);
void resturct_genepairs(int i,int j);
class pvalue_result{
public:
p p_temp;string temp1,temp2;double * temp;
void save(int size, p p1,wxString name,wxString dirname){
/*
//temp = new double[size];
temp1 = name + '\r'+'\n';
for(int i =0;i(p1[i]);
temp1 = temp1 + temp2 + '\r'+'\n';
}
if(dirname != ""){
int count = temp1.length();
const char * t = temp1.c_str();
wxString temp_dir = dirname;
dirname = dirname + "_pvalue" + name +".tmp";
wxFile file;
file.Create(dirname,true);
file.Open(dirname,wxFile::read_write);
file.Write(t,size*sizeof(double));
file.Close();
dirname = temp_dir;
}
*/
}
Microarray_Set * ms;
friend class Microarray_Set;
};
pvalue_result * pvalue_temp_for_saveandparlle;
};
class Find_name : std::binary_function < A_Gene_in_a_Condition, wxString ,bool>
{
public:
bool operator() ( const A_Gene_in_a_Condition & a, const wxString & b ) const
{
if ( a.name == b )
{
return ( 1 );
}
}
};
#endif // !defined(AFX_DATA_CONTAINER_H__203D7DAC_4470_45CF_9198_1B23A5988252__INCLUDED_)