Product Specific Modules¶
Canvas¶
The Python Canvas Package¶
The canvas package contains links to the various Canvas Python modules, including modules for fingerprint generation, similarity, and clustering. See the Canvas 1.4 Python API documentation for details on using the core classes. These modules hide many of the lower-level details of fingerprint generation and related tasks, as well as providing standard GUI and command line components that allow setting all the options for fingerprint, similarity and clustering.
Checking out a Canvas License¶
Using the Canvas Python API requires a Canvas license. Scripts that intend to use Canvas functionality must first checkout a Canvas license using the following lines of code:
import schrodinger.application.canvas.utils as canvasutils
lic = canvasutils.get_license(canvasutils.LICENSE_FULL)
If no license is available, the get_license function will raise an
Exception
. The variable lic
must remain in scope as long as any
Canvas functionality is intended to be used. When it goes out of scope, the
license is released.
Converting Structures to ChmMol Objects¶
Low-level Canvas functions do not use Structure
objects directly but
instead use ChmMol
objects. To convert between the two use the following
(“st” is a Structure object obtained using one of the methods described
earlier in the document):
import schrodinger.application.canvas.base as canvas
adaptor = canvas.ChmMmctAdaptor()
mol = adaptor.create(st.handle, canvas.ChmMmctAdaptor.NoStereo)
Fingerprint Generation and Similarity¶
What follows is a simple example showing how to generate fingerprints for two structures and calculate the similarity between the two structures based on those fingerprints:
from schrodinger import structure
from schrodinger.application.canvas import fingerprint
from schrodinger.application.canvas import similarity
from schrodinger.utils import log
import sys
import schrodinger.application.canvas.base as canvas
lic = canvas.ChmLicenseFull()
if not lic.isValid():
print "A full Canvas license is required"
sys.exit(-1)
logger = log.get_output_logger("FPExample:")
fp_gen = fingerprint.CanvasFingerprintGenerator( logger=logger )
fp_sim = similarity.CanvasFingerprintSimilarity( logger=logger )
# Read first and second structures from input file
sr = structure.StructureReader(sys.argv[1])
st1 = sr.next()
st2 = sr.next()
# Generate with default fingerprint settings:
fp1 = fp_gen.generate(st1)
fp2 = fp_gen.generate(st2)
# Calculate and print similarity:
fp_sim.setMetric("Tanimoto")
print "Tanimoto Similarity = %5.2f" % fp_sim.calculateSimilarity(fp1,fp2)
fp_sim.setMetric("Dice")
print "Dice Similarity = %5.2f" % fp_sim.calculateSimilarity(fp1,fp2)
Desmond¶
The desmond and schrodinger.trajectory packages contain modules for various Desmond-related operations. For example, to extract frame 47 from a trajectory:
from schrodinger.trajectory.desmondsimulation import DesmondSimulation
csim = DesmondSimulation(cms_file, trj_directory)
frame = csim.getFrame(47)
st = frame.getStructure()
Glide¶
The glide package helps to set up Glide jobs via keyword-value pairs.
Calculate Enrichment from Virtual Screening¶
The analysis.enrichment module helps to calculate enrichments based on known actives and the number of decoys in screen.
import schrodinger.analysis.enrichment as enrichment
efcalc = enrichment.Calculator(
actives_file_name = "my_actives.txt", # Active titles, one per line.
results = "screen_results.rept", # Glide report file.
total_decoys = 1000
)
efcalc.calculateMetrics() # Calculate a default suite of terms.
efcalc.report() # Print default report to standard out.
efcalc.savePlot() # Create default graph png.
print efcalc.calcBEDROC(alpha=20) # Print the BEDROC metric value
Jaguar¶
The jaguar package helps to set up Jaguar (QM) tasks. For example, to set up and run a Jaguar 6-31g** geometry optimization:
import schrodinger.application.jaguar.input as jagInput
import schrodinger.job.jobcontrol as jc
input = jagInput.read("inputFile.mae")
input.setValue("basis","6-31G**")
input.setValue("dftname","B3LYP")
input.setValue("igeopt","1") # Do geometry optimization
jagFileName = "jag631.in"
input.saveAs(jagFileName)
run_command = [os.path.join(os.environ['SCHRODINGER'], 'jaguar'),
"run",
jagFileName]
job = jc.launch_job(run_command)
MacroModel¶
The macromodel package helps to set up and run MacroModel tasks. To use this module productively, you should be familiar with the MacroModel Reference Manual. As a starting point, see the documentation for the ComUtil and SbcUtil classes.
A few examples of simplified scripts follow.
Set up and run a Monte Carlo multiple minimum conformation search job with non-default options:
import schrodinger.application.macromodel.utils as mmodutils
import schrodinger.job.jobcontrol as jc
import sys
mcu = mmodutils.ComUtil(ffld='mmffs')
# Use extended torsion sampling.
mcu.AUTO[8] = 3
# Write the com file for a Monte Carlo multiple minimum conformation
# search. (To actually run this script, you need to set
# input_structure_file.)
com_file = mcu.mcmm(input_structure_file)
cmd_args = mcu.getLaunchCommand(com_file)
job = jc.launch_job(cmd_args)
job.wait()
print ("MCMM job status: %s" % job.Status)
mcmm_output_file = job.StructureOutputFile
Set up and run a geometry minimization with restraints defined by an Atom
Selection Language expression. This is specified within a MacroModel
substructure file with the ASL2
code.
import schrodinger.application.macromodel.utils as mmodutils
import schrodinger.job.jobcontrol as jc
mcu = mmodutils.ComUtil(subs=True)
# Write the com file for a geometry optimization.
# (To run this script, you should set input_structure_file. For the
# script to do something interesting, the input structure file should
# have more than one molecule. :-)
com_file = mcu.mini(input_structure_file)
# Set up the MacroModel substructure file.
sbu = mmodutils.SbcUtil()
# Specify the force constant for Cartesian restraints.
sbu.ASL2[1] = 200
# Specify the ASL identifying the restrained atoms.
sbu.ASL2[2] = 'mol.n 1'
sbu_args = [com_file, 'ASL2']
sbc_file = sbu.writeSbcFile(sbu_args)
cmd_args = mcu.getLaunchCommand(com_file)
job = jc.launch_job(cmd_args)
job.wait()
print ("MINI job status: %s" % job.Status)
mini_output_file = job.StructureOutputFile
Set up and run a systematic pseudo-Monte Carlo conformation search,
dynamically assigning restraints to a ligand core (SUBS
and FXAT
):
import schrodinger.application.macromodel.utils as mmodutils
import schrodinger.structutils.analyze as analyze
import schrodinger.structure as structure
mcu = mmodutils.ComUtil(subs=True)
# Write the com file for a systematic pseudo-Monte Carlo multiple
# minimum conformation search.
com_file = mcu.spmc(input_structure_file)
# Find the atoms to be restrained via ASL and SMARTS; anything in a
# 6-membered ring.
st = structure.StructureReader(input_structure_file).next()
core_pattern = 'SMARTS. "r6"'
core_atoms = analyze.evaluate_asl(st, "withinbonds 1 %s" % core_pattern)
attachment_atoms = analyze.evaluate_asl(st, "not withinbonds 1 %s" % core_pattern)
# Set up and write the substructure file with the restraints.
sbu = mmodutils.SbcUtil()
sbc_args = [com_file]
sbc_args.extend(sbu.setSubs(attachment_atoms))
sbc_args.extend(sbu.setFixed(core_atoms))
sbu.writeSbcFile(sbc_args)
cmd_args = mcu.getLaunchCommand(com_file)
job = jc.launch_job(cmd_args)
job.wait()
print ("SPMC job status: %s" % job.Status)
spmc_output_file = job.StructureOutputFile
MCPRO+¶
The mcpro package contains a zmat module for working with zmat structures. It also contains various helper functions for the MCPRO+ GUI.
Prime¶
The prime package contains modules for reading and writing Prime input files and for fixing structures for use with Prime.
The protein package contains other modules for protein-related tasks, such as:
- The assignment module for optimizing hydroxyl, thiol and water orientiations, Chi-flips of asparagine, glutamine and histidine, and protonation states of aspartic acid, glutamic acid, and histidine.
- The captermini module for capping uncapped terminal residues.
- The findhets module for finding het (non-protein) compounds in structures.
- The rotamers module provides a rotamer library that can be applied to protein sidechains.
The adjust_residue_numbering_panel.py
script on the Script
Center contains an example of protein structure alignment. The script
also renumbers protein residues based on the alignment.
In addition, the schrodinger.structutils.build module contains a useful
mutate
function.
Here is an example of residue mutation and rotamer-library sampling:
from schrodinger.structutils import build
from schrodinger.protein import rotamers
residue = st.residue[index_of_residue_to_mutate]
# Here, mut_type is the three-letter code for the new residue.
build.mutate(st, residue.atom[1], mut_type)
rotamer_lib = rotamers.Rotamers( st, residue.atom[1] )
for rotamer in rotamer_lib.rotamers:
rotamer.apply()
# Operate on the new structure - compute energy, analyze or write
# the structure.
The prepwizard module also contains useful functions for manipulating protein structures. For example, to fill missing loops in a protein structure, based on a FASTA file sequence:
import schrodinger.application.prepwizard as pw
filled_st = pw.fill_missing_loops(input_st, fasta_file, prime_jobname)
QSite¶
The qsite package helps to set up QSite jobs.
VSW¶
The vsw package contains modules for VSW, including pipelining functionality for VSW jobs.
For example, to use VSW pipelining to write a QikProp job for a file of
ligands ligands_file
:
import schrodinger.application.vsw.input as vswinput
input_file = jobname + '.inp'
txt="""
"""
writer = vswinput.Writer(input_file, comment=txt)
writer.addVar('LIGANDS', 'Structures', [ligands_file])
writer.addStage('RUN_QIKPROP',
'qikprop.QikPropStage',
['LIGANDS'],
['OUTPUT_LIGANDS'])
writer.write()