schrodinger.project.project module¶
Interface to the active Maestro Project.
Projects may be accessed while within Maestro or without Maestro from a python script that imports this module. Usually when running from within Maestro the Project object would be returned via maestro.project_table_get()
For a description of basic concepts that clarify the relationship between the Workspace and Maestro Projects as well as when and how changes in one affect the other, please see the Basic Concepts section in the Python Module Overview located at schrodinger.com/pythonapi.
Adding a copy of a structure to a project can be done using
pt = maestro.project_table_get()
pt.importStructure(ct)
All row access is with respect to the order of rows in the project (which can differ from the order of rows in Maestro’s Project Table since the table’s rows can be sorted and rearranged).
Column and Row indices start at 1.
There are 3 ways to refer to rows:
Internal project index in mmproj, they are effectively indices into an array. These values are hidden from the user; avoid using them in scripts.
Project Table row number, as it appears in the left-most column of the PT in Maestro. This number can change when rows are deleted or the table is sorted.
Entry ID, which is unique for each row and never changes. These values are ints, but are often represented as strings, e.g. “1”. Scratch entries will have non-int entry IDs, but are not stored in the project table. These are used in Maestro commands, ASLs, etc, and are visible to the user.
Iterating over all rows in the project is done using an expression of the form:
pt=maestro.project_table_get()
for row in pt.all_rows:
# Now do something with row
Iterating over selected rows in the project is done using an expression of the form:
pt=maestro.project_table_get()
for row in pt.selected_rows:
# Now do something with row
Accessing each row of the project table returns a ProjectRow object. Common operations on ProjectRow objects are to get (or set) a structure associated with that row:
st = row.getStructure()
# and then update
row.setStructure(st)
Also common is accessing the project data. This can be done either by the name of the project table column or the dataname (the latter being as it appears in Maestro format files):
energy = row.property['r_mmod_Relative_Potential_Energy-MMFF94']
New columns and new properties for existing entries can be added to the project in a similar way. Note that the refreshTable() function is usually required to be called to show the results of additions to the project table.
A project should be open by at most one process at any given time. It is an error to open a project currently opened by another process.
Copyright Schrodinger LLC, All rights reserved.
- class schrodinger.project.project.EmptyIterator¶
Bases:
object
Empty iterator. Useful if you have some object that returns an iterator in most cases but in some cases does not. In the “not” case you can return an empty iterator and the calling code can still use a “for i in iterator” form as it will be a no-op.
- __init__()¶
- __len__()¶
Needed to allow “if empty_iterator” to evaluate to False. Halts the iteration. Can also be used to check to see if the iterator exists or not.
- class schrodinger.project.project.ProjectRow(pt, row_index)¶
Bases:
object
ProjectRow allows access to the structure and properties of an entry in the project. It is an access mechanism and not a completely self-contained object - project row objects should be treated as transient, they may become invalid by subsequent project operations.
This class represents a project entry. Each row is linked to one entry, but row != entry
There are 3 ways to identify a row:
- ProjectRow.index: Internal project order, entry in project - NOT sorted
and NOT same as entry_id.
- ProjectRow.row_number: Table row position - changes when table is
sorted
- ProjectRow.entry_id: ID of the entry represented by this row, never
changes.
Normally it won’t be necessary to create an explicit ProjectRow object, one will be returned by indexing into a ProjectTable object
- __init__(pt, row_index)¶
Construct a ProjectRow for the given Project instance based on an entry index.
- getStructure(props=True, copy=True, workspace_sync=True)¶
- Returns
The entry’s structure
- Return type
structure.Structure
- Parameters
props (bool) – Whether the associated PT properties are included in the returned structure (default).
copy – Whether to return a copy of the PT structure (default). If set to False, returns the original CT for the entry. Such use should in general be avoided, except as an optimization. NOTE: With copy=False, when the returned CT is modified, the changes are instantly propagated to the PT, but not the Workspace, and changes to properties do not propagate. Unless it’s certain that properties didn’t change, and that the structure is not included in the Workspace, any changes to it should be followed up by a call to setStructure().
workspace_sync – If this entry is included in Workspace, sync the Workspace with Project Table before retreiving entry’s structure. As an optimization, when getStructure() is called in a loop, call maestro.project_table_synchronize(), then call getStructure() with workspace_sync=False for each entry.
WARNING: The current default (copy=True) is to make a duplicate of the entry’s structure. These will be marked for garbage collection once they go out of scope in the calling code, but if, for example, you are in a loop your memory usage will grow until the loop is exited (and it may even take a while for it to drop since garbage collection is not necessarily immediate). This can cause large memory usage if, for example, you are iterating over a large number entries. In some cases you may want to explicitly delete the returned Structure. For example, in a loop iterating over a large number of entries you may want to delete the Structure while still in the loop (after you’re done processing the Structure) to prevent memory bloat.
- setStructure(struct, props=True, copy=True, sync_workspace=True)¶
Set the structure of the entry to the specified structure. If the entry is included in the Workspace, the Workspace CT will be updated accordingly.
- Parameters
struct (schrodinger.structure.Structure) – Set the entry to this Structure object
copy (bool) – If True, a copy of the Structure (CT) is made and that copy is used to set the entry. If False, the original Structure, struct, is placed into the project table. Doing this hands off control of struct and you should no longer use struct.
props (bool) – If True, update properties in the entry. If False, properties are ignored.
sync_workspace (bool) – Whether to update the maestro workspace
- property structure¶
This attribute is deprecated. Please use ProjectRow.getStructure() and ProjectRow.setStructure() instead.
- inWorkspace()¶
Obsolete. Use ProjectRow.in_workspace property instead.
- includeOnly(scroll_to_row=False)¶
Include this entry in the workspace and exclude all other entries.
- Parameters
scroll_to_row (bool) – If True, scroll to the included row in case it’s out of view.
- selectOnly()¶
Select this entry and de-select all other entries in the Project Table.
- delete()¶
Delete this row/entry from the project.
- property title¶
The title of the entry
- property index¶
Internal Project index of the row. This is different from Project Table row number or from entry ID.
- property row_number¶
This is the Project Table row number, as it appears to the user in Maestro. It is different from the internal row index.
- property entry_id¶
Entry ID of the row
- property group¶
EntryGroup for the row
- doc = 'Inclusion state of the entry (NOT_IN_WORKSPACE/IN_WORKSPACE/LOCKED_IN_WORKSPACE)\nWARNING: This property should NOT be treated as a boolean.'¶
- property in_workspace¶
Inclusion state of the entry (NOT_IN_WORKSPACE/IN_WORKSPACE/LOCKED_IN_WORKSPACE) WARNING: This property should NOT be treated as a boolean.
- property is_selected¶
Whether the entry is selected
- property read_only¶
Whether the entry is read only or not
- property deletable¶
Whether the entry is deletable or not
- property cms_structure_reader¶
Return StructureReader for associated CMS file or EmptyIterator if there is no associated file
- property cms_file¶
Return associated CMS file or None if there is no associated file
- property surfaces¶
Return an interator to the surface objects available for this entry
- newMolecularSurface(*args, **kwargs)¶
Create a new molecular surface for this row
- Parameters
name (str) – The name of the surface. Note that project rows require all surfaces to be named uniquely. See
overwrite
.asl (str or NoneType) – If given, the surface will only be created for atoms in the structure that match the provided ASL. Note that only one of
asl
andatoms
may be given. If neither are given, then the surface will be created for all atoms in the structure.atoms (list or NoneType) – An optional list of atom numbers. If given, the surface will only be created for the specified atoms. Note that only one of
asl
andatoms
may be given. If neither are given, then the surface will be created for all atoms in the structure.resolution (float) – The resolution of the surface, generally between 0 and 1. Smaller numbers lead to a more highly detailed surface.
probe_radius (float) – The radius of the rolling sphere used to calculate the surface. Defaults to 1.4 if
mol_surf_type
issurface.MolSurfType.Molecular
orsurface.MolSurfType.Extended
. May not be given ifmol_surf_type
issurface.MolSurfType.vdw
.vdw_scaling (float) – If given, all atomic radii will be scaled by the provided value before the surface is calculated.
mol_surf_type (
surface.MolSurfType
) – The type of surface to create.overwrite (bool) – What to do if the new surface has the same name as an existing surface for this project row. If True, the existing surface will be overwritten. In False, a ValueError will be raised.
- Returns
The new surface
- Return type
project_surface.Surface
- property surface¶
A dictionary of all surfaces for this row. Keys are surface names and values are
project_surface.Surface
objects. :type:project_surface.SurfaceDict
- moveToGroup(group_name)¶
Move this entry to group. If group does not exist it will be created.
- Parameters
group_name (str) – Name of group to which to move this entry. If such group doesn’t exist, it will be created. Note, this is different from the user-visible group title.
- ungroup()¶
Remove this entry from its current group.
- property property¶
Dictionary-like container of entry properties. Keys are strings of the form
type_family_name
as described instructure.PropertyName
documentation.
- class schrodinger.project.project.EntryGroup(pt, group_index)¶
Bases:
object
A class which represents an entry group in the project table. Entry groups are returned from the Project.group property.
The entry group itself has a number of properties:
collapsed - set or get the entry collapse/expand state
title - set or get the entry group title (What the user sees)
name - set or get the entry group name (Hidden unique name)
The following iterators are available which are very similar to those available from the Project class but only operate on the entries in the group:
all_rows - an iterator for all the rows in the group
selected_rows - an iterator for selected rows in the group
included_rows - an iterator for included rows in the group
- __init__(pt, group_index)¶
- property name¶
Get and set the group name (NOTE: this is different from user-visible group title)
- getParentGroup()¶
Return the parent EntryGroup, or None if this group is top-level.
- Returns
Parent entry, or None
- Return type
EntryGroup or None
- property title¶
Get and set the title of this group, as displayed in the PT.
- property collapsed¶
Get and set the collapsed state of this group
- property all_rows¶
Iterator for all rows in the group using the visible project table order
- property selected_rows¶
Iterator for the selected rows in the group usig the visible project table order
- property included_rows¶
Iterator for all included rows in the group. Order should be treated as random
- class schrodinger.project.project.EntrySurface(pt, surface_name, surface_handle)¶
Bases:
object
A class for accessing the surfaces associated with a given entry. This class will usually only be created from the EntrySurfaceIterator
- __init__(pt, surface_name, surface_handle)¶
- property included¶
Whether the surface is included in the Workspace.
- class schrodinger.project.project.Project(project_name='', project_handle=- 1, manage=True, show_cleanup_dialog_on_close=False)¶
Bases:
schrodinger.infra.mmobject.MmObject
Class to handle Maestro Projects. This is largely a wrapper to the underlying C library which stores all the state information.
The Project class allows selection of rows in the project via various interfaces.
A Maestro project may be accessed from within a Maestro session which has it open via maestro.project_table_get().
A Maestro project may alternatively be accessed without Maestro running by specifying a the name of the project when creating a project object.
See the doc string for the module for more details.
- static setDebug(state)¶
Enable or disable debug output. Use False or True. Sets this for the class, i.e. affects all instances, current and future.
- enable(option=None)¶
Enable the specified option. Currently only AUTOMATIC_CACHE_FREEING is available. This will cause any cached entries to be freed automatically after each iteration when using the all_rows iterator. Other iterators do not allow automatic cache freeing to be enabled.
- disable(option=None)¶
Disable the specified option. Currently only AUTOMATIC_CACHE_FREEING is available. See enable() for details.
- static initialize(error_handler=None)¶
Initialize necessary mmlibs (which will also implicitly initialize all the dependent mmlibs)
- static terminate()¶
Terminate various mmlibs (which also implicitly terminates all the libraries they are dependent upon)
- __init__(project_name='', project_handle=- 1, manage=True, show_cleanup_dialog_on_close=False)¶
Construct a Project instance either by opening a project file or using a handle to an already opened project.
- Parameters
project_name (str) – The name of the project to open
project_handle – The handle of an already open project
manage (bool) – Whether to perform garbage collection and close project when the project is delete or goes out of scope.
show_cleanup_dialog_on_close (bool) – Whether to block the process and show a clean up dialog when closing the project
- Note
Either project_name or project_handle must be passed in, but not both
- Note
If show_cleanup_dialog_on_close is False, project_cleanup is run in process
When a non-managed instance goes out of scope or is deleted the project is left open. This is desirable, for example, when you construct a python Project instance using the project handle of Maestro’s currently opened project. This allows Maestro to continue working with the opened project after the python Project instance is gone. Otherwise, the project would be closed and Maestro left in an invalid state, thinking that the project was still open.
- close()¶
Close the project immediately. Call this method on projects after being done using them. Current maestro project can not be closed. Note that the project cleanup will occur in-process; cleanup can be delayed until the process exits (or Maestro is closed) by relying on garbage collector to close the project instead of explicitly calling the close() method - but then the project can not be used anywhere again until that happens.
- __len__()¶
Return the number of entries (rows) in the project
- getRow(entry_id)¶
Retrieve a ProjectRow instance based on the entry ID.
- Parameters
entry_id (int or str) – is the entry ID of this project’s entry. This is the internally assigned identifier that is invariant for the life of the project. The ID does not change even if other entries are deleted or the entries (rows) in the Project are sorted. Entry ID can be passed in as a string also (e.g. “1”).
- Return type
- Returns
ProjectRow if entry ID is valid Otherwise, returns None.
- __contains__(entry)¶
Determine if the project contains the specified entry ID
- Parameters
entry_id (int or str) – The entry ID to check the project for.
- Return type
bool
- Returns
True if the specified entry ID is present. False otherwise.
- deleteRow(entry_id)¶
Delete the row with the given entry ID from this project.
- update()¶
If running in Maestro, update the project after a change as the user wants to see their changes in the PT. Does not do anything if the manual_update attribute is set to True.
- findRowsMatching(prop, cmp_op, value)¶
Returns a list of ProjectRow entries for all rows matching the given criteria.
cmp_op should be “<”, “<=”, “>”, “>=”, “==”, “!=”
- getSelectedRowTotal()¶
Return the total number of selected rows
- selectRows(select_mode=1, *args, **keywords)¶
Select rows in the project. Valid modes of selection are:
project.ADD - add rows to existing PT selection.
project.REPLACE - replace current selection.
project.INVERT - invert the PT selection.
project.ALL - select all rows in the PT.
project.NONE - deselect all rows in the PT.
Examples:
pt.selectRows(project.REPLACE, entry_ids=[1, 2, 3]) pt.selectRows(project.ALL) pt.selectRows(project.NONE) pt.selectRows(entry_ids=[1, 2, 3]) pt.selectRows(ADD, esl="entry_re entry*")
- Parameters
select_mode – Selection mode.
entry_ids (list(int) or list(str)) – List of entry IDs for the rows to select.
esl (str) – This is an ESL definition.
rows – Project indices for the rows to select (deprecated). Values refer to the values of the ProjectRow.index property.
rows – list(int)
function (callable) – Callback for determining whether a row should be selected or not (deprecated).
- includeRows(entry_ids, exclude_others=True, autofit=True)¶
Include rows with the given entry IDs in the Workspace, while optionally excluding all other entries. If entry_ids list is empty and exclude_others is True, all PT entries will be excluded.
- Parameters
entry_ids (list of ints or str.) – List of Entry IDs to include.
exclude_others (bool) – Whether to also exclude previously included entries.
autofit (bool) – Whether to fit WS towards included entries
- moveRowsToGroup(entry_ids, group_name)¶
Move a list of project entries into a group.
- Parameters
entry_ids (list(str)) – a list of project entry IDs
group_name (str) – The unique ID of a group; if a group with this name doesn’t exist, it will be created. Note, this is different from the user-visible group title.
- refreshTable()¶
Refresh the project table
This is only usable from within Maestro.
- getPropertyNames()¶
Return a list of the data names of usable properties in this project instance, including properties which were hidden. There are some additional properties, like whether an entry is selected or included, which are not returned by this function.
- getVisiblePropertyNames()¶
Return a list of the data names of visible properties in this project instance (hidden properties are not included).
- Return type
list(str)
- Returns
list of names of the property columns that are currently displayed in the Project Table
- getPropertyNamesForSelectedRows()¶
Return a set of data names of properties (including hidden ones) that are common to all selected entries in this project.
- Returns
List of property data names
- Return type
list of str
- property shortname¶
Get the short project name (without the path)
- property fullname¶
Get the full name of the project (including the path)
- getAdditionalDataDir(entry_id=None)¶
Get the additional data directory of the project.
- Parameters
int (str or) – Entry ID (will be converted to int)
- Raises
ValueError – entry_id is not a valid
mm.MmException – entry_id can’t be converted to entry index
- getUserDefinedASLSets()¶
Get user defined ASL sets.
- Return type
list of tuples
- Returns
List of tuples. Each tuple contains set name and ASL
- property all_rows¶
Iterator for all rows in the project using the visible project table order
- property selected_rows¶
Iterator for the selected rows using the visible project table order
- property included_rows¶
Iterator for all included rows. No specific return order for the rows.
- property groups¶
Get the entry groups in the project
- createNewGroup(title, parent_gid=None, collapsed=False)¶
Create a new group with the given title. The EntryGroup object for the new group will be returned. Group name/ID will be auto-generated.
- Parameters
title (string) – User-visible title for the new group.
parent_gid (str) – (Optional) Group ID/name of the parent group. By default the new group will be created at top level.
collapsed (bool) – Whether new group should be collapsed or not.
- Returns
New group object
- Return type
- property last_added_entry¶
Return a ProjectRow instance for the last entry added to the project
- freeCachedEntries()¶
Frees all entries that are cached.
Things like ProjectRow.getStructure(), ProjectRow.structure, ProjectRow.setStructure() will cause entries to be cached. Unless the cache is freed memory usage will grow and can become quite large (if, for example, you are iterating over and retrieving a large number of structures).
Note that on some operating systems any memory already allocated within a process is not returned to the system when it is freed. Instead it is simply marked as available to the process and only gets returned to the system when the process exits.
Given this you may not see your memory usage decrease after calling this method. However, by calling this method at carefully chosen points you can minimize your memory footprint.
If you free the cache, then the next time the above-mentioned methods/properties are invoked they will get and cache the data by fetching it from disk.
- importStructure(st, name=None, wsreplace=False, copy=True, add_group=False)¶
Create a new entry in the Project Table from structure <st> and return the ProjectRow object for the new entry.
In rare cases (when your Structure is managed by C code and use of it is no longer needed in python) using copy=False can give better performance. Doing so will make the Structure invalid for further use in your script.
- Parameters
st (
structure.Structure
) – Structure to add to the Project Table.name (str) – Entry name to give to the new entry. By default, the value of the s_m_entry_name property will be used.
wsreplace (bool) – whether to replace the Workspace with new entry. WARNING: if wsreplace is True, then any scratch entries in the Workspace will be disposed of without warning, which is not how Maestro would usually behave.
copy (bool) – If set to False, will insert the actual input CT into the PT instead of copying it first.
add_group (bool) – Whether to create new group(s) based on the s_m_subgroup_title and move the new entry to it/them.
- Return type
- Returns
Return ProjectRow object for the new entry.
- updateCrystalPropertiesIfRequired(entry_index)¶
- importStructureFile(filename, wsreplace=True, creategroups='multiple', format='any', wsinclude='', ptselect=True)¶
Imports all structures from the specified file into the Project Table. :param filename: File to import. :type filename: str
- Parameters
wsreplace (bool) – Whether to replace the Workspace with the first structure in the specified file (default True).
creategroups (str) – Which of the imported structures are to be grouped. Valid values are “multiple”, “all”, and “none”.
format (str) – Format of the file. Default is to derive from extension.
wsinclude (str) – Whether to include all entries in the workspace, or first entry or all entries. Valid values are ‘none’, ‘all’, ‘first’, or empty string (honor maestro preference).
ptselect (bool) – Whether to select imported entries or preserve originally selected entries in the PT
This method is only available when used from within Maestro.
- exportSelectedEntries(filename)¶
Export the selected entries to given file.
- Parameters
filename (str) – File to write structures to.
- getPropertyPrecision(property_name)¶
Return the precision of the property.
- Parameters
property_name (string) – is the m2io data name (the long name) of the property for which you want the precision
- Returns
precision of the property as an integer
Throws a ValueError if the property name isn’t valid.
- isColumnFixed(column)¶
Return whether the column is in fixed area of the Project Table.
- Parameters
column (int) – Project column
- Return type
bool
- Returns
Whether the column is in the fixed area.
- getFixedColumnsCount(in_subset=True)¶
Return number of columns in fixed area. This does not include always fixed columns (Row, Included, Stars, 2D Structure and Title).
- Parameters
column – Whether to return fixed columns count only for the columns in subset (True by default)
- Return type
int
- Returns
Number of columns in the fixed area.
- sortEntryGroups(sort_only_selected_groups, parent_group_id, sort_groups_using, sort_fields_list=None, sort_group_fields_list=None, is_alphanumeric_sort=True, is_ascending_sort=True)¶
Sorts the groups in project table based on the sort_groups_using which has MM_OPTION_TABLE_SORT_GROUP_OPTION values.
- Parameters
sort_only_selected_groups (bool) – if true then only groups with selection will be sorted, otherwise all groups will be sorted.
parent_group_id (str) – parent of groups to be sorted.
sort_groups_using (int) – option value of MM_OPTION_TABLE_SORT_GROUP_OPTION based on which groups will be sorted.
sort_fields_list (list of tuples) – list of tuples having property name and sort order (ASCENDING OR DESCENDING), together making sort fields of entries. e.g.[(“Entry Name”,ASCENDING),(‘Stars’,DESCENDING)]
sort_group_fields_list (list of tuples) – list of tuples having property name and sort order (ASCENDING OR DESCENDING), together making sort fields of groups. e.g.[(“Entry Name”,ASCENDING),(‘Stars’,DESCENDING)]
is_alphanumeric_sort (bool) – whether strings should be sorted by treating sequences of digits as single numbers or string values will be compared using strcmp for standard sorting.
is_ascending_sort (bool) – whether sort values in ascending or descending order.It is not required if groups are sorted based on given fields entry values as then sort fields will have their own sort order.
- sortEntries(sort_selected_entries, sort_fields_list, blank_cell_sort=BlankCellSort.BOTTOM, is_alphanumeric_sort=True)¶
Sorts HPT entries based on given table_sort_fields
- Parameters
sort_selected_entries (bool) – if true then only selected entries will be sorted,otherwise all entries will be sorted.
sort_fields_list (list of tuples) – list of tuples having property name and sort order (ASCENDING OR DESCENDING), together making sort fields of entries.e.g.[(“Entry Name”,ASCENDING),(‘Stars’,DESCENDING)]
blank_cell_sort (enum projectmodel.BlankCellSort) – value of enum projectmodel.BlankCellSort that tells how blank cells should be sorted. BlankCellSort.TOP - sort so that blank cells are at top, BlankCellSort.BOTTOM - sort such that blank cells are at bottom, BlankCellSort.LOWEST - sort as if blank cells contain lowest possible value BlankCellSort.HIGHEST - sort as if blank cells contain highest possible value.
is_alphanumeric_sort (bool) – whether strings should be sorted by treating sequences of digits as single numbers or string values will be compared using strcmp for standard sorting.
- isCurrentMaestroProject()¶
Return True if this project is the current project for this Maestro session. Returns False if running outside of Maestro.
- schrodinger.project.project.open_mmzip(prjzip, mmzip_mode, prjname=None)¶
Initializes the mmzip module and opens a file in mmzip. Checks for errors. :param prjzip: path to zipped project (or path to where the new .prjzip should go) :type prjzip: str
- Parameters
mmzip_mode – mode for mmzip (MMZIP_WRITE or MMZIP_READ)
prjname (str) – path to prj. Optional, because unzip_project does not have a path to a project yet.
- Returns
handle to mmzip proj
- schrodinger.project.project.unzip_project(prjzip, newdir=None)¶
Unzip a prjzip. newdir specifies directory into which the new project will be created. It will be created with the same name as the old project.
- Parameters
prjzip (str) – path to zipped project
newdir (str) – destination directory of new unzipped project. This does not include the name of the prjdir. If None, unzip into temporary directory under SCHRODINGER_TMP.
- Return type
str
- Returns
path of unzipped project
- schrodinger.project.project.zip_project(prjname, newdir)¶
Zip a .prj file. newdir specifies directory into which the zipped file will go. It will be created with the same name as the input project.
- Parameters
prjname (str) – path to project
newdir (str) – destination directory for zipped project.
- Returns
path of zipped project
- Return type
str
- schrodinger.project.project.open_project(projdir, widget=None, autounlock=False, askunlock=True)¶
Open a project file, unlocking it if it is locked and the users chooses to. open_project is a convenience function for constructing a Project() that provides information and options to users when projects are locked.
If projdir points to a zip archive of a project, we unzip it into a temp directory before opening it.
Note that this routine interacts with the user if the project is locked.
When closing a project that was extracted from a zip file, the project should first be closed, and then the temp directory deleted. Closing the project causes it to delete some of its own subdirectories, and this will create an error if the temp directory has already been deleted. First close the project and then use delete_temp_project_directory to do this safely.
- Parameters
projdir (str) – The path to a project
widget (QWidget or None) – The parent widget that any informational dialogs should be modal to. Use None if running without a GUI - any messages/input requests will go to the terminal. Note that using None when running under a PyQt gui will cause any questions to be asked in the terminal and “QCoreApplication::exec: The event loop is already running” to print to the terminal if the user is asked whether to unlock a file or not. The code runs correctly, however.
autounlock (bool) – If True, any project will be automatically unlocked and opened if it is locked, if False (default), the state of askunlock determines behavior.
Caution - use of autounlock=True can leave the project in an uncertain state if it is in use elsewhere, and should only be used if it is essential not to interact with the user.
- Parameters
askunlock (bool) – This parameter is overridden if autounlock is True. If askunlock is True (and autounlock is False), will ask the user if a locked project should be unlocked. If False, locked projects will not be opened.
- Return type
schrodinger.project.Project, str, str
- Returns
tuple of (project, path to project, path to temp directory). If project could not be opened, project will be None. If supplied project was a zip archive, path to temporary directory that was created to hold project.
Note that a Project object of a valid but empty project evaluates to False, so the way to check if a valid project was returned is to check:
if project is not None: pass
- schrodinger.project.project.temp_unzip_project(project_filename)¶
Yields a Project instance which is suitable for read-only modifications. This will open a Project in a temporary directory and delete the temporary directory when finished.
- Parameters
project_filename (str) – name of a prjzip file
- schrodinger.project.project.delete_temp_project_directory(projdir, tempdir, tries=10, force=False)¶
Called AFTER closing a project to safely delete the temp directory it resides in.
The project needs access to one of its subdirectories for a few ticks after it closes, so this routine waits until that directory disappears before deleting the entire directory tree. Otherwise, exceptions will result.
Note that after tries * 0.1 seconds, the routine will exit without removing the directory to avoid an infinite wait for a project that isn’t closing properly. The default yields a maximum wait of 1 second.
- Parameters
projdir (str) – path to the project directory
tempdir (str) – path to the temp directory to be removed (this is normally the parent directory of the project directory
tries (int) – The number of times to check if the project has finished closing. Once tries attempts have been made, the routine exists without removing the temp directory unless force=True
force (bool) – If True, then the directory is removed even if the project has not yet closed properly - this can lead to exceptions being printed to the terminal, though no harm is actually done. If False (defualt), then the temp directory is left intact if the project hasn’t closed after tries checks.
- schrodinger.project.project.convertToMMSortFieldsList(fields_list)¶
Convert given tuples list to MM_SortField list.
- Parameters
fields_list (list of tuples) – list of tuples having property name and sort order. e.g. [(“Entry ID”,ASCENDING),(‘Stars’,DESCENDING)]
- exception schrodinger.project.project.LockedProjectException¶
Bases:
_projectmodel.ProjectException
- exception schrodinger.project.project.InvalidProjectException¶
Bases:
_projectmodel.ProjectException
- exception schrodinger.project.project.ArchivedProjectException¶
Bases:
_projectmodel.ProjectException
- exception schrodinger.project.project.InvalidProjectVersion¶
Bases:
_projectmodel.ProjectException