Skip to content

Instantly share code, notes, and snippets.

@dacarlin
Last active May 16, 2017 11:18
Show Gist options
  • Save dacarlin/a1bac7ab7c19527ec11dd10dbe35effd to your computer and use it in GitHub Desktop.
Save dacarlin/a1bac7ab7c19527ec11dd10dbe35effd to your computer and use it in GitHub Desktop.
Generate feature sets using RosettaScripts and analyze using Pandas
  1. Install Anaconda Python

  2. Add a features reporter moveer to your RosettaScript. Or, if you have already generated output scripts and wish to scroe them and report features, use a simple script like the following

<ROSETTASCRIPTS>
<SCOREFXNS>
  <t weights=talaris2014_cst.wts />
</SCOREFXNS>
<MOVERS>
  <ReportToDB name=report database_name=features.db3>
    <feature name=ResidueFeatures />
    <feature name=InterfaceFeatures scorefxn=t pack_together=false />
  </ReportToDB>
</MOVERS>
<PROTOCOLS>
    <Add mover=report /> 
</PROTOCOLS>
</ROSETTASCRIPTS>
  1. To take the features.db3 database and import into Pandas for use, all you need is to
import sqlite3

my_feature_tables = {}
db = sqlite3.connect( 'features.db3' )
cursor = db.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()

for table_name in tables:
    table_name = table_name[0]
    table = pandas.read_sql_query("SELECT * from %s" % table_name, db)
    my_feature_tables.update( { table_name: table } ) 

which will give you a dictionary filled with Pandas DataFrames with the SQL tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment