Skip to content

Instantly share code, notes, and snippets.

@neksa
Created May 30, 2018 21:39
Show Gist options
  • Save neksa/d27b36d4b62b0927448f9baa0bf2bb50 to your computer and use it in GitHub Desktop.
Save neksa/d27b36d4b62b0927448f9baa0bf2bb50 to your computer and use it in GitHub Desktop.
import zlib
from pyasn1.codec.ber import decoder
def decode_residues(res):
residues = []
try:
code, rest = decoder.decode(zlib.decompress(res, 16 + zlib.MAX_WBITS))
except:
pass
for i in range(len(code)):
c = code[i]
range_from, range_to, gi = tuple([c[j] for j in range(len(c))])
for x in range(range_from, range_to + 1):
residues.append(x)
return residues
def get_residues(obs_int_id, mol_int="mol"):
global MolResFace, IntResFace
if mol_int == "mol":
qres = db_ibis.query(MolResFace).filter(MolResFace.obs_int_id == obs_int_id).one()
else:
qres = db_ibis.query(IntResFace).filter(IntResFace.obs_int_id == obs_int_id).one()
residues = decode_residues(qres.seqloc)
return residues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment