Documentation

Calculating invariants of conjoined structures

topoly.getpoly(invariant, topolname, value=None)[source]

Generates list of objects which have polynomial value corresponding to given invariant type and topolname. These objects can be multiplied (*) to find polynomial of joined structures and added (+) to find polynomial of unjoined union.

Parameters:
  • invariant (str) – Name of invariant (or its abbreviation): ‘Alexander’ (‘a’), ‘Conway’ (‘c’), ‘Jones’ (‘j’), ‘HOMFLYPT’ (‘h’), ‘Yamada’ (‘y’), ‘BLMHo’ (‘b’), ‘Kauffman bracket’ (‘kb’), ‘Kauffman polynomial’ (‘kp’),

  • topolname (str) – Topology name i.e. “3_1”, “-5_1”, “t3_1”

  • value (str, optional) – Polynomial of given topolname structure. If nothing is given searches for linkname value in polvalues.py. Default: None.

Returns:

List of Polynomial objects.

topoly.exportpoly(polynomials, exportfile='new_polvalues.py')[source]

Sends list of Polynomial objects generated by getpoly to chosen exportfile, that can be used as an alternative dictionary.

Parameters:
  • polynomials (list of Poly objects) – List of objects generated by getpoly.

  • exportfile (str, optional) – Name of file where polynomial records will be written. Default: ‘new_polvalues.py’.

Lasso type indentification (minimal surface calculation)

topoly.lasso_type(structure, loop_indices=None, smooth=0, precision=0, density=1, min_dist=(10, 3, 3), pic_files=0, output_prefix='', more_info=False, pdb_chain=None, pdb_model=None, pdb_bridges='ssbond', bridges=[], breaks=[])[source]

Calculates minimal surfaces spanned on given loops and checks if remaining parts of chains cross surfaces and how many times. Returns corresponding topoly types of lassos (type for each loop).

Parameters:
  • structure – (str/list): The structure containing the loop which may be pierced by the tail, given in coordinates, or the path to the file containing the data.

  • loop_indices (list, optional) – the indices of all loops within the structure (list of pairs). If they are not specified, SS-bonds defining loops are automatically found in input data (if the file is in PDB or CIF format). Default: None

  • smooth (int, optional) – Number of smoothing iterations. Higher number – structure will be more smooth. Default: 0.

  • precision (int, optional) – Precision of computations of minimal surface. Viable options are the parameters of the PrecisionSurface class. Default: PrecisionSurface.HIGH.

  • density (int, optional) – Density of the triangulation of minimal surface. Viable options are the parameters of the DensitySurface class. Default: DensitySurface.MEDIUM

  • min_dist ([int, int, int], optional) – Minimal distance (number of atoms/amino acids etc.) between, respectively, next two crossings, crossing and bridge defining loop and crossing and end of tail – to think about these crossings as deep enough ones and do NOT reduce them. Default: [10,3,3]

  • pic_files (int/list of ints, optional) – Output file format for generated pictures with surface and crossings. Possible formats: * VMD – SurfacePlotFormat.VMD or 1, * JSmol – SurfacePlotFormat.JSMOL or 2, * Mathematica – SurfacePlotFormat.MATHEMATICA or 4. Input as one of these or any combination of these as a list. Default: SurfacePlotFormat.DONTPLOT

  • output_prefix (str, optional) – Prefix of desired output file. Default: No prefix.

  • more_info (bool, optional) – If True, more info is returned. Look down below in “return”. Default: False

  • pdb_chain (string, optional) – If inputting .pdb file, which chain should be used. If none, the first chain is taken into account. Default: None.

  • pdb_model (string, optional) – If inputting .pdb file, which model should be used. If none, the first model is taken into account. Default: None.

  • pdb_bridges (string, optional) – Useful only for topoly.yamada_ and topoly.aps_ and when inputing .pdb file. Determines which bridges should be used during topoly analysis: ‘ssbond’ – disulfide bonds, ‘ion’ – ionic bridges, ‘covalent’ – other covalent (non-disulfide) bridges, ‘all’ – covalent (disulfide and non-disulfide) and ionic bridges. Default: ‘ssbond’.

  • bridges (list, optional) – The list of tuples denoting the bridging residues in the main chain. Default: [].

  • breaks (list, optional) – The list of breaks of the main chain. Default: [].

Returns:

Dictionary with loops indices as keys and string report with lasso type as values. If more_info=True more info is produced: IDs of atoms that cross the surface (“crossingsN/C”); IDs of atoms that cross he surface before the procedure of crossing reduction (“beforeN/C”); radius of gyration (“Rg”); number of iterations of structure smoothing procedure (“smoothing_iterations”).

topoly.make_surface(structure, loop_indices=None, precision=0, density=1, precision_output=3, pdb_chain=None, pdb_model=None, pdb_bridges='ssbond', bridges=[], breaks=[])[source]

Calculates minimal surface spanned on a given loop.

Parameters:
  • structure (str/list) – The structure containing loop to calculate the surface spanned on, given in coordinates, or the path to the file containing the data.

  • loop_indices (list, optional) – The indices of loop within the structure. If they are not specified the whole structure is used as loop. Default: None.

  • precision (int, optional) – Precision of computations of minimal surface. Viable options are the parameters of the PrecisionSurface class. Default: PrecisionSurface.HIGH.

  • density (int, optional) – Density of the triangulation of minimal surface. Viable options are the parameters of the DensitySurface class. Default: DensitySurface.MEDIUM.

  • precision_output (int, optional) – Precision of output, number of decimal places in returned values. Default: 3

  • pdb_chain (string, optional) – If inputting .pdb file, which chain should be used. If none, the first chain is taken into account. Default: None.

  • pdb_model (string, optional) – If inputting .pdb file, which model should be used. If none, the first model is taken into account. Default: None.

  • pdb_bridges (string, optional) – Useful only for topoly.yamada_ and topoly.aps_ and when inputting .pdb file. Determines which bridges should be used during topoly analysis: ‘ssbond’ – disulfide bonds, ‘ion’ – ionic bridges, ‘covalent’ – other covalent (non-disulfide) bridges, ‘all’ – covalent (disulfide and non-disulfide) and ionic bridges. Default: ‘ssbond’.

  • bridges (list, optional) – The list of tuples denoting the bridging residues in the main chain. Default: [].

  • breaks (list, optional) – The list of breaks of the main chain. Default: [].

Returns:

List of triangles that form minimal surface.

Finding loops, theta-curves and handcuffs in structure

topoly.find_loops(structure, output_type='pdcode', pdb_chain=None, pdb_model=None, breaks=[], bridges=[], pdb_bridges='ssbond', arc_bridges=1, output='list', file_prefix='loop', folder_prefix='')[source]

Finds all loops in a given structure and return as one of many possible formats.

Parameters:
  • structure (str/list) – The structure to find the links in, given in abstract code, coordinates, or the path to the file containing the data.

  • output_type (str/list, optional) – The output format of the loops. The viable formats are parameters of the OutputType class. Default: OutputType.PDcode.

  • pdb_chain (str, optional) – The chain identifier in the PDB file. If none, the first chain is taken into account. Default: None.

  • pdb_model (int, optional) – The model identifier in the PDB file. If none, the first model is taken into account. Default: None.

  • breaks (list, optional) – The list of breaks of the main chain. Default: []

  • bridges (list, optional) – Default: []. The list of tuples denoting the bridging residues in the main chain. Default: [].

  • pdb_bridges (string, optional) – Useful only for topoly.yamada_ and topoly.aps_ and when inputting .pdb file. Determines which bridges should be used during topoly analysis: ‘ssbond’ – disulfide bonds, ‘ion’ – ionic bridges, ‘covalent’ – other covalent (non-disulfide) bridges, ‘all’ – covalent (disulfide and non-disulfide) and ionic bridges. Default: ‘ssbond’.

  • arc_bridges (int, optional) – Number of bridges which can be included in a given loop. For 0 no restriction is made. Default: 1.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’. Default: ‘list’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “loop”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

Returns:

List/generator/files with the loops found represented in a chosen format.

topoly.find_thetas(structure, output_type='pdcode', pdb_chain=None, pdb_model=None, breaks=[], bridges=[], pdb_bridges='ssbond', arc_bridges=1, output='list', file_prefix='theta', folder_prefix='')[source]

Finds all theta-curves in a given structure and return as one of many possible formats.

Parameters:
  • structure (str/list) – The structure to find the theta-curves in, given in abstract code, coordinates, or the path to the file containing the data.

  • output_type (str/list, optional) – The output format of the loops. The viable formats are parameters of the OutputType class. Default: OutputType.PDcode.

  • pdb_chain (str, optional) – The chain identifier in the PDB file. If none, the first chain is taken into account. Default: None.

  • pdb_model (int, optional) – The model identifier in the PDB file. If none, the first model is taken into account. Default: None.

  • breaks (list, optional) – The list of breaks of the main chain. Default: [].

  • bridges (list, optional) – The list of tuples denoting the bridging residues in the main chain. Default: [].

  • pdb_bridges (string, optional) – Useful only for topoly.yamada_ and topoly.aps_ and when inputting .pdb file. Determines which bridges should be used during topoly analysis: ‘ssbond’ – disulfide bonds, ‘ion’ – ionic bridges, ‘covalent’ – other covalent (non-disulfide) bridges, ‘all’ – covalent (disulfide and non-disulfide) and ionic bridges. Default: ‘ssbond’.

  • arc_bridges (int, optional) – Number of bridges which can be included in each arc. For 0 no restriction is made. Default: 1.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’. Default: ‘list’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “theta”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

Returns:

List/generator/files with the theta-curves found represented in a chosen format.

topoly.find_handcuffs(structure, output_type='pdcode', pdb_chain=None, pdb_model=None, breaks=[], bridges=[], pdb_bridges='ssbond', arc_bridges=1, output='list', file_prefix='handcuff', folder_prefix='')[source]

Finds all handcuff graphs in a given structure and return as one of many possible formats.

Parameters:
  • structure (str/list) – The structure to find the handcuff graphs in, given in abstract code, coordinates, or the path to the file containing the data.

  • output_type (str/list, optional) – The output format of the loops. The viable formats are parameters of the OutputType class. Default: OutputType.PDcode.

  • pdb_chain (str, optional) – The chain identifier in the PDB file. If none, the first chain is taken into account. Default: None.

  • pdb_model (int, optional) – The model identifier in the PDB file. If none, the first model is taken into account. Default: None.

  • breaks (list, optional) – The list of breaks of the main chain. Default: [].

  • bridges (list, optional) – The list of tuples denoting the bridging residues in the main chain. Default: [].

  • pdb_bridges (string, optional) – Useful only for topoly.yamada_ and topoly.aps_ and when inputting .pdb file. Determines which bridges should be used during topoly analysis: ‘ssbond’ – disulfide bonds, ‘ion’ – ionic bridges, ‘covalent’ – other covalent (non-disulfide) bridges, ‘all’ – covalent (disulfide and non-disulfide) and ionic bridges. Default: ‘ssbond’.

  • arc_bridges (int, optional) – Number of bridges which can be included in each arc. For 0 no restriction is made. Default: 1.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’. Default: ‘list’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “handcuff”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

Returns:

List/generator/files with the handcuff graphs found represented in a chosen format.

Random polygons generation

topoly.generate_walk(length, no_of_structures, bond_length=1, print_with_index=True, output='file', file_prefix='walk', folder_prefix='', file_fmt=(3, 5))[source]

Generates polygonal lasso structure with vertices of equal lengths and saves in .xyz file. Each structures is saved in distinct file named <file_prefix>_<num>.xyz in folder l<looplength>_t<taillength>.

Parameters:
  • length (int) – Number of sides of polygonal random walk.

  • no_of_structures (int) – Quantity of created walks.

  • bond_length (int, optional) – Length of each side of created walks. Default: 1.

  • print_with_index (bool, optional) – If True, then output has also node index. Default: True.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “walk”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

  • file_fmt ([int,int], optional) – Only if output==’file’. Numbers on file and folder format <num>, <length> are padded with maximally these numbers of zeros respectively.

Returns:

If output=’file’ – information with folder name. If output=’list’ – list of structures, each structure is coordinate list of lists. If output=’generator’ – generator yielding structure which is coordinate list of lists.

topoly.generate_loop(length, no_of_structures, bond_length=1, print_with_index=True, output='file', file_prefix='loop', folder_prefix='', file_fmt=(3, 5))[source]

Generates polygonal loop structure with vertices of equal lengths and saves in .xyz file. Each structures is saved in distinct file named <file_prefix>_<num>.xyz in folder w<length>.

Parameters:
  • length (int) – Number of sides of polygonal loops.

  • no_of_structures (int) – Quantity of created loops.

  • bond_length (int, optional) – Length of each side of created loops. Default: 1.

  • print_with_index (bool, optional) – If True, then created .xyz has nxyz format instead of xyz, where n is index number. Default: True.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “loop”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

  • file_fmt ([int,int], optional) – Only if output==’file’. Numbers on file and folder format <num>, <looplength> are padded with maximally these numbers of zeros respectively.

Returns:

If output=’file’ – information with folder name. If output=’list’ – list of structures, each structure is coordinate list of lists. If output=’generator’ – generator yielding structure which is coordinate list of lists.

topoly.generate_lasso(looplength, taillength, no_of_structures, bond_length=1, output='file', print_with_index=True, file_prefix='lasso', folder_prefix='', file_fmt=(3, 3, 5))[source]

Generates polygonal lasso structure with vertices of equal lengths and saves in .xyz file. Each structures is saved in distinct file named <file_prefix>_<num>.xyz in folder l<looplength>_t<taillength>.

Parameters:
  • looplength (int) – Number of sides of polygonal loop.

  • taillength (int) – Number of sides of polygonal tail.

  • no_of_structures (int) – Quantity of created loops.

  • bond_length (int, optional) – Length of each side of created lassos. Default: 1.

  • print_with_index (bool, optional) – If True, then created .xyz has nxyz format instead of xyz, where n is index number. Default: True.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “lasso”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

  • file_fmt ([int,int,int], optional) – Only if output==’file’. Numbers on file and folder format <num>, <looplength>, <taillength> are padded with maximally these numbers of zeros respectively.

Returns:

If output=’file’ – information with folder name. If output=’list’ – list of structures, each structure is coordinate list of lists. If output=’generator’ – generator yielding structure which is coordinate list of lists.

topoly.generate_handcuff(looplengths, linkerlength, no_of_structures, bond_length=1, output='file', print_with_index=True, file_prefix='hdcf', folder_prefix='', file_fmt=(3, 3, 3, 5))[source]

Generates polygonal lasso structure with vertices of equal lengths and saves in .xyz file. Each structures is saved in distinct file named <file_prefix>_<num>.xyz in folder l<looplength1>_<looplength2>_t<linkerlength>.

Parameters:
  • looplengths ([int,int]) – Number of sides of polygonal loops.

  • linkerlength (int) – Number of sides of polygonal linker.

  • no_of_structures (int) – Quantity of created loops.

  • bond_length (int, optional) – Length of each side of created lassos. Default: 1.

  • print_with_index (bool, optional) – If True, then created .xyz has nxyz format instead of xyz, where n is index number. Default: True.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “hdcf”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

  • file_fmt ([int,int,int,int], optional) – Only if output==’file’. Numbers on file and folder format <num>, <looplength1>, <looplength2>, <linkerlength> are padded with maximally these numbers of zeros respectively.

Returns:

If output=’file’ – information with folder name. If output=’list’ – list of structures, each structure is coordinate list of lists. If output=’generator’ – generator yielding structure which is coordinate list of lists.

topoly.generate_theta(arc_lengths, no_of_structures, bond_length=1, output='file', print_with_index=True, file_prefix='theta', folder_prefix='', file_fmt=(3, 5))[source]

Generates polygonal N-theta-curve (composed of N arcs) structure with vertices of equal lengths and saves in .xyz file. Each structures is saved in distinct file named <file_prefix>_<num>.xyz in folder t<arclength1>_<arclength2>_…_<arclengthN>_

Parameters:
  • arc_lengths ([int,int,...,int]) – Number of sides of polygonal arcs.

  • no_of_structures (int) – Quantity of created loops.

  • bond_length (int, optional) – Length of each side of created lassos. Default: 1.

  • print_with_index (bool, optional) – If True, then created .xyz has nxyz format instead of xyz, where n is index number. Default: True.

  • output (str, optional) – Format of output data ‘file’, ‘list’ or ‘generator’.

  • file_prefix (str, optional) – Only if output==’file’. Prefix of each created file. Default: “theta”.

  • folder_prefix (str, optional) – Only if output==’file’. Prefix of created file folder. Default: no prefix.

  • file_fmt ([int,int], optional) – Only if output==’file’. Numbers on file and folder format <num>, <arclength> are padded with maximally these numbers of zeros.

Returns:

If output=’file’ – information with folder name. If output=’list’ – list of structures, each structure is coordinate list of lists. If output=’generator’ – generator yielding structure which is coordinate list of lists.

Knot map manipulating functions

topoly.plot_matrix(matrix, map_filename='KnotFingerPrintMap', map_fileformat='png', map_cutoff=0.48, map_palette={'3_1': 'Greens', '4_1': 'Oranges', '5_1': 'Reds', '5_2': 'Purples', '6_1': 'Blues', '8_20|3_1#3_1': 'Reds', 'name': 'knot'}, map_arrows=True, debug=False)[source]

Plotting the figure for a given fingerprint matrix.

Parameters:
  • matrix (str) – The matrix with information about the topology of each subchain of the structure. Can be given either in dictionary, or KnotProt format. The matrix can be given directly, or as a path to the file. The file may also be gzipped (i.e. txt.gz)

  • map_filename (str, optional) – The name of the output file with the matrix figure. Default: KnotFingerPrintMap.

  • map_fileformat (str, optional) – The format of the output matrix figure. Viable options are the parameters of the PlotFormat class. Default: PlotFormat.PNG.

  • map_cutoff (float, optional) – The cutoff of the non-trivial structure probability. All structures with probability below the cutoff will be regarded as trivial, and therefore not marked in the figure. Default: 0.48.

  • map_palette (str, optional) – The palette of colors for matrix plot. Viable options are parameters of the Palette class. Default: Palette.KNOT.

  • map_arrows (bool, optional) – If the arrows are to be plotted. Default: True

  • debug (bool, optional) – The debug mode.

Returns:

Communicate about the figure creation.

topoly.find_spots(matrix, gap_size=0, spot_size=20, map_cutoff=0.48)[source]

Finds centers of fields in the matrix.

Parameters:
  • matrix (str/dict) – The matrix fingerprint of the structure.

  • gap_size (int, optional) – The size of the trivial fragment allowed between two parts to classify them as single spot. If 0, only the connected fragments are considered as spots. Default: 0.

  • spot_size (int, optional) – The minimal size of the spot. Fragments with less non-trivial repentants will be suppressed. Default: 20.

  • map_cutoff (float, optional) – The cutoff of the non-trivial structure probability. All structures with probability below the cutoff will be regarded as trivial, and therefore not marked in the figure. Default: 0.48.

Returns:

The list of the centers of the spots.

topoly.translate_matrix(matrix, output_format='dict', knot='', beg=0, end=0)[source]

Translates between various formats of the matrix (KnotProt-like <-> dictionary <-> list of lists).

Parameters:
  • matrix (str/dict) – The matrix fingerprint of the structure, or the path to the file with the matrix. The file may also be gzipped (i.e. txt.gz)

  • output_format (string, optional) – The format of the output matrix. The viable options are the paramters of the OutputFormat class. Default: OutputFormat.Dictionary

  • knot (string, optional) – The knot name in case the input is matrix (list of lists). Default: ‘’.

  • beg (int, optional) – The first index of the chain, needed if the input is matrix (list of lists). Default: 0

  • end (int, optional) – The last index of the chain, needed if the input is matrix (list of lists) or KnotProt string output. Default: 0

Returns:

The matrix in desired format (string, dictionary or list of lists).

Visualization

topoly.xyz2vmd(xyz_file)[source]

Converts .xyz file into .pdb file and creates .psf topoly file with same name. Then you can open your structure in vmd typing “vmd file.pdb -psf file.psf”.

.xyz file format: 4 columns (id, x, y, z), atoms in neighboring rows are treated as bonded, lines with single letter (e.g. X) separate different arcs.

Parameters:

xyz_file (str) – Name of xyz file.

Returns:

None

topoly.plot_graph(structure, palette={'all': 'hsv', 'name': 'structure'})[source]

Plotting the 3D rotable presentation of the structure with each arc colored differently.

Parameters:
  • structure (str/list) – The structure or the path to the file containing the data to plot.

  • palette (str, optional) – The palette of colors for matrix plot. Viable options are parameters of the Palette class. Default: Palette.RAINBOW.

Returns:

Communicate about the figure creation.

Data manipulation

topoly.translate_code(structure, output_type='pdcode', pdb_chain=None, pdb_model=None)[source]

Translates between the representations of structure. In particular, can print the abstract codes of a structure specified by coordinates, or translate between the abstract codes.

Parameters:
  • structure (str/list) – The structure to print the data.

  • output_type (str, optional) – The output format. The viable formats are parameters of the OutputType class. Default: OutputType.PDcode.

  • pdb_chain (string, optional) – If inputting .pdb file, which chain should be used. If none, the first chain is taken into account. Default: None.

  • pdb_model (int, optional) – The model identifier in the PDB file. If none, the first model is taken into account. Default: None.

Returns:

The structure in a given format.

topoly.find_matching(data, invariant, chiral=False, minimal=True, external_dictionary='')[source]

Finds the matching structure for a given polynomial. Searches either the built-in, or user-defined dictionary.

Parameters:
  • data (string/dictionary) – The polynomial given either in string of coefficients (e.g. ‘1 -1 1’), the dictionary of polynomials with their probabilities (e.g. {‘1 -1 1’: 0.8, ‘1 -3 1’: 0.2}, or dictionary of probabilities for each subchain (e.g. {(0, 100): {‘1 -1 1’: 0.8, ‘1 -3 1’: 0.2}, (50, 100): {‘1 -1 1’: 0.3, ‘1’: 0.7}}).

  • invariant (string) – The name of the invariant, e.g. ‘Alexander’, of ‘Jones’.

  • chiral (bool, optional) – If the chirality should be taken into account. By default False.

  • external_dictionary (string, optional) – The absolute path to the user-defined dictionary of polynomials. The dictionary must be compliant with the template which can be obtained on the Topoly website (https://topoly.cent.uw.edu.pl).

Returns:

Either the string with matching structure name (e.g. ‘3_1’), or the dictionary with the structure name and respective probability (e.g. {‘3_1’: 0.8, ‘4_1’: 0.2}), or the dictionary with data for each subchain, e.g. {(0, 100): {‘3_1’: 0.8, ‘4_1’: 0.2}, (50, 100): {‘3_1’: 0.3, ‘0_1’: 0.7}}.

topoly.import_structure(structure_name)[source]

Finds a PDcode of the structure required.

Parameters:

structure_name (str) – The name of the structure to create.

Returns:

The graph of the corresponding structure defined by the PDcode.

topoly.reduce_structure(structure, steps=1000, reduce_method=1, output_type='xyz', debug=False, closed=True)[source]

Reducing the structure to a form with less crossing in a planar projection.

Parameters:
  • structure (str/list) – The structure to calculate the polynomial for, given in abstract code, coordinates, or the path to the file containing the data.

  • steps (int, optional) – Number of reduction steps. Default: 1000.

  • reduce_method (str, optional) – The method used to reduce the structure. Viable methods are the parameters of the ReduceMethod class. Default: ReduceMethod.KMT.

  • output_type (str, optional) – The format of the reduced chain. The abstract codes are possible only for closed structure. Default: OutputType.XYZ.

  • debug (bool, optional) – The debug mode. Default: False.

Returns:

The abstract code or the coordinates of the reduced structure.

topoly.close_curve(structure, closure=2, output_type='xyz', debug=False)[source]

Closing the structure (connecting loose ends) with a chosen method.

Parameters:
  • structure (str/list) – The structure to calculate the polynomial for, given in abstract code, coordinates, or the path to the file containing the data.

  • closure (str, optional) – The method used to close the structure. Viable methods are the parameters of the Closure class. Default: Closure.TWO_POINTS.

  • output_type (str, optional) – The format of the closed chain. Default: OutputType.XYZ.

  • debug (bool, optional) – The debug mode. Default: False.

Returns:

The abstract code or the coordinates of the closed structure.

Parameters for various functions (topoly.params)

class topoly.params.Closure[source]

Type of closure for invariant calculating functions.

CLOSED = 0

(Deterministic) direct segment between two endpoints.

MASS_CENTER = 1

(Deterministic) segments added to two endpoints in the direction “going out of center of mass”, and then connected by an arc on the big sphere.

TWO_POINTS = 2

(Random) each endpoint connected with different random point on the big sphere, and those added points connected by an arc on the big sphere.

ONE_POINT = 3

(Random) both endpoints connected with the same random point on the big sphere.

RAYS = 4

(Random) parallel segments added to two endpoints, and then connected by an arc on the big sphere; direction of added segments is random.

DIRECTION = 5

(Deterministic) the same as RAYS but the direction can be given.

class topoly.params.ReduceMethod[source]

Reduction method for invariant calculating functions.

NO = 0

Without reduction.

KMT = 1

KMT algorithm [ Koniaris K, Muthukumar M (1991) Self-entanglement in ring polymers, J. Chem. Phys. 95, 2873–2881 ]. This algorithm analyzes all triangles in a chain made by three consecutive amino acids, and removes the middle amino acid in case a given triangle is not intersected by any other segment of the chain. In effect, after a number of iterations, the initial chain is replaced by (much) shorter chain of the same topological type.

REIDEMEISTER = 2

Simplification of chain (and number of crossings) by a sequence of Reidemeister moves.

EASY = 3

The deterministic version of Reidemeister simplification, using only the 1st and 2nd move.

class topoly.params.SurfacePlotFormat[source]

The output formats for minimal surface plotting.

DONTPLOT = 0

Without plotting.

VMD = 1

Plot files to visualisation in VMD.

JSMOL = 2

Plot files to visualisation in JSMOL.

MATHEMATICA = 4

Plot files to visualisation in Mathematica.

class topoly.params.PlotFormat[source]

The output format for images.

PNG = 'png'

.png file – lossless compression, raster.

SVG = 'svg'

.svg – lossless, vector.

PDF = 'pdf'

.pdf – portable document format.

class topoly.params.OutputFormat[source]

The output formats for matrices.

KnotProt = 'knotprot'

The matrix in the format used in KnotProt.

Dictionary = 'dict'

The dictionary-like output.

Matrix = 'matrix'

The matrix-like (list of lists) output

Ccode = 'Ccode'

The output suitable for passing to C-coded parts of the package.

class topoly.params.PrecisionSurface[source]

Precision of computations of minimal surface spanned on the loop (high precision => time consuming computations).

HIGH = 0

High precision level. Default.

MEDIUM = 1

Medium precision level, may be used when analyzing large structures, trajectories or other big sets of data.

LOW = 2

Lowest precision level, may be used when analyzing large structures, trajectories or other big sets of data.

class topoly.params.DensitySurface[source]

Density of the triangulation of minimal surface spanned on the loop (high density => time consuming computations). Default value: MEDIUM.

HIGH = 2

The highest density.

MEDIUM = 1

Medium precision level. Default.

LOW = 0

Lowest precision level, may be used when analyzing large structures, trajectories or other big sets of data.

class topoly.params.Bridges[source]

The bridges types to be parsed from PDB file.

SSBOND = 'ssbond'

Disulfide bonds.

ION = 'ion'

Ionic bridges.

COVALENT = 'covalent'

Other covalent (non-disulfide) bridges.

ALL = 'all'

Covalent (disulfide and non-disulfide) and ionic bridges.

class topoly.params.OutputType[source]

The possible output types for find_loops, find_thetas, etc.

PDcode = 'pdcode'

PDcode format

EMcode = 'emcode'

EMcode format

XYZ = 'xyz'

.xyz file format (only coordinates)

NXYZ = 'nxyz'

.xyz file format (indexes and coordinates)

PDB = 'pdb'

PDB file format

Mathematica = 'math'

Mathematica list format

MMCIF = 'mmcif'

mmcif structure format

PSF = 'psf'

psf topology file format

IDENT = 'ident'

indices of first and last atom of each arc of the structure

ATOMS = 'atoms'
class topoly.params.Colors[source]

Colors for drawing figures.

Knots = {'3_1': 'Greens', '4_1': 'Oranges', '5_1': 'Reds', '5_2': 'Purples', '6_1': 'Blues', '8_20|3_1#3_1': 'Reds', 'name': 'knot'}

Default knot fields colors in knot map

GLN = {'': 'seismic', 'name': 'GLN'}

Default colormap for GLN maps

Structure = {'all': 'hsv', 'name': 'structure'}

Default colormap for structure plotting using plot_graph