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__(key, /)

Return key in self.

__len__()

Return len(self).

count(value, /)

Return number of occurrences of value.

default

Alias for field number 1

index(value, start=0, stop=9223372036854775807, /)

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__(key, /)

Return key in self.

__len__()

Return len(self).

count(value, /)

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)[source]

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_or_velocity_prop(prop)[source]

Parse a property name and return the information from it if it is a VOTCA mobility or velocity 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 or velocity property.

schrodinger.application.matsci.kmc.parse_field_prop(prop)[source]

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)[source]

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[source]

Bases: object

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

__init__()[source]

Create an AxisData object

setComponent(axis, value)[source]

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)[source]

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)[source]

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

class schrodinger.application.matsci.kmc.Table(filename)[source]

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)[source]

Create a Table instance

Parameters

filename (str) – The path to the SQL file

setCursor(cursor)[source]

Set the SQL cursor this table should use

Parameters

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

create()[source]

Create this table in the database

Raises

SQLCreationError – If the cursor is not defined

getMoleculeInfo(molecule, centroid=True)[source]

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

static getSegmentType(molecule)[source]

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

static getAllSegmentTypes(struct)[source]

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

class schrodinger.application.matsci.kmc.FramesTable(filename)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

Add a row to the table

Parameters
classmethod setRowProperty(mols, prop, value, cursor)[source]

Set the value of a property in the row for the given pair of molecules

Parameters
  • mols (iterable) – The two mol numbers involved in this pair

  • prop (str) – The name of property column to set

  • value (any) – The value to set for the property

  • cursor (sqlite3.Cursor) – The cursor to use

Raises

RuntimeError – If value has spaces

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

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)[source]

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

static getAllSegmentTypes(struct)

Get all the segment types for this structure

Parameters

struct (structure.Structure) – The structure object

Return type

set

Returns

Each item of the set is the name of a segment type

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

static getSegmentType(molecule)

Get the segment type for this molecule

Segment names will be type_X, where X is the molecule number

Parameters

molecule (structure._Molecule) – The molecule object

Return type

str

Returns

The segment type for this molecule

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)[source]

Bases: object

Manage initialization and filling of SQL database tables

class Cursor(manager)[source]

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)[source]

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)[source]

Create a DatabaseManager instance

Parameters
initializeDatabase()[source]

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

fillAtoms()[source]

Fill the atoms table

fillFragments()[source]

Fill the fragments table

fillFrames()[source]

Fill the frames table

fillMolecules()[source]

Fill the molecules table

fillSegmentTypes()[source]

Fill the segmentTypes table

fillSegments()[source]

Fill the segments table

Raises

RuntimeError – If fillSegmentTypes has not been called yet

fillSchrodinger()[source]

Fill the schrodinger table

fillPairs(dist, pair_type='heavy')[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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')[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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

exception schrodinger.application.matsci.kmc.SQLCreationError[source]

Bases: Exception

Raised if an issue occurs when creating the database

__init__(*args, **kwargs)

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)[source]

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