Class utils
utility functions: modified extended string:match(); atom token,hedron and dihedron key manipulators not a class but works better with ldoc if we say it is
Functions
string:ematch (pat) | extend string.match to test and capture patterns - goes into string: namespace |
Fields
utils.warn | global flags |
Methods
utils:split_newlines (s) | split_newlines
http://lua-users.org/wiki/EnhancedFileLines
Splits string s into array of lines, returning the result. |
utils:lineByLineCompare (s1, s2) | execute line-by-line compare of 2 passed strings |
utils:genKey (atoms) | generate a string key for hedon or dihedron consisting of atom tokens separated by ':'s |
utils:splitKey (k) | split 3- (hedron) or 4- (dihedron) element string key into atom token constituents |
utils:splitAtomKey (k) | split atom token of form (sequence postion)(residue)(atom string) into constituents |
utils:addBase (base, t) | convert table of atom-name-only (from chemdata.sidechains) to atomKey |
utils:setAccuracy95 (num) | round number to value presented for %9.5lf in C |
utils:setAccuracy83 (num) | round number to value presented for %8.3lf in C |
utils:pairsByKeys (t, f) | sort table by keys, from pil 1st ed 19.3 |
utils:atomString (ndx, name, res, chain, resn, ax, ay, az, occ, tempFact) | generate a PDB ATOM record |
utils:writeFile (fname, s) | open a named file, write the passed string, close the file |
utils:getHostname () | get our hostname |
utils:orderPair (a1, a2) | sort a pair of variables |
Functions
Methods- string:ematch (pat)
-
extend string.match to test and capture patterns - goes into string: namespace
https://inspired-lua.org/index.php/2013/05/extend-string-match-to-test-and-capture-patterns/
Parameters:
- pat pattern same as for string.match()
Returns:
-
same as string.match() but sets global variables _1, _2, ... for captures on success
Fields
Methods
- utils:split_newlines (s)
-
split_newlines
http://lua-users.org/wiki/EnhancedFileLines
Splits string s into array of lines, returning the result. New-line character sequences ("\n", "\r\n", "\r"), if any, are NOT included at the ends of the lines.
Parameters:
- s string containing newline characters
Returns:
-
array of lines
- utils:lineByLineCompare (s1, s2)
-
execute line-by-line compare of 2 passed strings
Parameters:
- s1 string containing newline characters
- s2 string containing newline characters
Returns:
-
false if not perfect match, else number of lines compared
- utils:genKey (atoms)
-
generate a string key for hedon or dihedron consisting of atom tokens separated by ':'s
Parameters:
- atoms ... tokens of the form (sequence postion)(residue)(atom string) e.g. 224PCB = C-beta of Proline at sequence position 224
Returns:
-
string key e.g. 1MN:1MCA:1MC:2QN
- utils:splitKey (k)
-
split 3- (hedron) or 4- (dihedron) element string key into atom token constituents
Parameters:
- k string key to split
Returns:
-
table of sequential fields
- utils:splitAtomKey (k)
-
split atom token of form (sequence postion)(residue)(atom string) into constituents
Parameters:
- k atom token key to split
Returns:
-
table of constituents in order [1] sequence postion [2] residue [3] atom
- utils:addBase (base, t)
-
convert table of atom-name-only (from chemdata.sidechains) to atomKey
Parameters:
- base
- t table of atom names in ipairs from chemdata.sidechains e.g. { 'CA', 'CB', 'CG1' }
Returns:
-
new table with atomKeys
- base
- utils:setAccuracy95 (num)
-
round number to value presented for %9.5lf in C
Parameters:
- num the initial value
Returns:
-
the value rounded to 5 decimal places
- utils:setAccuracy83 (num)
-
round number to value presented for %8.3lf in C
Parameters:
- num the initial value
Returns:
-
the value rounded to 3 decimal places
- utils:pairsByKeys (t, f)
-
sort table by keys, from pil 1st ed 19.3
Parameters:
- t table of key, value pairs
- f optional comparison function
Returns:
-
iterator for use as 'for name, line in pairsByKeys(lines) do'
- utils:atomString (ndx, name, res, chain, resn, ax, ay, az, occ, tempFact)
-
generate a PDB ATOM record
Parameters:
- ndx index of record
- name atom NAME (CA)
- res 1-letter residue code
- chain chain ID
- resn residue number
- ax atom X coordinate
- ay atom Y coordinate
- az atom Z coordinate
- occ occupancy
- tempFact temperature factor (B factor)
Returns:
-
string with text and newline for one ATOM record
- utils:writeFile (fname, s)
-
open a named file, write the passed string, close the file
Parameters:
- fname name of file to open
- s string to write
- utils:getHostname ()
-
get our hostname
Returns:
-
string with hostname
- utils:orderPair (a1, a2)
-
sort a pair of variables
Parameters:
- a1 first thing
- a2 second thing
Returns:
-
table with [1] and [2] set to a1/a2 according to lua table.sort()