From 28866848dab222c0aa1552be0e36fd20a10edc89 Mon Sep 17 00:00:00 2001 From: "c.faber" <c.faber@fz-juelich.de> Date: Tue, 3 Sep 2024 10:31:46 +0200 Subject: [PATCH] add sequence position --- setup.py | 2 +- src/BioHelpers_FABER.egg-info/PKG-INFO | 2 +- src/BioHelpers_FABER/bio_mod.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4f926fb..0a6b022 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as f: setup( name="BioHelpers_FABER", - version="0.1.13", + version="0.1.14", description="Small collection of useful scripts for the computational work with RNA Data.", url="https://gitlab.jsc.fz-juelich.de/faber1/biohelpers", package_dir={"": "src"}, diff --git a/src/BioHelpers_FABER.egg-info/PKG-INFO b/src/BioHelpers_FABER.egg-info/PKG-INFO index a691826..e0314b7 100644 --- a/src/BioHelpers_FABER.egg-info/PKG-INFO +++ b/src/BioHelpers_FABER.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: BioHelpers-FABER -Version: 0.1.12 +Version: 0.1.13 Summary: Small collection of useful scripts for the computational work with RNA Data. Home-page: https://gitlab.jsc.fz-juelich.de/faber1/biohelpers Author: Christian Faber diff --git a/src/BioHelpers_FABER/bio_mod.py b/src/BioHelpers_FABER/bio_mod.py index f57e88e..9651f73 100644 --- a/src/BioHelpers_FABER/bio_mod.py +++ b/src/BioHelpers_FABER/bio_mod.py @@ -491,6 +491,32 @@ def numberOfResidues(file: str) -> int: return int(len(res)) +def get_sequence_position(filename: str) -> tuple: + """Show all the non-het Residues in a given pdb file and the associated position in the native molecule. + + :param filename: Filename of PDB + :type filename: str + :return: Tuple of list with positions and sequence as string + :rtype: tuple + """ + chain = pdb.PDBParser().get_structure("id", filename)[0].get_chains() + chain = next(chain) + residues = chain.get_residues() + r1 = next(residues) + r2 = next(residues) + numb = [r1.id[1], r2.id[1]] + sequ = [r1.get_resname(), r2.get_resname()] + for r in residues: + if r.id[0] == " ": + sequ.append(r.get_resname()) + if abs(numb[-1] - r.id[1]) > 1: + numb.append(r.id[1]) + numb.append(r.id[1]) + else: + numb[-1] = r.id[1] + return (numb, "".join(sequ)) + + if __name__ == "__main__": print("------------------") print(" gmap 1.0 - sub module ") -- GitLab