io Module

IO routines, see write_anchors() and read_anchors()

class anchorna.io._AnchorJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

default(o)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
anchorna.io._json_hook(d)[source]
anchorna.io._make_rgb_transparent(rgb, bg_rgb, alpha)[source]
anchorna.io._parse_selection(anchors, selection)[source]

Parse string specifying anchors and select these

See anchorna combine -h

anchorna.io._read_anchors(fname, check_header=True)[source]

Read anchors from GFF file

Offsets are restored from comments.

anchorna.io.export_dialign(anchors, seqids, mode='aa', score_use_fluke=None)[source]

Export anchors to Dialign anchor file

anchorna.io.export_jalview(anchors, mode='aa', score_use_fluke=None)[source]

Export anchors to Jalview feature file

anchorna.io.export_locarna(anchors, mode='nt', score_use_fluke=None)[source]

Export anchors to 4 column bed files usable with mlocarna ----anchor-constraints

anchorna.io.export_stockholm(anchors, seqs, mode='nt', score_use_fluke=None, gap='-.')[source]

Export anchors to a Stockholm GC line

anchorna.io.load_json(fname)[source]

Load anchors from JSON file, experimental

anchorna.io.read_anchors(fname, check_header=True)[source]

Read anchors from GFF file

Offsets are restored from comments. Additionally, anchors can be selected and/or removed with a special syntax, see anchorna combine -h

anchorna.io.write_anchors(anchors, fname, mode=None)[source]

Write anchors to GFF file

Offsets are stored as comments.

Parameters:

mode (str) – if specified, transform indices and export to GFF file without the offsets stored as comments. The result is a file which should not be read in again with anchorna.

anchorna.io.write_json(obj, fname)[source]

Write anchors to JSON file, experimental