Skip to content

Enable reading from a tar file #2

@pwrose

Description

@pwrose

AlphaFold db bundles files as tar files.

Rather than un-taring the files and then parsing the cif.gz files, specific files could be read directly from the tar file, e,g.,

filename = "AF-O52908-F1-model_v2.cif.gz"

with tarfile.open("UP000000799_192222_CAMJE_v2.tar") as tf:
    with gzip.open(tf.extractfile(filename), mode="rt") as gf:
        gf.readlines()

With some modifications to CifReader, it should be possible to do this:

with tarfile.open("UP000000799_192222_CAMJE_v2.tar") as tf:
    cfr = CifFileReader()
    file_obj = tf.extractfile(filename)
    cif_obj = cfr.read(file_obj, output='cif_dictionary')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions