From 4efd19deda74b6a1b66bd0ca52dbf59b848cfd33 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Wed, 28 Aug 2024 15:01:44 -0500 Subject: [PATCH] Also support mmCIF with `getchain` (#27) --- Project.toml | 2 +- src/utils.jl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 5a5e5bd..c1911cb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GPCRAnalysis" uuid = "c1d73f9e-d42a-418a-8d5b-c7b00ec0358f" authors = ["Tim Holy and contributors"] -version = "0.5.0" +version = "0.5.1" [deps] BioStructures = "de9282ab-8554-53be-b2d6-f6c222edabfc" diff --git a/src/utils.jl b/src/utils.jl index c99df90..2820b5a 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -40,9 +40,12 @@ end """ getchain(filename::AbstractString; model=1, chain="A") -Read a PDB file `filename` and extract the specified chain. +Read a PDB or mmCIF file `filename` and extract the specified chain. """ -getchain(filename::AbstractString; model=1, chain="A") = read(filename, PDBFormat)[model][chain] +getchain(filename::AbstractString; model=1, chain="A") = + endswith(filename, ".pdb") ? read(filename, PDBFormat)[model][chain] : + endswith(filename, ".cif") ? read(filename, MMCIFFormat)[model][chain] : + throw(ArgumentError("Unknown file format")) function validate_seq_residues(seq::AnnotatedAlignedSequence, chain) for (i, r) in zip(getsequencemapping(seq), seq)