pidibble.baseparsers module¶
- class pidibble.baseparsers.ListParser(d=',')[source]¶
Bases:
objectA simple parser for lists of strings, with a customizable delimiter.
- class pidibble.baseparsers.NonconformanceRegistry[source]¶
Bases:
objectAccumulates types of PDB-format nonconformance encountered during a parse, rather than every individual instance.
Real-world PDB files routinely deviate from the fixed-column standard (for example, a charge column that holds
O-instead of a bare number). A single file can contain tens of thousands of instances of the same deviation, so logging each one is useless noise. This registry collapses them by type, keyed by(record_key, field, kind)— e.g.("ATOM", "charge", "not coercible to Float")— keeping a running count and one exemplar (the offending value and its byte range) per type so the end-of-parse summary can point at something concrete.- add(record_key, nc)[source]¶
Record one nonconformance instance under its type signature.
- Parameters:
record_key (str) – The record type the instance was found in (e.g.
ATOM).nc (dict) – A nonconformance descriptor as produced by
StringParser, with keysfield,kind,byte_range, andvalue.
- report(log, label='')[source]¶
Emit one INFO line per nonconformance type to the given logger.
- Parameters:
log (logging.Logger) – The logger to emit the summary to.
label (str, optional) – A label for the source being parsed (e.g. the PDB id), included in the summary header.
- class pidibble.baseparsers.StringParser(fmtdict, typemap, allowed={})[source]¶
Bases:
objectA parser for fixed-width strings, with a customizable field map.
- Parameters:
- report_field_error(record, k)[source]¶
Report an error in parsing a specific field from a fixed-width string record.
- pidibble.baseparsers.list_parse(obj, d)[source]¶
A factory function to create a ListParser with a specific delimiter.