使用哪种语言? [英] in which language to run in?

查看:44
本文介绍了使用哪种语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在哪个平台上运行dis程序,原因是tueboc中出现了错误


in which platform can i run dis program,coz m gettin errors in tueboc


#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cmath>
#include <sys/time.h>
using namespace std;

double similarity_score(char a,char b);
double find_array_max(double array[],int length);
void insert_at(char arr[], int n, int idx, char val);
void checkfile(int open, char filename[]);
string read_sequence(ifstream& f);

int ind;
double mu,delta;


int main(int argc, char** argv){

  // read info from arguments
  if(argc!=6){
    cout<<"Give me the propen number of input arguments:"<<endl<<"1 : mu"<<endl;
    cout<<"2 : delta"<<endl<<"3 : filename sequence A"<<endl<<"4 : filename sequence B"<<endl;
    cout<<"5 : maximal length N of sequences"<<endl;exit(1);
  }
  mu    = atof(argv[1]);
  delta = atof(argv[2]);
  /////////////////////////////////
  // give it the filenames
  char *nameof_seq_a = argv[3];
  char *nameof_seq_b = argv[4];
  int N_max = atoi(argv[5]);
  string seq_a,seq_b; 
  
  // read the sequences into two vectors:
  ifstream stream_seq_b;                      // first define the input-streams for seq_a and seq_b
  stream_seq_b.open(nameof_seq_b);            // the same for seq_b
  checkfile(! stream_seq_b,nameof_seq_b);
  seq_b = read_sequence(stream_seq_b);
  ifstream stream_seq_a;
  stream_seq_a.open(nameof_seq_a);            // open the file for input
  checkfile(! stream_seq_a,nameof_seq_a);     // check, whether the file was opened successfully
  seq_a = read_sequence(stream_seq_a);  


  // string s_a=seq_a,s_b=seq_b;
  int N_a = seq_a.length();                     // get the actual lengths of the sequences
  int N_b = seq_b.length();
 
  ////////////////////////////////////////////////

  // initialize H
  double H[N_a+1][N_b+1];     
  for(int i=0;i<=N_a;i++){
    for(int j=0;j<=N_b;j++){
      H[i][j]=0.;
    }
  } 

  double temp[4];
  int I_i[N_a+1][N_b+1],I_j[N_a+1][N_b+1];     // Index matrices to remember the 'path' for backtracking
  
  // here comes the actual algorithm

  for(int i=1;i<=N_a;i++){
    for(int j=1;j<=N_b;j++){
      temp[0] = H[i-1][j-1]+similarity_score(seq_a[i-1],seq_b[j-1]); 
      temp[1] = H[i-1][j]-delta;                  
      temp[2] = H[i][j-1]-delta;                 
      temp[3] = 0.;
      H[i][j] = find_array_max(temp,4);
      switch(ind){
      case 0:                                  // score in (i,j) stems from a match/mismatch
   	I_i[i][j] = i-1;
	I_j[i][j] = j-1;
	break;
      case 1:                                  // score in (i,j) stems from a deletion in sequence A
     	I_i[i][j] = i-1;
	I_j[i][j] = j;
	break;
      case 2:                                  // score in (i,j) stems from a deletion in sequence B
      	I_i[i][j] = i;
	I_j[i][j] = j-1;
	break;
      case 3:                                  // (i,j) is the beginning of a subsequence
      	I_i[i][j] = i;
	I_j[i][j] = j;	
	break;
      }
    }
  }

  // Print the matrix H to the console
  cout<<"**********************************************"<<endl;
  cout<<"The scoring matrix is given by  "<<endl<<endl;
  for(int i=1;i<=N_a;i++){
    for(int j=1;j<=N_b;j++){
      cout<<H[i][j]<<" ";
    }
    cout<<endl;
    }

  // search H for the maximal score
  double H_max = 0.;
  int i_max=0,j_max=0;
  for(int i=1;i<=N_a;i++){
    for(int j=1;j<=N_b;j++){
      if(H[i][j]>H_max){
	H_max = H[i][j];
	i_max = i;
	j_max = j;
      }
    }
  }

  //cout<<H_max<<endl;
  
     // Backtracking from H_max
  int current_i=i_max,current_j=j_max;
  int next_i=I_i[current_i][current_j];
  int next_j=I_j[current_i][current_j];
  int tick=0;
  char consensus_a[N_a+N_b+2],consensus_b[N_a+N_b+2];

  while(((current_i!=next_i) || (current_j!=next_j)) && (next_j!=0) && (next_i!=0)){

    if(next_i==current_i)  consensus_a[tick] = '-';                  // deletion in A
    else                   consensus_a[tick] = seq_a[current_i-1];   // match/mismatch in A

    if(next_j==current_j)  consensus_b[tick] = '-';                  // deletion in B
    else                   consensus_b[tick] = seq_b[current_j-1];   // match/mismatch in B

    current_i = next_i;
    current_j = next_j;
    next_i = I_i[current_i][current_j];
    next_j = I_j[current_i][current_j];
    tick++;
    }
 
 // Output of the consensus motif to the console
  cout<<endl<<"***********************************************"<<endl;
  cout<<"The alignment of the sequences"<<endl<<endl;
  for(int i=0;i<N_a;i++){cout<<seq_a[i];}; cout<<"  and"<<endl;
  for(int i=0;i<N_b;i++){cout<<seq_b[i];}; cout<<endl<<endl;
  cout<<"is for the parameters  mu = "<<mu<<" and delta = "<<delta<<" given by"<<endl<<endl;  
  for(int i=tick-1;i>=0;i--) cout<<consensus_a[i]; 
  cout<<endl;
  for(int j=tick-1;j>=0;j--) cout<<consensus_b[j];
  cout<<endl;
  

} // END of main



/////////////////////////////////////////////////////////////////////////////
// auxiliary functions used by main:
/////////////////////////////////////////////////////////////////////////////


void checkfile(int open, char filename[]){

  if (open){cout << "Error: Can't open the file "<<filename<<endl;exit(1);}
  else cout<<"Opened file "<<filename<<endl;
}

/////////////////////////////////////////////////////////////////////////////

double similarity_score(char a,char b){

  double result;
  if(a==b){
      result=1.;
    }
  else{
      result=-mu;
    }
  return result;
}

/////////////////////////////////////////////////////////////////////////////

double find_array_max(double array[],int length){

  double max = array[0];            // start with max = first element
  ind = 0;

  for(int i = 1; i<length; i++){
      if(array[i] > max){
	max = array[i];
	ind = i; 
      }
  }
  return max;                    // return highest value in array
}

/////////////////////////////////////////////////////////////////////////////

string read_sequence(ifstream& f)
{
  // overflows.
  string seq;
  char line[5000];
  while( f.good() )
    {
      f.getline(line,5000);
      // 		cout << "Line:" << line << endl;
      if( line[0] == 0 || line[0]=='#' )
	continue;
      for(int i = 0; line[i] != 0; ++i)
	{
	  int c = toupper(line[i]);
	  if( c != 'A' && c != 'G' && c != 'C' && c != 'T' )
	    continue;
	  //cout << char(c);
	  seq.push_back(char(c));
	}
    }
  return seq;

}

推荐答案

它是C++.请报告有关您得到的错误的详细信息.

[更新]
您无法使用turbo C++对其进行编译,因为turbo C++的日期是在程序使用C++的某些最新功能(例如标准"C"库的新标头)时给出的. br/> 您可以使用更新的编译器(建议的解决方案),也可以修改代码以使其与当前编译器可以理解的旧C++相匹配.
[/update]
It is C++. Please report detailed info about the error(s) you get.

[update]
You cannot compile it (as it stands) using turbo C++, because turbo C++ is dated while the program uses some recent features of C++ (for instance new header for the standard ''C'' libraries).
You may either use a more recent compiler (suggested solution) or adapt the code to match the old C++ your current compiler understands.
[/update]


形成您的注释,似乎正在使用g ++编译器.因此,您可以使用Linux,也可以在Windows中使用Cygwin或MinGW.您可以从下面提供的链接中获取此信息

http://www.cygwin.com/ [ ^ ]

http://www.mingw.org/ [ ^ ]
Form your comment it seems to be using a g++ compiler. So either you can use Linux or in Windows you can use Cygwin or MinGW. YOu can get this from below provided links

http://www.cygwin.com/[^]

http://www.mingw.org/[^]


好吧,实际上不可能猜到,但这不是C ++的C语言.
我怀疑它是托管的,所以我会在Visual Studio下尝试作为C ++控制台应用程序.
Well, it is not really possible to guess, but it is C++ not vanilla C.
I would suspect it is managed, so I would try under Visual Studio as a C++ Console application.


这篇关于使用哪种语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆