- is_first = true
- msa = Msa.new
- ic = Iconv.new( 'UTF-8//IGNORE', 'UTF-8' )
- File.open( path ) do | file |
- while line = file.gets
- line = ic.iconv( line )
- if can_ignore?( line )
- saw_ignorable = true
- elsif ( is_first && is_program_name_line?( line ) )
- elsif( line =~ /^\S+\s+.+\s*$/ || line =~ /^\s+.+\s*$/ || line =~ /^\S+\s*$/ )
- if ( saw_ignorable )
- block += 1
- current_seq_index_per_block = -1
- saw_ignorable = false
- end
- current_seq_index_per_block += 1
- if ( line =~ /^(\S+)\s+(.+?)\s*$/ )
- name = $1
- seq = $2.gsub( /\s/, '.' )
- a = msa.find_by_name( name, false, false )
- if ( a.length < 1 )
- msa.add( name, seq )
- elsif ( a.length == 1 )
- msa.get_sequence( a[ 0 ] ).append!( seq )
- else
- error_msg = "Unexpected error at line: " + line
- raise IOError, error_msg
- end
- current_name = name
- elsif ( line =~ /^\s+(.+?)\s*$/ )
- seq = $1.gsub( /\s/, '.' )
- a = msa.find_by_name( current_name, false, false )
- if ( a.length != 1 )
- error_msg = "Unexpected error at line: " + line
- raise IOError, error_msg
- else
- msa.get_sequence( a[ 0 ] ).append!( seq )
- end
+ elsif ( is_first && is_program_name_line?( line ) )
+ elsif( line =~ /^\S+\s+.+\s*$/ || line =~ /^\s+.+\s*$/ || line =~ /^\S+\s*$/ )
+ if ( saw_ignorable )
+ block += 1
+ current_seq_index_per_block = -1
+ saw_ignorable = false
+ end
+ current_seq_index_per_block += 1
+ if ( line =~ /^(\S+)\s+(.+?)\s*$/ )
+ name = $1
+ seq = $2.gsub( /\s/, '.' )
+ a = msa.find_by_name( name, false, false )
+ if ( a.length < 1 )
+ msa.add( name, seq )
+ elsif ( a.length == 1 )
+ msa.get_sequence( a[ 0 ] ).append!( seq )
+ else
+ error_msg = "Unexpected error at line: " + line
+ raise IOError, error_msg
+ end
+ current_name = name
+ elsif ( line =~ /^\s+(.+?)\s*$/ )
+ seq = $1.gsub( /\s/, '.' )
+ a = msa.find_by_name( current_name, false, false )
+ if ( a.length != 1 )
+ error_msg = "Unexpected error at line: " + line
+ raise IOError, error_msg
+ else
+ msa.get_sequence( a[ 0 ] ).append!( seq )
+ end