Please modify the following function code (saveBfactor) in the MD Analysis workflow to solve this issue:
def saveBfactor(input, output, bfactors):
# load input into BioPython structure
structure = PDBParser(QUIET=True).get_structure('structure', input)
# add B-factor to each structure atoms
i = 0
resold = ""
for atom in structure.get_atoms():
res = atom.get_parent().get_id()[1]
if (res != resold):
i=i+1
bf = [d for d in bfactors if d['residue'] == i][0]['bfactor']
atom.set_bfactor(bf)
resold = res
Please modify the following function code (saveBfactor) in the MD Analysis workflow to solve this issue: