Kortemme-Lab / flex_ddG_tutorial

MIT License
69 stars 26 forks source link

analyze_flex_ddG.py #26

Open MilesYyh opened 1 year ago

MilesYyh commented 1 year ago

Hi! @kylebarlow I run the run_example_1.py and it output files include (pdb rosetta.out and wt_traj). It didn't have the file of ddG.db3. And then, I run the analyze_flex_ddG.py. Something wrong. So i fix the code in the analyze_flex_ddG.py. I delte the "ddG.db3" relative in the code. Finally it work. It is okay?

Like I delte the following: def get_scores_from_db3_file(db3_file, struct_number, case_name): conn = sqlite3.connect(db3_file) conn.row_factory = sqlite3.Row c = conn.cursor()

num_batches = c.execute('SELECT max(batch_id) from batches').fetchone()[0]

scores = pd.read_sql_query('''
SELECT batches.name, structure_scores.struct_id, score_types.score_type_name, structure_scores.score_value, score_function_method_options.score_function_name from structure_scores
INNER JOIN batches ON batches.batch_id=structure_scores.batch_id
INNER JOIN score_function_method_options ON score_function_method_options.batch_id=batches.batch_id
INNER JOIN score_types ON score_types.batch_id=structure_scores.batch_id AND score_types.score_type_id=structure_scores.score_type_id
''', conn)

def renumber_struct_id( struct_id ):
    return trajectory_stride * ( 1 + (int(struct_id-1) // num_batches) )

scores['struct_id'] = scores['struct_id'].apply( renumber_struct_id )
scores['name'] = scores['name'].apply( lambda x: x[:-9] if x.endswith('_dbreport') else x )
scores = scores.pivot_table( index = ['name', 'struct_id', 'score_function_name'], columns = 'score_type_name', values = 'score_value' ).reset_index()
scores.rename( columns = {
    'name' : 'state',
    'struct_id' : 'backrub_steps',
}, inplace=True)
scores['struct_num'] = struct_number
scores['case_name'] = case_name

conn.close()

return scores