This commit is contained in:
kuoi 2023-02-03 02:13:39 +08:00
parent 7e4aab7d0a
commit 6c0681f97c
1 changed files with 36 additions and 8 deletions

View File

@ -7,13 +7,13 @@
using namespace std;
int datatype=0, ntax, nseq;
int intype=0, outype=0, ntax, nseq;
char * fn;
void show_help(int help_num);
void read_input(void);
int readPhy(){
void readPhy(){
int num=0;
cout << "readphy is working, filename is " << fn << endl;
//read file
@ -28,9 +28,22 @@ int readPhy(){
ntax = stoi (sntax); nseq = stoi (snseq); // string to int
cout << "ntax=" << ntax << " nseq=" << nseq << endl;
//read sequence
string taxa[ntax], sequ[ntax];
//taxa[ntax] = new string*[];
int lennum;
for(lennum=0;lennum<ntax;lennum++){
getline(seqfile,snall);
istringstream istr(snall);
istr >> taxa[lennum]; istr >> sequ[lennum];
cout << "tax" << lennum << " is " << taxa << "; seq" << lennum << " is " << sequ << endl;
}
seqfile.close();
return num;
// return taxa;
// return sequ;
}
void writeFas(){
}
void procargs (int nargs, char ** arg){ //*arg 视为整体,是字符串指针
@ -54,12 +67,18 @@ void procargs (int nargs, char ** arg){ //*arg 视为整体,是字符串指针
switch (*++cp){//先++
case 'f':
cp++;
if (*cp=='f') datatype=1;
if (*cp=='n') datatype=2;
if (*cp=='p') {datatype=3; cout << "datatype is phylip, " << datatype << endl;}
if (*cp=='f') intype=1;
if (*cp=='n') intype=2;
if (*cp=='p') {intype=3; cout << "intype is phylip, " << intype << endl;}
break;
case 'h': show_help(1); break;
case 'i': cp++; fn = cp; break;
case 't':
cp++;
if (*cp=='f') outype=1;
if (*cp=='n') outype=2;
if (*cp=='p') {outype=3; cout << "intype is phylip, " << intype << endl;}
break;
default: cout << "Unrecognized agruments " << *(arg+i) << endl; exit(0);
}
}
@ -75,12 +94,21 @@ void show_help (int help_num){
}
void read_input (void){
if (datatype==3) readPhy();
if (intype==3) readPhy();
}
void write_output (void){
switch(outype){
case '1': ; break;
case '2': ; break;
case '3': ; break;
}
}
int main(int argc, char **argv){
procargs (argc, argv);
read_input();
write_output();
int i;
for (i = 0; i < argc; i++) cout << "argument "<< i << " is " << *(argv+i) << endl;
return 1;