Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable reading from a tar file #2

Open
pwrose opened this issue Jun 3, 2022 · 0 comments
Open

Enable reading from a tar file #2

pwrose opened this issue Jun 3, 2022 · 0 comments

Comments

@pwrose
Copy link

pwrose commented Jun 3, 2022

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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant