Skip to content

Instantly share code, notes, and snippets.

@lhatsk
Created February 12, 2024 10:59
Show Gist options
  • Save lhatsk/f8abc8174f9a96ccb28999e69e5556b3 to your computer and use it in GitHub Desktop.
Save lhatsk/f8abc8174f9a96ccb28999e69e5556b3 to your computer and use it in GitHub Desktop.
Updates the b-factor range of models from 0..1 to 0..100
from Bio.PDB import *
from argparse import ArgumentParser
def parse_arguments():
parser = ArgumentParser(description='Fix b-factor range for coloring')
parser.add_argument('--pdb',
help='Model file',
required=True)
parser.add_argument('--output',
help='Output',
required=True)
args = parser.parse_args()
return args
def main():
args = parse_arguments()
parser = PDBParser()
structure = parser.get_structure('X', args.pdb)[0]
for chain in structure:
for residue in chain:
for atom in residue:
atom.set_bfactor(atom.get_bfactor() * 100)
io = PDBIO()
io.set_structure(structure)
io.save(args.output)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment