Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new custom monomer #7

Open
mikelj25 opened this issue May 27, 2024 · 1 comment
Open

Add new custom monomer #7

mikelj25 opened this issue May 27, 2024 · 1 comment

Comments

@mikelj25
Copy link

Hi,

Thanks for this great library! it's extremely helpful.

I have several custom monomers that i would like to insert to the monomers bank and use them for peptide design, is there any documentation for how to address that issue?

I see that there are several files in data folder that (i guess) should be updated to include new monomers, but how exactly should i populate these files is a bit confusing for me. Especially the monomers.pdf - i understated that i need to generate sdf like data for each molecule i want to add, but the metadata with its abbreviations is not completely understood by me.

Hope it was clear enough and many thanks in advance for your help

@varontron
Copy link

I have solved this problem in two ways:

  1. replace the monomers.sdf in site-packages/pyPept/data before import
  2. load a custom monomers.sdf as a python module on-the-fly:
      import importlib.util
      with(open("/path/to/custom_monomers.sdf","r")) as f:
        monomers = f.read()
      path = pathlib.Path(tempfile.gettempdir()) / "monomers"
      os.makedirs(path, exist_ok=True)
      with open(f"{path}/__init__.py", 'w') as f:
        f.write('')
      with(open(f"{path}/monomers.sdf", 'w')) as f:
        f.write(monomers)
      spec = importlib.util.spec_from_file_location('monomers', '/tmp/monomers/__init__.py')
      mod = importlib.util.module_from_spec(spec)
      sys.modules['monomers'] = mod
      seq = Sequence(biln, path='monomers')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants