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 ( msg != NULL )
|
||||
fprintf ( stderr , "\n%s\n" , msg ) ;
|
||||
exit ( 0 ) ;
|
||||
fprintf ( stderr , "\n%s\n" , msg ) ; //output to the screen, usually error
|
||||
exit ( 0 ) ; //exit(0)正常运行程序并退出程序;exit(1)非正常运行导致退出程序
|
||||
}
|
||||
|
||||
void * myalloc ( unsigned long int size )
|
||||
|
@ -207,85 +207,85 @@ void * myalloc ( unsigned long int size )
|
|||
|
||||
int stringis ( char * a , char * b )
|
||||
{
|
||||
while ( * a && tolower ( * a ) == tolower ( * b ) ) { ++a ; ++ b ; }
|
||||
if ( * a || * b ) return 0 ;
|
||||
return 1 ;
|
||||
while ( * a && tolower ( * a ) == tolower ( * b ) ) { ++a ; ++ b ; } //tolower: conver letters from uppercase to lowercase
|
||||
if ( * a || * b ) return 0 ; // or || ,return fake
|
||||
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 ;
|
||||
char * cp ;
|
||||
if ( nargs == 1 ) {
|
||||
display_help ( 0 ) ;
|
||||
if ( nargs == 1 ) { // no arguments if nargs == 1
|
||||
display_help ( 0 ) ; //not show the help ouput just no argument output
|
||||
exit ( 0 ) ; }
|
||||
for ( i = 1 ; i < nargs ; ++ i ) {
|
||||
cp = arg [ i ] ;
|
||||
if ( * cp != '-' ) {
|
||||
fprintf ( stderr , "\nWrong argument: %s\n" , arg [ i ] ) ;
|
||||
if ( * cp != '-' ) { // if arguments not start with -
|
||||
fprintf ( stderr , "\nWrong argument: %s\n" , arg [ i ] ) ; //show which argument is wrong
|
||||
exit ( 0 ) ; }
|
||||
switch ( * ++ cp ) {
|
||||
case 'a': saveall = 1 ; break ;
|
||||
case 'b': do_branch_swapping = 0 ; break ;
|
||||
case 'a': saveall = 1 ; break ; //save all trees
|
||||
case 'b': do_branch_swapping = 0 ; break ; //no branch swapping
|
||||
case 'e': equal_taxon_sequence = 1 ; break ;
|
||||
case 'f': fasta = 1 ; break ;
|
||||
case 'h': display_help ( 1 ) ; exit ( 0 ) ;
|
||||
case 'i':
|
||||
case 'f': fasta = 1 ; break ; //fasta format
|
||||
case 'h': display_help ( 1 ) ; exit ( 0 ) ; //help
|
||||
case 'i': //use the filename -i${filename}
|
||||
case '@':
|
||||
if ( * cp == '@' ) multifiles = 1 ;
|
||||
if ( * cp == '@' ) multifiles = 1 ; //there are multi files
|
||||
++ cp ;
|
||||
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 ( 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 ;
|
||||
case 'j':
|
||||
case 'j': //j${NumberofJakknife}
|
||||
++ cp ;
|
||||
if ( isdigit ( * cp ) )
|
||||
jakprob = atoi ( cp ) ;
|
||||
if ( isdigit ( * cp ) ) //to find if the character is the numer
|
||||
jakprob = atoi ( cp ) ; //atoi: convert character to the int
|
||||
dojak = changewts = 1 ;
|
||||
break ;
|
||||
case 'k': swapcollapse = 1 ; break ;
|
||||
case 'm': errout ( ( ( maxram = atof ( ++ cp ) ) <= 0 ) , "You must indicate RAM to use" ) ; together = 0 ; break ;
|
||||
case 'N': usenexus = 1 ; break ;
|
||||
case 'o':
|
||||
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 ; //atof: transfer chracter into double
|
||||
case 'N': usenexus = 1 ; break ; //output the nexus file
|
||||
case 'o': //-o${outfile}
|
||||
++ cp ;
|
||||
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 ( outp != NULL , "Can't open TWO output files" ) ;
|
||||
errout ( ( outp = fopen ( cp , "wb" ) ) == NULL , "Can't open output file" ) ;
|
||||
break ;
|
||||
case 'p': felipe = 1 ; break ;
|
||||
case 'q':
|
||||
case 'p': felipe = 1 ; break ; //file in Phylip style
|
||||
case 'q': //a quick approximmation
|
||||
++ cp ;
|
||||
quickbremer = 1 ;
|
||||
if ( * cp == '0' ) bremertype = 0 ;
|
||||
if ( * cp == '1' ) bremertype = 1 ;
|
||||
if ( * cp == '2' ) bremertype = 2 ;
|
||||
break ;
|
||||
case 'r': numreplications = atoi ( ++ cp ) ; break ;
|
||||
case 'R': ranseed = atoi ( ++ cp ) ; break ;
|
||||
case 's':
|
||||
case 'r': numreplications = atoi ( ++ cp ) ; break ; //use N starting points. -r${Number}
|
||||
case 'R': ranseed = atoi ( ++ cp ) ; break ; //random seed
|
||||
case 's': //spr use spr instead of tbr
|
||||
if ( !strcmp ( cp , "spr" ) ) { use_spr = 1 ; break ; }
|
||||
case 't': savejusttrees = 1 ; break ;
|
||||
case 'T':
|
||||
case 't': savejusttrees = 1 ; break ; //output standrad tre format
|
||||
case 'T': //set start tree -T${treefile}
|
||||
++ cp ;
|
||||
errout ( treeinp != NULL , "Can't open TWO tree files" ) ;
|
||||
errout ( ( treeinp = fopen ( cp , "rb" ) ) == NULL , "Can't open tree file" ) ;
|
||||
break ;
|
||||
case 'v': verbose = 1 ; break ;
|
||||
case 'w': random_starts = 1 ; break ;
|
||||
case 'x':
|
||||
case 'v': verbose = 1 ; break ; //report rearrangements
|
||||
case 'w': random_starts = 1 ; break ; //use random trees as start tree
|
||||
case 'x': //-x${Numer of ratcher}
|
||||
++ cp ;
|
||||
if ( isdigit ( * cp ) ) ratcycles = atoi ( cp ) ;
|
||||
if ( isdigit ( * cp ) ) ratcycles = atoi ( cp ) ;//if the char is number, make ratecycles=
|
||||
else ratcycles = 10 ;
|
||||
break ;
|
||||
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 ( ( outp == NULL ) , "No output file specified" ) ;
|
||||
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" ) ;
|
||||
if ( bremertype == 2 )
|
||||
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" ) ;
|
||||
errout ( ( !jakprob && bremertype == 2 ) , " ...but cannot use a deletion prob. P=0 to rescale!" ) ;
|
||||
fprintf ( stderr , "\n" ) ; }
|
||||
if ( quickbremer && usenexus ) legindic [ 0 ] = 0 ;
|
||||
if ( !do_branch_swapping && !ratcycles ) shownegbremers = 1 ;
|
||||
if ( quickbremer && usenexus ) legindic [ 0 ] = 0 ; // *** left here temp
|
||||
if ( !do_branch_swapping && !ratcycles ) shownegbremers = 1 ; // *** left here temp
|
||||
if ( treeinp != NULL && numreplications )
|
||||
fprintf ( stderr , "\nNote: \"-T\" overrides \"-r\": number of trees in file determines starting points\n" ) ;
|
||||
if ( !numreplications ) numreplications = 1 ;
|
||||
if ( maxram > 0 ) {
|
||||
fprintf ( stderr , "\nUsing %.2f MBytes of RAM for matrix buffers\n" , maxram ) ;
|
||||
fflush ( stderr ) ;
|
||||
maxram *= 1024 * 1024 ; }
|
||||
fflush ( stderr ) ; //清空缓存区 ***
|
||||
maxram *= 1024 * 1024 ; } // ***
|
||||
reportheader = '\r' ;
|
||||
if ( !isatty( fileno( stderr ) ) ) {
|
||||
errout ( verbose , "Verbose allowed only when STDERR goes to screen" ) ;
|
||||
|
|
Loading…
Reference in a new issue