def parse_ng86(lines, results):
 sequences = []
 for line in lines:
  line_floats_res = re.findall('-*\\d+\\.\\d+', line)
  line_floats = [float(val) for val in line_floats_res]
  matrix_row_res = re.match('^([^\\s]+?)(?:\\s+-?\\d+\\.\\d+|\\s*$|-1.0000\\s*\\()', line)
  if (matrix_row_res is not None):
   seq_name = matrix_row_res.group(1).strip()
   sequences.append(seq_name)
   results[seq_name] = {}
   for i in range(0, len(line_floats), 3):
    NG86 = {}
    NG86['omega'] = line_floats[i]
    NG86['dN'] = line_floats[(i + 1)]
    NG86['dS'] = line_floats[(i + 2)]
    results[seq_name][sequences[(i // 3)]] = {'NG86': NG86}
    results[sequences[(i // 3)]][seq_name] = {'NG86': NG86}
 return (results, sequences)

def parse_ng86 ( lines , results ) : sequences = [ ] for line in lines : line_floats_res = re . findall ( '-*\\d+\\.\\d+' , line ) line_floats = [ float ( val ) for val in line_floats_res ] matrix_row_res = re . match ( '^([^\\s]+?)(?:\\s+-?\\d+\\.\\d+|\\s*$|-1.0000\\s*\\()' , line ) if ( matrix_row_res is not None ) : seq_name = matrix_row_res . group ( 1 ) . strip ( ) sequences . append ( seq_name ) results [ seq_name ] = { } for i in range ( 0 , len ( line_floats ) , 3 ) : NG86 = { } NG86 [ 'omega' ] = line_floats [ i ] NG86 [ 'dN' ] = line_floats [ ( i + 1 ) ] NG86 [ 'dS' ] = line_floats [ ( i + 2 ) ] results [ seq_name ] [ sequences [ ( i // 3 ) ] ] = { 'NG86' : NG86 } results [ sequences [ ( i // 3 ) ] ] [ seq_name ] = { 'NG86' : NG86 } return ( results , sequences )
parse the nei & gojobori section of the results .