Small helper functions that don’t fit anywhere else.
Return a new name that has suffix attached; replaces other extensions.
Arguments : |
|
---|
Context manager to open a compressed (bzip2, gzip) or plain file (uses anyopen()).
Open datasource (gzipped, bzipped, uncompressed) and return a stream.
Arguments : |
|
---|
Split extension in path p at the left-most separator.
Returns True if obj can be iterated over and is not a string.
Returns obj so that it can be iterated over; a string is not treated as iterable
FORTRANReader provides a method to parse FORTRAN formatted lines in a file.
Usage:
atomformat = FORTRANReader('2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10')
for line in open('coordinates.crd'):
serial,TotRes,resName,name,x,y,z,chainID,resSeq,tempFactor = atomformat.read(line)
Fortran format edit descriptors; see Fortran Formats for the syntax.
Only simple one-character specifiers supported here: I F E A X (see FORTRAN_format_regex).
Strings are stripped of leading and trailing white space.
Set up the reader with the FORTRAN format string.
The string fmt should look like ‘2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10’.
Return how many format entries could be populated with legal values.
Parse the descriptor.
parse_FORTRAN_format(edit_descriptor) –> dict
Returns : | dict with totallength (in chars), repeat, length, format, decimals |
---|---|
Raises : | ValueError if the edit_descriptor is not recognized and cannot be parsed |
Note
Specifiers: L ES EN T TL TR / r S SP SS BN BZ are not supported, and neither are the scientific notation Ew.dEe forms.
Parse line according to the format string and return list of values.
Values are converted to Python types according to the format specifier.
Returns : | list of entries with appropriate types |
---|---|
Raises : | ValueError if any of the conversions cannot be made (e.g. space for an int) |
See also
Regular expresssion (see re) to parse a simple FORTRAN edit descriptor. (?P<repeat>\d?)(?P<format>[IFELAX])(?P<numfmt>(?P<length>\d+)(\.(?P<decimals>\d+))?)?
Return bins of width delta that cover xmin,xmax (or a larger range).
dict = fixedwidth_bins(delta,xmin,xmax)
The dict contains ‘Nbins’, ‘delta’, ‘min’, and ‘max’.
Converts between 3-letter and 1-letter amino acid codes.
Process residue string.
Argument : | The residue must contain a 1-letter or 3-letter or 4-letter residue string, a number (the resid) and optionally an atom identifier, which must be separate from the residue with a colon (”:”). White space is allowed in between. |
---|---|
Returns : | (3-letter aa string, resid, atomname); known 1-letter aa codes are converted to 3-letter codes |
Returns the unit vector normal to two vectors.
Returns the length of a vector, sqrt(v.v).
Faster than numpy.linalg.norm() because no frills.
Returns the angle between two vectors in radians
Takes the scalar triple product of three vectors.
Returns : | v3 . (v1 x v2) |
---|