(file_, num_evo_entries)
Read a Mathematica protein record from file and convert into dict.
Read a Mathematica protein record from file and convert into dict.
Read a Mathematica protein record from file and convert into dict .
def read_record(file_, num_evo_entries):
    """ Read a Mathematica protein record from file and convert into dict. """
    
    dict_ = {}

    while True:
        next_line = file_.readline()
        for case in switch(next_line):
            if case('[ID]' + '\n'):
                id_ = file_.readline()[:-1]
                dict_.update({'id': id_})
            elif case('[PRIMARY]' + '\n'):
                primary = letter_to_num(file_.readline()[:-1], _aa_dict)
                dict_.update({'primary': primary})
            elif case('[EVOLUTIONARY]' + '\n'):
                evolutionary = []
                for residue in range(num_evo_entries): evolutionary.append([float(step) for step in file_.readline().split()])
                dict_.update({'evolutionary': evolutionary})
            elif case('[SECONDARY]' + '\n'):
                secondary = letter_to_num(file_.readline()[:-1], _dssp_dict)
                dict_.update({'secondary': secondary})
            elif case('[TERTIARY]' + '\n'):
                tertiary = []
                for axis in range(NUM_DIMENSIONS): tertiary.append([float(coord) for coord in file_.readline().split()])
                dict_.update({'tertiary': tertiary})
            elif case('[MASK]' + '\n'):
                mask = letter_to_num(file_.readline()[:-1], _mask_dict)
                dict_.update({'mask': mask})
            elif case('\n'):
                return dict_
            elif case(''):
                return None
def read_record ( file_ , num_evo_entries ) : dict_ = { } while True : next_line = file_ . readline ( ) for case in switch ( next_line ) : if case ( '[ID]' + '\n' ) : id_ = file_ . readline ( ) [ : - 1 ] dict_ . update ( { 'id' : id_ } ) elif case ( '[PRIMARY]' + '\n' ) : primary = letter_to_num ( file_ . readline ( ) [ : - 1 ] , _aa_dict ) dict_ . update ( { 'primary' : primary } ) elif case ( '[EVOLUTIONARY]' + '\n' ) : evolutionary = [ ] for residue in range ( num_evo_entries ) : evolutionary . append ( [ float ( step ) for step in file_ . readline ( ) . split ( ) ] ) dict_ . update ( { 'evolutionary' : evolutionary } ) elif case ( '[SECONDARY]' + '\n' ) : secondary = letter_to_num ( file_ . readline ( ) [ : - 1 ] , _dssp_dict ) dict_ . update ( { 'secondary' : secondary } ) elif case ( '[TERTIARY]' + '\n' ) : tertiary = [ ] for axis in range ( NUM_DIMENSIONS ) : tertiary . append ( [ float ( coord ) for coord in file_ . readline ( ) . split ( ) ] ) dict_ . update ( { 'tertiary' : tertiary } ) elif case ( '[MASK]' + '\n' ) : mask = letter_to_num ( file_ . readline ( ) [ : - 1 ] , _mask_dict ) dict_ . update ( { 'mask' : mask } ) elif case ( '\n' ) : return dict_ elif case ( '' ) : return None