schrodinger.application.matsci.kmc module

Utilities for working with VOTCA

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.kmc.ColumnData(type, default)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

count(value) → integer -- return number of occurrences of value
default

Alias for field number 1

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

type

Alias for field number 0

class schrodinger.application.matsci.kmc.MoleculeData(index, name, mtype, posx, posy, posz)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

count(value) → integer -- return number of occurrences of value
index

Alias for field number 0

mtype

Alias for field number 2

name

Alias for field number 1

posx

Alias for field number 3

posy

Alias for field number 4

posz

Alias for field number 5

schrodinger.application.matsci.kmc.is_votca_prop(prop)

Check if a property is a votca property

Parameters:prop (str) – The property to check
Return type:str or None
Returns:If the property is a votca property, the type of property is returned as a module-level constant. If the property is not recognized as a VOTCA property, None is returned.
schrodinger.application.matsci.kmc.parse_mobility_prop(prop)

Parse a property name and return the information from it if it is a VOTCA mobility property

Parameters:prop (str) – The property to check
Return type:(int, str, str) or None
Returns:The integer is the field index, the first string is the charge (HOLE or ELECTRON) and the second string is the axis name. None is returned if the property is not a mobility property.
schrodinger.application.matsci.kmc.parse_field_prop(prop)

Parse a property name and return the information from it if it is a VOTCA field property

Parameters:prop (str) – The property to check
Return type:(int, str) or None
Returns:The integer is the field index, the string is the axis name. None is returned if the property is not a field property.
schrodinger.application.matsci.kmc.parse_database_prop(prop)

Parse a property name and return the information from it if it is a VOTCA database property

Parameters:prop (str) – The property to check
Return type:(int, str) or None
Returns:The integer is the field index, the string is the charge (HOLE or ELECTRON). None is returned if the property is not a database property.
class schrodinger.application.matsci.kmc.AxisData

Bases: object

Holds data that differs on the X, Y and Z axes

__init__()

Create an AxisData object

setComponent(axis, value)

Set the data for one axis

Parameters:axis (str or int) – Either the capital name of an axis (X, Y, Z) or the numerical index of that axis
class schrodinger.application.matsci.kmc.SQLCursor(path)

Bases: object

Context manager for reading or modifying an SQL database. Ensures that changes are commited and the cursor/connection are closed when finished.

cmd = “black SQL magic” with SQLCursor(path_to_sql_file) as cursor:

cursor.execute(cmd)
__init__(path)

Initialize self. See help(type(self)) for accurate signature.

class schrodinger.application.matsci.kmc.Table(filename)

Bases: object

Base table class for VOTCA SQL tables

TABLE_NAME = ''
COLUMNS = {}
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
SQL_ID = '_id'
SQID = 'id'
FRAME = 'frame'
TOP = 'top'
NAME = 'name'
TYPE = 'type'
MOL = 'mol'
SEG = 'seg'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

class schrodinger.application.matsci.kmc.FramesTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The frames table

TABLE_NAME = 'frames'
TIME = 'time'
STEP = 'step'
BOX11 = 'box11'
BOX12 = 'box12'
BOX13 = 'box13'
BOX21 = 'box21'
BOX22 = 'box22'
BOX23 = 'box23'
BOX31 = 'box31'
BOX32 = 'box32'
BOX33 = 'box33'
CANRIGID = 'canRigid'
COLUMNS = {'box11': ColumnData(type='REAL', default=None), 'box12': ColumnData(type='REAL', default=None), 'box13': ColumnData(type='REAL', default=None), 'box21': ColumnData(type='REAL', default=None), 'box22': ColumnData(type='REAL', default=None), 'box23': ColumnData(type='REAL', default=None), 'box31': ColumnData(type='REAL', default=None), 'box32': ColumnData(type='REAL', default=None), 'box33': ColumnData(type='REAL', default=None), 'canRigid': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=0), 'step': ColumnData(type='INT', default=0), 'time': ColumnData(type='REAL', default=0)}
addRow(struct)

Add a frame row to the table

The main frame information is the PBC box

Parameters:struct (schrodinger.structure.Structure) – The structure with the PBC information
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.MoleculesTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The molecules table

TABLE_NAME = 'molecules'
COLUMNS = {'frame': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=None), 'name': ColumnData(type='TEXT', default=None), 'top': ColumnData(type='INT', default=0), 'type': ColumnData(type='TEXT', default=None)}
addRow(molecule)

Add a row

Parameters:molecule (schrodinger.structure._StructureMolecule) – The molecule object to add a row for
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.SegmentsTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The segments table

TABLE_NAME = 'segments'
UNCNNE = 'UnCnNe'
UNCNNH = 'UnCnNh'
UCNCCE = 'UcNcCe'
UCNCCH = 'UcNcCh'
UCCNNE = 'UcCnNe'
UCCNNH = 'UcCnNh'
EANION = 'eAnion'
ENEUTRAL = 'eNeutral'
ECATION = 'eCation'
HAS_E = 'has_e'
HAS_H = 'has_h'
OCCPE = 'occPe'
OCCPH = 'occPh'
COLUMNS = {'UcCnNe': ColumnData(type='REAL', default=0), 'UcCnNh': ColumnData(type='REAL', default=0), 'UcNcCe': ColumnData(type='REAL', default=0), 'UcNcCh': ColumnData(type='REAL', default=0), 'UnCnNe': ColumnData(type='REAL', default=0), 'UnCnNh': ColumnData(type='REAL', default=0), 'eAnion': ColumnData(type='REAL', default=0), 'eCation': ColumnData(type='REAL', default=0), 'eNeutral': ColumnData(type='REAL', default=0), 'frame': ColumnData(type='INT', default=0), 'has_e': ColumnData(type='INT', default=0), 'has_h': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=None), 'mol': ColumnData(type='INT', default=None), 'name': ColumnData(type='TEXT', default=None), 'occPe': ColumnData(type='REAL', default=-1), 'occPh': ColumnData(type='REAL', default=-1), 'posX': ColumnData(type='REAL', default=None), 'posY': ColumnData(type='REAL', default=None), 'posZ': ColumnData(type='REAL', default=None), 'top': ColumnData(type='INT', default=0), 'type': ColumnData(type='TEXT', default=None)}
SITE_ENERGY_PROPS = {'electron': ['UcCnNe', 'UnCnNe', 'UcNcCe'], 'hole': ['UcCnNh', 'UnCnNh', 'UcNcCh']}
addRow(molecule, stypes)

Add a row

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to add a row for
  • stypes (dict) – Kyes are segment names (atom pdbres names), values are the index of that segment
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.SegmentTypesTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The segmentTypes table

TABLE_NAME = 'segmentTypes'
BASIS = 'basis'
ORBFILE = 'orbfile'
TORBNRS = 'torbnrs'
COORDFILE = 'coordfile'
CANRIGID = 'canRigid'
COLUMNS = {'basis': ColumnData(type='TEXT', default='noname'), 'canRigid': ColumnData(type='INT', default=0), 'coordfile': ColumnData(type='TEXT', default='nofile'), 'frame': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=None), 'name': ColumnData(type='TEXT', default=None), 'orbfile': ColumnData(type='TEXT', default='nofile'), 'top': ColumnData(type='INT', default=0), 'torbnrs': ColumnData(type='TEXT', default='NOT_USED')}
addRow(stype, index)

Add a row

Parameters:
  • stype (str) – The segment type name (should be an atom.pdbres name)
  • index (int) – The segment type index
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.FragmentsTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The fragments table

TABLE_NAME = 'fragments'
SYMMETRY = 'symmetry'
LEG1 = 'leg1'
LEG2 = 'leg2'
LEG3 = 'leg3'
COLUMNS = {'frame': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=None), 'leg1': ColumnData(type='INT', default=1), 'leg2': ColumnData(type='INT', default=2), 'leg3': ColumnData(type='INT', default=3), 'mol': ColumnData(type='INT', default=None), 'name': ColumnData(type='TEXT', default=None), 'posX': ColumnData(type='REAL', default=None), 'posY': ColumnData(type='REAL', default=None), 'posZ': ColumnData(type='REAL', default=None), 'seg': ColumnData(type='INT', default=None), 'symmetry': ColumnData(type='INT', default=-1), 'top': ColumnData(type='INT', default=0), 'type': ColumnData(type='TEXT', default=None)}
addRow(molecule)

Add a row

Parameters:molecule (schrodinger.structure._StructureMolecule) – The molecule object to add a row for
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.AtomsTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The atoms table

TABLE_NAME = 'atoms'
FRAG = 'frag'
RESNR = 'resnr'
RESNAME = 'resname'
WEIGHT = 'weight'
ELEMENT = 'element'
QMID = 'qmid'
QMPOSX = 'qmPosX'
QMPOSY = 'qmPosY'
QMPOSZ = 'qmPosZ'
COLUMNS = {'element': ColumnData(type='TEXT', default=None), 'frag': ColumnData(type='INT', default=None), 'frame': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=None), 'mol': ColumnData(type='INT', default=None), 'name': ColumnData(type='TEXT', default=None), 'posX': ColumnData(type='REAL', default=None), 'posY': ColumnData(type='REAL', default=None), 'posZ': ColumnData(type='REAL', default=None), 'qmPosX': ColumnData(type='REAL', default=0.0), 'qmPosY': ColumnData(type='REAL', default=0.0), 'qmPosZ': ColumnData(type='REAL', default=0.0), 'qmid': ColumnData(type='INT', default=0), 'resname': ColumnData(type='TEXT', default=None), 'resnr': ColumnData(type='INT', default=1), 'seg': ColumnData(type='INT', default=None), 'top': ColumnData(type='INT', default=0), 'type': ColumnData(type='INT', default=None), 'weight': ColumnData(type='REAL', default=None)}
addRow(atom)

Add a row

Parameters:atom (structure.Structure._StructureAtom) – The atom to add a row for
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.PairsTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The pairs table

TABLE_NAME = 'pairs'
SEG1 = 'seg1'
SEG2 = 'seg2'
DRX = 'drx'
DRY = 'dry'
DRZ = 'drz'
LOE = 'lOe'
LOH = 'lOh'
HAS_E = 'has_e'
HAS_H = 'has_h'
RATE12E = 'rate12e'
RATE21E = 'rate21e'
RATE12H = 'rate12h'
RATE21H = 'rate21h'
JEFF2E = 'Jeff2e'
JEFF2H = 'Jeff2h'
COLUMNS = {'Jeff2e': ColumnData(type='REAL', default=0), 'Jeff2h': ColumnData(type='REAL', default=0), 'drx': ColumnData(type='REAL', default=None), 'dry': ColumnData(type='REAL', default=None), 'drz': ColumnData(type='REAL', default=None), 'frame': ColumnData(type='INT', default=0), 'has_e': ColumnData(type='INT', default=0), 'has_h': ColumnData(type='INT', default=0), 'id': ColumnData(type='INT', default=None), 'lOe': ColumnData(type='REAL', default=0), 'lOh': ColumnData(type='REAL', default=0), 'rate12e': ColumnData(type='REAL', default=0), 'rate12h': ColumnData(type='REAL', default=0), 'rate21e': ColumnData(type='REAL', default=0), 'rate21h': ColumnData(type='REAL', default=0), 'seg1': ColumnData(type='INT', default=None), 'seg2': ColumnData(type='INT', default=None), 'top': ColumnData(type='INT', default=0), 'type': ColumnData(type='INT', default=0)}
addRow(index, dimer)

Add a row to the table

Parameters:
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.SuperExchangeTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The superExchange table

Note: unused

TABLE_NAME = 'superExchange'
COLUMNS = {'frame': ColumnData(type='INT', default=0), 'top': ColumnData(type='INT', default=0), 'type': ColumnData(type='TEXT', default=None)}
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.SchrodingerTable(filename)

Bases: schrodinger.application.matsci.kmc.Table

The schrodinger table. This contains Schrodinger-specific information and is not used by VOTCA

TABLE_NAME = 'schrodinger'
MOLFORM = 'mol_formula'
VOLUME = 'pbc_volume_Ang3'
JOBID = 'jobid'
STRUCTURE_PATH = 'structure_path'
STRUCTURE_FILE = 'structure_file'
PAIR_DISTANCE = 'pair_distance_Ang'
PAIR_TYPE = 'pair_type'
VERSION = 'version'
JUMPFILE = 'jumpfile'
JUMPSUMMARY = 'jumpsummary'
RUNTIME = 'runtime'
SEED = 'seed'
FIELDX = 'fieldX'
FIELDY = 'fieldY'
FIELDZ = 'fieldZ'
TEMPERATURE = 'temperature'
RATEFILE = 'ratefile'
CARRIERTYPE = 'carriertype'
SITE_KEYWORDS = 'site_keywords'
FIX_SITE_KEYWORDS = 'site_fix_keywords'
COLUMNS = {'carriertype': ColumnData(type='TEXT', default='none'), 'fieldX': ColumnData(type='REAL', default='none'), 'fieldY': ColumnData(type='REAL', default='none'), 'fieldZ': ColumnData(type='REAL', default='none'), 'jobid': ColumnData(type='TEXT', default='none'), 'jumpsummary': ColumnData(type='TEXT', default='none'), 'mol_formula': ColumnData(type='TEXT', default='none'), 'pair_distance_Ang': ColumnData(type='REAL', default=0.0), 'pair_type': ColumnData(type='REAL', default='none'), 'pbc_volume_Ang3': ColumnData(type='REAL', default=0.0), 'ratefile': ColumnData(type='TEXT', default='none'), 'runtime': ColumnData(type='REAL', default='none'), 'seed': ColumnData(type='INT', default='none'), 'site_fix_keywords': ColumnData(type='TEXT', default='none'), 'site_keywords': ColumnData(type='TEXT', default='none'), 'structure_file': ColumnData(type='TEXT', default='none'), 'structure_path': ColumnData(type='TEXT', default='none'), 'temperature': ColumnData(type='REAL', default='none'), 'version': ColumnData(type='REAL', default=0.92)}
addRow(struct)

Add a row

Parameters:struct (schrodinger.structure.Structure) – The structure for the database
ADDROW_COMMAND = 'INSERT INTO {name} ({cols}) VALUES ({ph})'
CREATION_COMMAND = 'CREATE TABLE {name} ({columns});'
FRAME = 'frame'
MOL = 'mol'
NAME = 'name'
POSX = 'posX'
POSY = 'posY'
POSZ = 'posZ'
SEG = 'seg'
SQID = 'id'
SQL_ID = '_id'
TOP = 'top'
TYPE = 'type'
__init__(filename)

Create a Table instance

Parameters:filename (str) – The path to the SQL file
create()

Create this table in the database

Raises:SQLCreationError – If the cursor is not defined
getMoleculeInfo(molecule, centroid=True)

Get common database information for a molecule object

Parameters:
  • molecule (schrodinger.structure._StructureMolecule) – The molecule object to get information for
  • centroid (bool) – Include information about the molecule’s centroid. If False, all centroid information will be 0.
Return type:

MoleculeData

Returns:

A MoleculeData object containing the information

setCursor(cursor)

Set the SQL cursor this table should use

Parameters:cursor (sqlite3.Cursor) – The cursor to use for database read/writes
class schrodinger.application.matsci.kmc.DatabaseManager(struct, filename)

Bases: object

Manage initialization and filling of SQL database tables

class Cursor(manager)

Bases: schrodinger.application.matsci.kmc.SQLCursor

Context manager for obtaining a cursor object for use by the tables. Note that when adding many rows it saves a huge amount of time to create the cursor once and then close it when finished rather than create/close a cursor for each row.

__init__(manager)

Initialize self. See help(type(self)) for accurate signature.

TABLE_CLASSES = (<class 'schrodinger.application.matsci.kmc.FramesTable'>, <class 'schrodinger.application.matsci.kmc.PairsTable'>, <class 'schrodinger.application.matsci.kmc.MoleculesTable'>, <class 'schrodinger.application.matsci.kmc.SegmentsTable'>, <class 'schrodinger.application.matsci.kmc.FragmentsTable'>, <class 'schrodinger.application.matsci.kmc.AtomsTable'>, <class 'schrodinger.application.matsci.kmc.SegmentTypesTable'>, <class 'schrodinger.application.matsci.kmc.SchrodingerTable'>, <class 'schrodinger.application.matsci.kmc.SuperExchangeTable'>)
__init__(struct, filename)

Create a DatabaseManager instance

Parameters:
  • struct (schrodinger.structure.Structure) – The structure to find dimers in
  • filename (str) – The name of the SQL file to create
initializeDatabase()

Create all the tables and fill all but the pairs table with initial data

fillAtoms()

Fill the atoms table

fillFragments()

Fill the fragments table

fillFrames()

Fill the frames table

fillMolecules()

Fill the molecules table

fillSegmentTypes()

Fill the segmentTypes table

fillSegments()

Fill the segments table

Raises:RuntimeError – If fillSegmentTypes has not been called yet
fillSchrodinger()

Fill the schrodinger table

fillPairs(dist, pair_type='heavy')

Find all dimers in the given structure based on the normal Schrodinger dimer finding algorithm. Add all found dimers to the given VOTCA SQL file.

Parameters:
  • dist (float) – The distance threshold for defining dimers
  • pair_type (str) – Either SQL_HEAVY (heavy atom distances only) or SQL_ALL (all atoms are considered when determining pair distance)
Return type:

int

Returns:

The number of dimers found

schrodinger.application.matsci.kmc.sql_command(cursor, cmd)

Perform the given command without closing the cursor or saving the results to the database

Parameters:
  • cursor (sqlite3.Cursor) – The cursor used
  • cmd (str) – The SQL command to perform
Return type:

bool

Returns:

True if the command executed, False if the command raised a no such table error

Raises:

sqlite3.OperationalError – in unknown circumstances

schrodinger.application.matsci.kmc.table_rows(db_path, table, orderby=None)

Generator for all the rows in a specific table of the database

Parameters:
  • db_path (str or pathlib.Path) – The path to the database
  • table (str) – The name of the table to get the rows for
Return type:

sqlite3.Row

Returns:

Yields each row in the table

schrodinger.application.matsci.kmc.delete_all_rows(db_path, table)

Delete all the rows in this table

Parameters:
  • db_path (str or pathlib.Path) – The path to the database
  • table (str) – The name of the table to get the rows for
schrodinger.application.matsci.kmc.is_no_table_error(exc)

Detect if this exception is due to the requested table not existing

Parameters:exc (Exception) – The Exception to check
Return type:bool
Returns:Whether this exception is for a missing table
schrodinger.application.matsci.kmc.add_schrodinger_column(db_path, name)

Add a column to the schrodinger table. This may be needed if the SQL file was created with an older version that didn’t include this column

Parameters:
  • db_path (str or pathlib.Path) – The path to the SQL file
  • name (str) – The name of the column, must be a key in SchrodingerTable.COLUMNS
schrodinger.application.matsci.kmc.set_schrodinger_db_value(db_path, name, value)

Set the value of the given column in the Schrodinger table.

Parameters:
  • db_path (str or pathlib.Path) – The path to the SQL file
  • name (str) – The name of the column, must be a key in SchrodingerTable.COLUMNS
  • value – The value to put into the database. The type of the parameter should be consistent with the expected type for that column.
schrodinger.application.matsci.kmc.store_schrodinger_job_props(db_path, mae_name, struct)

Store Schrodinger information about the current job in the database

Parameters:
  • db_path (str or pathlib.Path) – The path to the SQL file
  • mae_name (str) – The name of the Maestro file that will hold the structure
  • struct (schrodinger.structure.Structure) – The structure to add corresponding job info props to
schrodinger.application.matsci.kmc.get_schrodinger_db_value(db_path, name)

Get the value for the given column from the Schrodinger table in the database

Parameters:
  • db_path (str or pathlib.Path) – The path to the SQL file
  • name (str) – The name of the column to get the data from
Return type:

variable or None

Returns:

The value for the given column in the Schrodinger table, or None if no such table exists or no such column exists

schrodinger.application.matsci.kmc.get_db_structure_path(db_path, existence_check=True)

Get the path to the structure that created this database

Parameters:
  • db_path (str or pathlib.Path) – The path to the SQL file
  • existence_check (bool) – If True, return None if the path in the database does not point to an existing file. If False, return the path regardless of whether the file exists.
Return type:

pathlib.Path or None

Returns:

The Path to the structure file, or None if no path is found in the database or existence_check=True and the file does not exist

schrodinger.application.matsci.kmc.add_pairs_to_database(struct, path, dist, pair_type='heavy')

Find all dimers in the given structure based on the normal Schrodinger dimer finding algorithm. Add all found dimers to the given VOTCA SQL file.

Parameters:
  • struct (schrodinger.structure.Structure) – The structure with the pairs
  • path (str) – The path to the SQL database
  • dist (float) – The distance threshold for defining dimers
  • pair_type (str) – Either SQL_HEAVY (heavy atom distances only) or SQL_ALL (all atoms are considered when determining pair distance)
Return type:

int

Returns:

The number of dimers found

schrodinger.application.matsci.kmc.get_pairs_from_database(db_path)

Get the pairs from the database

Parameters:db_path (str or pathlib.Path) – The path to the SQL file
Return type:list
Returns:Each item of the list is a schrodinger.application.matsci.clusterstruct.Dimer object. The list is empty if the pairs table has not been populated. Note that the Dimer objects will not have set the home_atom or neighbor_atom properties of the neighbor_info property.
schrodinger.application.matsci.kmc.has_pair_data(db_path)

Check if the database has pair data

Parameters:db_path (str or pathlib.Path) – The path to the database
Return type:bool or str
Returns:If no data, False. If data, the distance type used to find pairs - either SQL_HEAVY or SQL_ALL
schrodinger.application.matsci.kmc.get_pair_info(db_path)

Get the parameters used to determine the existing pairs in the database

Parameters:db_path (str or pathlib.Path) – The path to the database
Return type:(str, float) or None
Returns:The type of distance used to find pairs (SQL_HEAVY or SQL_ALL) and the distance cutoff for pairs. None is returned if no pair data exists.
schrodinger.application.matsci.kmc.find_missing_coupling_data(path, charge)

Find any pair coupings that are 0

Parameters:
  • path (str) – The path to the database file
  • charge (str) – Either HOLE or ELECTRON
Return type:

list

Returns:

Each item is a tuple with the molecule numbers of the two molecules involved in the missing coupling term.

schrodinger.application.matsci.kmc.find_missing_site_energies(path, charge)

Find any segment that has any site energy property equal to 0

Parameters:
  • path (str) – The path to the database file
  • charge (str) – Either HOLE or ELECTRON
Return type:

list

Returns:

Each item is the integer SQID (which translates to molecule number) of any segment with missing site energy information

schrodinger.application.matsci.kmc.copy_sql_data(source, destination, table, columns)

Copy the column from table in the source database to the destination database

Parameters:
  • source (str or pathlib.path) – the path to the source database
  • destination (str or pathlib.path) – the path to the destination database
  • table (str) – The name of the table to copy from
  • columns (list) – A list of column names to copy
Raises:

IndexError – If the two databases do not have the same number of rows

class schrodinger.application.matsci.kmc.CouplingData(struct, splitting=False, charge=None)

Bases: object

Stores coupling results for a single structure

SQL_TO_PROP = {'Jeff2': 'r_matsci_Charge_Transfer_Coupling'}
__init__(struct, splitting=False, charge=None)

Create a CouplingData instance

Parameters:
  • struct (schrodinger.structure.Structure) – The structure with the coupling data properties
  • splitting (bool) – True if the data comes from from a frontier orbital splitting calculation, False if not
  • charge (str) – Should be either the ELECTRON or HOLE constant. Indicates the charge this data is for. If not given, charge information is taken from the coupling type structure property.
class schrodinger.application.matsci.kmc.CouplingDataHandler(charge)

Bases: object

Does data handling for all coupling results for one type of charge

FORBACK = ('12', '21')
AVERAGED = ('Jeff2',)
__init__(charge)

Create a CouplingDataHandler instance

Parameters:charge (str) – What type of charge this instance will manage coupling data for. Should be HOLE or ELECTRON
addData(coupling_data)

Add a CouplingData object to this handler

Parameters:coupling_data (CouplingData) – The data object to add
validateData(expected_pairs, logfn=None, splitting=False)

Validate that the current coupling data looks valid

Parameters:
  • expected_pairs (int) – How many pairs we should have data for.
  • logfn (callable) – If supplied and a problem occurs, the problem will be logged to via this function. If not supplied, and IndexError will be raised.
  • splitting (bool) – True if the coupling is via orbital splitting, False if it is from full Wavefunction calculations
Raises:

IndexError – If the data is invalid and logfn is not provided

insertDataIntoDatabase(cursor)

Insert the managed data into the database

Parameters:cursor (sqlite3.Cursor) – The cursor to use to write to the database
exception schrodinger.application.matsci.kmc.SQLCreationError

Bases: Exception

Raised if an issue occurs when creating the database

__init__

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

schrodinger.application.matsci.kmc.generate_votca_database(struct, backend=None)

Create a VOTCA SQL database and include data on species and pairs

Note that VOTCA requires the segments in a system be ordered such that all segments of the same type appear together in order. This function returns the reordered structure used to create the database. (segments=molecules)

Parameters:
  • struct (schrodinger.structure.Structure) – The structure to create a database for
  • backend (scschrodigner.job.jobcontrol._Backend) – The backend if one exists
Return type:

str

Returns:

The name of the sql file that was created

Raises:

SQLCreationError – If the sql file can’t be created