add comment

This commit is contained in:
kuoi 2022-04-12 01:32:27 +01:00
parent a533f12f7c
commit e2cd563a78

View file

@ -680,26 +680,26 @@ void get_fasta_dims ( int * mync , int * mynt )
char c ; char c ;
int curnt = 0 , curnc = 0 , atnc ; int curnt = 0 , curnc = 0 , atnc ;
char * nampt = strsp ; char * nampt = strsp ;
while ( !feof ( inp ) && i != '>' ) i = getc ( inp ) ; while ( !feof ( inp ) && i != '>' ) i = getc ( inp ) ; //没读到 EOF 并且不是 > 继续,直到读到 >
if ( i != '>' ) { if ( i != '>' ) { //读到最后没有 > 报错
fprintf ( stderr , "\nError reading fasta file --expected taxon name\n" ) ; fprintf ( stderr , "\nError reading fasta file --expected taxon name\n" ) ;
errout ( 1 , NULL ) ; } errout ( 1 , NULL ) ; }
while ( !feof ( inp ) ) { while ( !feof ( inp ) ) { //没读到 EOF 不停
fscanf ( inp , " %s" , nampt ) ; fscanf ( inp , " %s" , nampt ) ; //从 inp 读到 nampt
i = 0 ; i = 0 ;
++ curnt ; ++ curnt ;
if ( curnt == 1) if ( curnt == 1) //第一次
while ( 1 ) { while ( 1 ) {
fscanf ( inp , " %c" , &c ) ; fscanf ( inp , " %c" , &c ) ;
if ( c == '>' || feof ( inp ) ) break ; if ( c == '>' || feof ( inp ) ) break ; //读到 > 或者 EOF
++ curnc ; } ++ curnc ; } // 读到 > 或者 EOF curnc ++
else { else { //第二次及之后
atnc = 0 ; atnc = 0 ;
while ( 1 ) { while ( 1 ) {
fscanf ( inp , " %c" , &c ) ; fscanf ( inp , " %c" , &c ) ;
if ( c == '>' || feof ( inp ) ) break ; if ( c == '>' || feof ( inp ) ) break ;
++ atnc ; } ++ atnc ; }
if ( atnc != curnc ) { if ( atnc != curnc ) { //到最后比较
fprintf ( stderr , "\nError reading fasta file --it seems not to be aligned\n" ) ; fprintf ( stderr , "\nError reading fasta file --it seems not to be aligned\n" ) ;
errout ( 1 , NULL ) ; }}} errout ( 1 , NULL ) ; }}}
* mync = curnc ; * mync = curnc ;
@ -715,22 +715,22 @@ void read_multifiles ( void )
int atfile = 0 , numfiles = 0 ; int atfile = 0 , numfiles = 0 ;
char ** taxnam ; char ** taxnam ;
double prop , secs , prevprop ; double prop , secs , prevprop ;
clock_t beg , end ; clock_t beg , end ; // 定义起始时间
beg = clock () ; beg = clock () ; //计算时间
errout ( ( tmpp = fopen ( "oblong.tmp" , "wb" ) ) == NULL , "Cannot open temporary file, \"oblong.tmp\"" ) ; errout ( ( tmpp = fopen ( "oblong.tmp" , "wb" ) ) == NULL , "Cannot open temporary file, \"oblong.tmp\"" ) ;
// Find out total NT and total NC // Find out total NT and total NC
multinp = inp ; multinp = inp ;
maskinit ( ) ; maskinit ( ) ; //maskinit 函数
taxnam = ( char ** ) myalloc ( MAXMULTITAXA * sizeof ( char * ) ) ; taxnam = ( char ** ) myalloc ( MAXMULTITAXA * sizeof ( char * ) ) ; //default MAXMULTITAXA 1000 L32
fscanf ( inp , " %s" , nampt ) ; fscanf ( inp , " %s" , nampt ) ; //FILE * inp = NULL 读入文件到 nampt
while ( !feof ( multinp ) ) { while ( !feof ( multinp ) ) { //feof 如果 EOF 返回非 0没有EOF 返回 0
++ numfiles ; ++ numfiles ; //numfiles 初始为 0
if ( ( inp = fopen ( nampt , "rb" ) ) == NULL ) { if ( ( inp = fopen ( nampt , "rb" ) ) == NULL ) { // r readbale b binary 二进制可以防止 Windows下文件问题
fprintf ( stderr , "\nCannot open file %s (from list of multiple files)\n" , nampt ) ; fprintf ( stderr , "\nCannot open file %s (from list of multiple files)\n" , nampt ) ;
exit ( 0 ) ; } exit ( 0 ) ; }
if ( reporttoscreen ) if ( reporttoscreen ) // L60: default 1 L309:0
fprintf ( stderr , "%cChecking input file %3i %-40s" , reportheader , numfiles , nampt ) ; fprintf ( stderr , "%cChecking input file %3i %-40s" , reportheader , numfiles , nampt ) ;
if ( fasta ) get_fasta_dims ( &nc , &nt ) ; if ( fasta ) get_fasta_dims ( &nc , &nt ) ; //get nc and nt
else { else {
i = fscanf ( inp , " %i %i" , &nt , &nc ) ; i = fscanf ( inp , " %i %i" , &nt , &nc ) ;
if ( i < 2 ) { if ( i < 2 ) {
@ -750,7 +750,7 @@ void read_multifiles ( void )
if ( !strcmp ( nampt , taxnam[ i ] ) ) matched = i ; if ( !strcmp ( nampt , taxnam[ i ] ) ) matched = i ;
if ( matched < 0 ) { if ( matched < 0 ) {
errout( curnt >= MAXMULTITAXA , "Sorry, cannot deal with so many distinct taxon names (change MAXMULTITAXA and recompile)" ) ; errout( curnt >= MAXMULTITAXA , "Sorry, cannot deal with so many distinct taxon names (change MAXMULTITAXA and recompile)" ) ;
taxnam [ curnt ] = ( char * ) myalloc ( MAXNAMELEN * sizeof ( char ) ) ; taxnam [ curnt ] = ( char * ) myalloc ( MAXNAMELEN * sizeof ( char ) ) ; //MAXNAMELEN = 1000 default
strcpy ( taxnam [ curnt ++ ] , nampt ) ; } strcpy ( taxnam [ curnt ++ ] , nampt ) ; }
if ( fasta ) -- nampt ; if ( fasta ) -- nampt ;
for ( b = 0 ; b < nc ; ++ b ) { for ( b = 0 ; b < nc ; ++ b ) {