Package: rush-py
rush-pyQuickstartThis document will walk through executing jobs on the rush platform. For
a comprehensive guide on the concepts and constructing a full workflow,
see thefull rush-py
explainerdocument.First, install the following modules via pip—we require Python ≥ 3.10:pip install rush-py pdb-tools0) SetupThis is where we prepare the rush client, directories, and input data
we’ll be working with.0.0) ImportsimportosimporttarfilefromdatetimeimportdatetimefrompathlibimportPathimportpy3Dmolimportrequestsfrompdbtoolsimportpdb_delhetatm,pdb_fetch,pdb_selchainimportrushNOTE: This walkthrough assumes that you are running code in a
Jupyter notebook, which allows for top levelawaitcalls. If you are
writing a normal Python script, you will need to wrap your code in
something like the following:importasynciodefmain():#your code hereasyncio.run(main)0.1) CredentialsRetrieve your API token from theRush
UI.You can either set theRUSH_URLandRUSH_TOKENenvironment variables
or provide them as variables to the client directly.To see how to set environment variables,Wikipediahas an
extensive article.RUSH_URL=os.getenv("RUSH_URL")or"https://tengu.qdx.ai"RUSH_TOKEN=os.getenv("RUSH_TOKEN")or"YOUR_TOKEN_HERE"0.2) ConfigurationLets set some global variables that define our project. These are not
required, but are good practice to help organize the jobs that will be
persisted under your account.Make sure you create a unique set of tags for each run. Good practice is
to have at least each of the experiment name and system name as a tag.EXPERIMENT="rush-py-quickstart"SYSTEM="1B39"TAGS=["qdx",EXPERIMENT,SYSTEM]0.2) Build your clientGet our client, which we’ll use for calling modules and generally for
using the Rush API.As mentioned earlier,urlandaccess_tokenare optional if you have
set the env variablesRUSH_URLandRUSH_TOKENrespectively.batch_tagswill be applied to each run that is spawned by this client.A folder called.rushwill be created in your workspace directory
(defaults to the current working directory, can be overridden by passingworkspace=to the provider builder).# By using the `build_provider_with_functions` method,# we will also build helper functions calling each moduleclient=awaitrush.build_provider_with_functions(url=RUSH_URL,access_token=RUSH_TOKEN,batch_tags=TAGS)0.3) Input selectionFetch data files from RCSB to pass as input to the modules:PROTEIN_PDB_PATH=client.workspace/f"{SYSTEM}_P.pdb"complex=list(pdb_fetch.fetch_structure(SYSTEM))protein=pdb_delhetatm.remove_hetatm(pdb_selchain.select_chain(complex,"A"))withopen(PROTEIN_PDB_PATH,"w")asf:forlinprotein:f.write(str(l))help(client.convert)Help on function convert in module rush.provider:

async convert(*args: *tuple[EnumValue, RushObject[bytes]], target: 'Target | None' = None, resources: 'Resources | None' = {'storage': 10, 'storage_units': 'MB', 'gpus': 0}, tags: 'list[str] | None' = None, restore: 'bool | None' = None) -> tuple[RushObject[list[Conformer]]]
    Convert biomolecular and chemical file formats to the QDX file format. Supports PDB and SDF
    
    Module version:  
    `github:talo/tengu-prelude/efc6d8b3a8cc342cd9866d037abb77dac40a4d56#convert`
    
    QDX Type Description:
    
        format: PDB | SDF;
        input: @bytes
        ->
        output: @[Conformer]
    
    
    :param format: the format of the input file
    :param input: the input file
    :return output: the output conformers1) Running Rush ModulesYou can view which modules are available, alongside their documentation,
in theAPI Documentation.1.1) Prep the proteinFirst we will run the protein preparation routine (using pdbfixer and
pdb2pqr internally) to prepare the protein for a molecular dynamics
simulation.# we can check the arguments and outputs for prepare_protein with help()help(client.prepare_protein)Help on function prepare_protein in module rush.provider:

async prepare_protein(*args: *tuple[RushObject[bytes]], target: 'Target | None' = None, resources: 'Resources | None' = {'storage': 138, 'storage_units': 'MB', 'gpus': 1}, tags: 'list[str] | None' = None, restore: 'bool | None' = None) -> tuple[RushObject[list[Conformer]], RushObject[bytes]]
    Prepare a PDB for downstream tasks: protonate, fill missing atoms, etc.
    
    Module version:  
    `github:talo/prepare_protein/83bed2ad1f01f495c94518717f9f5b1bd7fe855c#prepare_protein_tengu`
    
    QDX Type Description:
    
        input_pdb: @bytes
        ->
        output_qdxf: @[Conformer];
        output_pdb: @bytes
    
    
    :param input_pdb: An input protein as a file; one PDB file
    :return output_qdxf: An output protein a vec: one qdxf per model in pdb
    :return output_pdb: An output protein as a file: one PDB file# Here we run the function, it will return a Provider.Arg which you can use to# fetch the results# We set restore = True so that we can restore a previous run to the same path# with the same tagsprepared_protein_qdxf,prepared_protein_pdb=awaitclient.prepare_protein(PROTEIN_PDB_PATH,)# This initially only has the id of your result; we will show how to fetch the# actual value laterprepared_protein_qdxf2024-02-16 17:14:00,643 - rush - INFO - Trying to restore job with tags: ['qdx', 'rush-py-quickstart', '1B39'] and path: github:talo/prepare_protein/83bed2ad1f01f495c94518717f9f5b1bd7fe855c#prepare_protein_tengu
2024-02-16 17:14:00,835 - rush - INFO - Restoring job from previous run with id b073d2c8-5754-4b8e-8bd4-31d7b2c6a0b7

Arg(id=906fad5a-4829-4a39-8ffa-73bcdfd82c17, value=None)1.3) Run statusesThis will show the status of all of your runs. You can also view run
statuses on theRush UI.awaitclient.status(){}1.4) Run ValuesThis will return the “value” of the output from the function—for files
you will recieve a url that you can download, otherwise you will recieve
them as python types:protein_qdxf_value=awaitprepared_protein_qdxf.get()len(protein_qdxf_value[0]["topology"]["symbols"])48491.5) DownloadsWe provide a utility to download files into your workspace, you can
either provide a filename, which will be saved inworkspace/objects/[filename], or you can provide your own filepath
which the client will use as-is:awaitprepared_protein_pdb.download(filename="01_prepared_protein.pdb",overwrite=True)# we can read our prepared protein pdb like thiswithopen(client.workspace/"objects"/"01_prepared_protein.pdb","r")asf:print(f.readline(),"...")REMARK   1 CREATED WITH OPENMM 8.0, 2024-02-10
 ...