def opm_mempos(opmpdbfn, geofn, ballfn): """ get membrane position from opmdb pdb file """ geodat = IO.read_geo(geofn) # an anchor residue used to find out the offset. it has no meaning base_res_id = geodat['startingSNs'][0] opmchain = IO.guess_chain(opmpdbfn, geodat) for res in opmchain: if res.get_id()[1] == base_res_id: opm_base_z = res['CA'].get_coord()[2] break my_base_z = IO.read_balls(ballfn)[0].coords[2] # offset from my ball coords to opm pdb coords my_z_offset = opm_base_z - my_base_z opm_half_thickness = abs( Bio.PDB.PDBParser().get_structure('MyStruct',opmpdbfn)[0] # structure and model .get_list()[-1].get_list()[0] # last chain and first residue .get_list()[0].get_coord()[2] ) # first atom and z coord # my extracellular membrane position my_extra_z = opm_half_thickness - my_z_offset # my periplasm membrane position my_peri_z = -opm_half_thickness - my_z_offset return my_extra_z, my_peri_z, my_z_offset