add comments of arg
This commit is contained in:
parent
7031196089
commit
39036cc34e
1 changed files with 41 additions and 41 deletions
82
oblong.c
82
oblong.c
|
@ -194,8 +194,8 @@ void errout ( int cond , char * msg )
|
||||||
{
|
{
|
||||||
if ( !cond ) return ;
|
if ( !cond ) return ;
|
||||||
if ( msg != NULL )
|
if ( msg != NULL )
|
||||||
fprintf ( stderr , "\n%s\n" , msg ) ;
|
fprintf ( stderr , "\n%s\n" , msg ) ; //output to the screen, usually error
|
||||||
exit ( 0 ) ;
|
exit ( 0 ) ; //exit(0)正常运行程序并退出程序;exit(1)非正常运行导致退出程序
|
||||||
}
|
}
|
||||||
|
|
||||||
void * myalloc ( unsigned long int size )
|
void * myalloc ( unsigned long int size )
|
||||||
|
@ -207,85 +207,85 @@ void * myalloc ( unsigned long int size )
|
||||||
|
|
||||||
int stringis ( char * a , char * b )
|
int stringis ( char * a , char * b )
|
||||||
{
|
{
|
||||||
while ( * a && tolower ( * a ) == tolower ( * b ) ) { ++a ; ++ b ; }
|
while ( * a && tolower ( * a ) == tolower ( * b ) ) { ++a ; ++ b ; } //tolower: conver letters from uppercase to lowercase
|
||||||
if ( * a || * b ) return 0 ;
|
if ( * a || * b ) return 0 ; // or || ,return fake
|
||||||
return 1 ;
|
return 1 ; //return true
|
||||||
}
|
}
|
||||||
|
|
||||||
void procargs ( int nargs , char ** arg )
|
void procargs ( int nargs , char ** arg ) // int nargs =2 for [oblong -f] **arg = *arg [] 字符串数组
|
||||||
{
|
{
|
||||||
int i ;
|
int i ;
|
||||||
char * cp ;
|
char * cp ;
|
||||||
if ( nargs == 1 ) {
|
if ( nargs == 1 ) { // no arguments if nargs == 1
|
||||||
display_help ( 0 ) ;
|
display_help ( 0 ) ; //not show the help ouput just no argument output
|
||||||
exit ( 0 ) ; }
|
exit ( 0 ) ; }
|
||||||
for ( i = 1 ; i < nargs ; ++ i ) {
|
for ( i = 1 ; i < nargs ; ++ i ) {
|
||||||
cp = arg [ i ] ;
|
cp = arg [ i ] ;
|
||||||
if ( * cp != '-' ) {
|
if ( * cp != '-' ) { // if arguments not start with -
|
||||||
fprintf ( stderr , "\nWrong argument: %s\n" , arg [ i ] ) ;
|
fprintf ( stderr , "\nWrong argument: %s\n" , arg [ i ] ) ; //show which argument is wrong
|
||||||
exit ( 0 ) ; }
|
exit ( 0 ) ; }
|
||||||
switch ( * ++ cp ) {
|
switch ( * ++ cp ) {
|
||||||
case 'a': saveall = 1 ; break ;
|
case 'a': saveall = 1 ; break ; //save all trees
|
||||||
case 'b': do_branch_swapping = 0 ; break ;
|
case 'b': do_branch_swapping = 0 ; break ; //no branch swapping
|
||||||
case 'e': equal_taxon_sequence = 1 ; break ;
|
case 'e': equal_taxon_sequence = 1 ; break ;
|
||||||
case 'f': fasta = 1 ; break ;
|
case 'f': fasta = 1 ; break ; //fasta format
|
||||||
case 'h': display_help ( 1 ) ; exit ( 0 ) ;
|
case 'h': display_help ( 1 ) ; exit ( 0 ) ; //help
|
||||||
case 'i':
|
case 'i': //use the filename -i${filename}
|
||||||
case '@':
|
case '@':
|
||||||
if ( * cp == '@' ) multifiles = 1 ;
|
if ( * cp == '@' ) multifiles = 1 ; //there are multi files
|
||||||
++ cp ;
|
++ cp ;
|
||||||
errout ( stringis ( cp , "oblong.tmp" ) , "Cannot use \"oblong.tmp\" as input file; rename it and try again" ) ;
|
errout ( stringis ( cp , "oblong.tmp" ) , "Cannot use \"oblong.tmp\" as input file; rename it and try again" ) ;
|
||||||
errout ( stringis ( cp , "oblong.pts" ) , "Cannot use \"oblong.pts\" as input file; rename it and try again" ) ;
|
errout ( stringis ( cp , "oblong.pts" ) , "Cannot use \"oblong.pts\" as input file; rename it and try again" ) ;
|
||||||
errout ( inp != NULL , "Can't open TWO input files" ) ;
|
errout ( inp != NULL , "Can't open TWO input files" ) ;
|
||||||
errout ( ( inp = fopen ( cp , "rb" ) ) == NULL , "Can't open input file" ) ;
|
errout ( ( inp = fopen ( cp , "rb" ) ) == NULL , "Can't open input file" ) ; //input file, if the input list can't be readable in the bianry mode, on windows, binary is different
|
||||||
break ;
|
break ;
|
||||||
case 'j':
|
case 'j': //j${NumberofJakknife}
|
||||||
++ cp ;
|
++ cp ;
|
||||||
if ( isdigit ( * cp ) )
|
if ( isdigit ( * cp ) ) //to find if the character is the numer
|
||||||
jakprob = atoi ( cp ) ;
|
jakprob = atoi ( cp ) ; //atoi: convert character to the int
|
||||||
dojak = changewts = 1 ;
|
dojak = changewts = 1 ;
|
||||||
break ;
|
break ;
|
||||||
case 'k': swapcollapse = 1 ; break ;
|
case 'k': swapcollapse = 1 ; break ; //do TBR/SPR collapsing
|
||||||
case 'm': errout ( ( ( maxram = atof ( ++ cp ) ) <= 0 ) , "You must indicate RAM to use" ) ; together = 0 ; break ;
|
case 'm': errout ( ( ( maxram = atof ( ++ cp ) ) <= 0 ) , "You must indicate RAM to use" ) ; together = 0 ; break ; //atof: transfer chracter into double
|
||||||
case 'N': usenexus = 1 ; break ;
|
case 'N': usenexus = 1 ; break ; //output the nexus file
|
||||||
case 'o':
|
case 'o': //-o${outfile}
|
||||||
++ cp ;
|
++ cp ;
|
||||||
errout ( stringis ( cp , "oblong.tmp" ) , "Cannot use \"oblong.tmp\" as output file; use a different name" ) ;
|
errout ( stringis ( cp , "oblong.tmp" ) , "Cannot use \"oblong.tmp\" as output file; use a different name" ) ;
|
||||||
errout ( stringis ( cp , "oblong.pts" ) , "Cannot use \"oblong.pts\" as output file; use a different name" ) ;
|
errout ( stringis ( cp , "oblong.pts" ) , "Cannot use \"oblong.pts\" as output file; use a different name" ) ;
|
||||||
errout ( outp != NULL , "Can't open TWO output files" ) ;
|
errout ( outp != NULL , "Can't open TWO output files" ) ;
|
||||||
errout ( ( outp = fopen ( cp , "wb" ) ) == NULL , "Can't open output file" ) ;
|
errout ( ( outp = fopen ( cp , "wb" ) ) == NULL , "Can't open output file" ) ;
|
||||||
break ;
|
break ;
|
||||||
case 'p': felipe = 1 ; break ;
|
case 'p': felipe = 1 ; break ; //file in Phylip style
|
||||||
case 'q':
|
case 'q': //a quick approximmation
|
||||||
++ cp ;
|
++ cp ;
|
||||||
quickbremer = 1 ;
|
quickbremer = 1 ;
|
||||||
if ( * cp == '0' ) bremertype = 0 ;
|
if ( * cp == '0' ) bremertype = 0 ;
|
||||||
if ( * cp == '1' ) bremertype = 1 ;
|
if ( * cp == '1' ) bremertype = 1 ;
|
||||||
if ( * cp == '2' ) bremertype = 2 ;
|
if ( * cp == '2' ) bremertype = 2 ;
|
||||||
break ;
|
break ;
|
||||||
case 'r': numreplications = atoi ( ++ cp ) ; break ;
|
case 'r': numreplications = atoi ( ++ cp ) ; break ; //use N starting points. -r${Number}
|
||||||
case 'R': ranseed = atoi ( ++ cp ) ; break ;
|
case 'R': ranseed = atoi ( ++ cp ) ; break ; //random seed
|
||||||
case 's':
|
case 's': //spr use spr instead of tbr
|
||||||
if ( !strcmp ( cp , "spr" ) ) { use_spr = 1 ; break ; }
|
if ( !strcmp ( cp , "spr" ) ) { use_spr = 1 ; break ; }
|
||||||
case 't': savejusttrees = 1 ; break ;
|
case 't': savejusttrees = 1 ; break ; //output standrad tre format
|
||||||
case 'T':
|
case 'T': //set start tree -T${treefile}
|
||||||
++ cp ;
|
++ cp ;
|
||||||
errout ( treeinp != NULL , "Can't open TWO tree files" ) ;
|
errout ( treeinp != NULL , "Can't open TWO tree files" ) ;
|
||||||
errout ( ( treeinp = fopen ( cp , "rb" ) ) == NULL , "Can't open tree file" ) ;
|
errout ( ( treeinp = fopen ( cp , "rb" ) ) == NULL , "Can't open tree file" ) ;
|
||||||
break ;
|
break ;
|
||||||
case 'v': verbose = 1 ; break ;
|
case 'v': verbose = 1 ; break ; //report rearrangements
|
||||||
case 'w': random_starts = 1 ; break ;
|
case 'w': random_starts = 1 ; break ; //use random trees as start tree
|
||||||
case 'x':
|
case 'x': //-x${Numer of ratcher}
|
||||||
++ cp ;
|
++ cp ;
|
||||||
if ( isdigit ( * cp ) ) ratcycles = atoi ( cp ) ;
|
if ( isdigit ( * cp ) ) ratcycles = atoi ( cp ) ;//if the char is number, make ratecycles=
|
||||||
else ratcycles = 10 ;
|
else ratcycles = 10 ;
|
||||||
break ;
|
break ;
|
||||||
default: fprintf ( stderr , "\nUnrecognized option: %s\n" , arg [ i ] ) ; exit ( 0 ) ; }}
|
default: fprintf ( stderr , "\nUnrecognized option: %s\n" , arg [ i ] ) ; exit ( 0 ) ; }}
|
||||||
errout ( ( fasta && felipe ) , "Cannot use both Phylip and Fasta formats" ) ;
|
errout ( ( fasta && felipe ) , "Cannot use both Phylip and Fasta formats" ) ; //fasta = 1 and felipe = 1, it can't be identified as different type
|
||||||
errout ( ( inp == NULL ) , "No data set specified" ) ;
|
errout ( ( inp == NULL ) , "No data set specified" ) ;
|
||||||
errout ( ( outp == NULL ) , "No output file specified" ) ;
|
errout ( ( outp == NULL ) , "No output file specified" ) ;
|
||||||
if ( quickbremer && dojak ) {
|
if ( quickbremer && dojak ) {
|
||||||
dojak = changewts = 0 ;
|
dojak = changewts = 0 ; //if quick approximmation and jack both are set, the jack won't be done
|
||||||
fprintf ( stderr , "\nNOTE: Cannot do both jackknifing and bremer at the same time!\n" ) ;
|
fprintf ( stderr , "\nNOTE: Cannot do both jackknifing and bremer at the same time!\n" ) ;
|
||||||
if ( bremertype == 2 )
|
if ( bremertype == 2 )
|
||||||
fprintf ( stderr , " deletion prob P=%.2f will be used to rescale supports (1-P)\n" , ( double ) jakprob / 100 ) ;
|
fprintf ( stderr , " deletion prob P=%.2f will be used to rescale supports (1-P)\n" , ( double ) jakprob / 100 ) ;
|
||||||
|
@ -294,15 +294,15 @@ void procargs ( int nargs , char ** arg )
|
||||||
else fprintf ( stderr , " will do relative bremer supports instead\n" ) ;
|
else fprintf ( stderr , " will do relative bremer supports instead\n" ) ;
|
||||||
errout ( ( !jakprob && bremertype == 2 ) , " ...but cannot use a deletion prob. P=0 to rescale!" ) ;
|
errout ( ( !jakprob && bremertype == 2 ) , " ...but cannot use a deletion prob. P=0 to rescale!" ) ;
|
||||||
fprintf ( stderr , "\n" ) ; }
|
fprintf ( stderr , "\n" ) ; }
|
||||||
if ( quickbremer && usenexus ) legindic [ 0 ] = 0 ;
|
if ( quickbremer && usenexus ) legindic [ 0 ] = 0 ; // *** left here temp
|
||||||
if ( !do_branch_swapping && !ratcycles ) shownegbremers = 1 ;
|
if ( !do_branch_swapping && !ratcycles ) shownegbremers = 1 ; // *** left here temp
|
||||||
if ( treeinp != NULL && numreplications )
|
if ( treeinp != NULL && numreplications )
|
||||||
fprintf ( stderr , "\nNote: \"-T\" overrides \"-r\": number of trees in file determines starting points\n" ) ;
|
fprintf ( stderr , "\nNote: \"-T\" overrides \"-r\": number of trees in file determines starting points\n" ) ;
|
||||||
if ( !numreplications ) numreplications = 1 ;
|
if ( !numreplications ) numreplications = 1 ;
|
||||||
if ( maxram > 0 ) {
|
if ( maxram > 0 ) {
|
||||||
fprintf ( stderr , "\nUsing %.2f MBytes of RAM for matrix buffers\n" , maxram ) ;
|
fprintf ( stderr , "\nUsing %.2f MBytes of RAM for matrix buffers\n" , maxram ) ;
|
||||||
fflush ( stderr ) ;
|
fflush ( stderr ) ; //清空缓存区 ***
|
||||||
maxram *= 1024 * 1024 ; }
|
maxram *= 1024 * 1024 ; } // ***
|
||||||
reportheader = '\r' ;
|
reportheader = '\r' ;
|
||||||
if ( !isatty( fileno( stderr ) ) ) {
|
if ( !isatty( fileno( stderr ) ) ) {
|
||||||
errout ( verbose , "Verbose allowed only when STDERR goes to screen" ) ;
|
errout ( verbose , "Verbose allowed only when STDERR goes to screen" ) ;
|
||||||
|
|
Loading…
Reference in a new issue