{"id":22384809,"url":"https://github.com/pgarrett-scripps/peptacular","last_synced_at":"2025-07-31T04:32:48.763Z","repository":{"id":143189254,"uuid":"591504879","full_name":"pgarrett-scripps/peptacular","owner":"pgarrett-scripps","description":"A spectacularly simple package for working with peptide sequences.","archived":false,"fork":false,"pushed_at":"2024-06-03T19:48:13.000Z","size":11840,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-10T19:56:44.336Z","etag":null,"topics":["bioinformatics","mass-spectrometry","peptide-identification","peptide-sequences","peptides","protein","proteomics","python"],"latest_commit_sha":null,"homepage":"https://peptacular.readthedocs.io/en/latest/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgarrett-scripps.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-01-20T23:21:53.000Z","updated_at":"2024-10-03T19:36:32.000Z","dependencies_parsed_at":"2023-12-06T01:25:38.050Z","dependency_job_id":"9610ecea-8288-440f-aa0f-4ef6c7142091","html_url":"https://github.com/pgarrett-scripps/peptacular","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgarrett-scripps%2Fpeptacular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgarrett-scripps%2Fpeptacular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgarrett-scripps%2Fpeptacular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgarrett-scripps%2Fpeptacular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgarrett-scripps","download_url":"https://codeload.github.com/pgarrett-scripps/peptacular/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228215605,"owners_count":17886430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bioinformatics","mass-spectrometry","peptide-identification","peptide-sequences","peptides","protein","proteomics","python"],"created_at":"2024-12-05T01:19:20.290Z","updated_at":"2024-12-05T01:19:21.326Z","avatar_url":"https://github.com/pgarrett-scripps.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Peptacular\n\nA spectacularly simple package for working with peptide sequences. Now proforma2.0 compliant.\n\n# Warnings\n\n- The internal fragment ion mass calculation may not be accurate. Fairly certain that the ay, by, and cy internal fragments are \ncorrect since the y fragment is really just a smaller parent ion.\n- GNO and RESID mods are disabled for now. I will add them back in later.\n- Project is still under development. I will be adding more features and fixing bugs as I find them.\n\n## ReadTheDocs\nhttps://peptacular.readthedocs.io/en/latest/index.html\n\n## Installation\n\n```bash\npip install peptacular\n```\n\n### Proforma Notation:\n- https://pubs.acs.org/doi/suppl/10.1021/acs.jproteome.1c00771/suppl_file/pr1c00771_si_001.pdf\n\n### Modification Types:\n- Modifications can be represented as str, int, or float.\n- During parsing, the module automatically identifies the modification type based on its representation.\n\n## Ion Types:\n - Terminal: a, b, c, x, y, z\n - Internal: ax, ay, az, bx, by, bz, cx, cy, cz\n - Immonium: i\n - special: p, n (precursor, none)\n\n## Working with Sequences\n```python\nimport peptacular as pt\n\n# Add mods to sequence\nsequence = pt.add_mods('P[1.2345]EPTIDE', {5: 1, 'cterm': 'Amide'})\nassert sequence == 'P[1.2345]EPTID[1]E-[Amide]'\n\n# Get mods: mods are returned as a list of Mod objects Mod(value, multiplier)\nmods = pt.get_mods(sequence)\nassert mods == {'cterm': [pt.Mod('Amide', 1)], 0: [pt.Mod(1.2345, 1)], 5: [pt.Mod(1, 1)]}\n\n# Strip mods\nstripped_sequence = pt.strip_mods(sequence)\nassert stripped_sequence == 'PEPTIDE'\n\n# Pop mods\nstripped_sequence, mods = pt.pop_mods(sequence)\nassert stripped_sequence == 'PEPTIDE'\nassert mods == {'cterm': [pt.Mod('Amide', 1)], 0: [pt.Mod(1.2345, 1)], 5: [pt.Mod(1, 1)]}\n\n# Reverse sequence\nreverse_sequence = pt.reverse(sequence, swap_terms=False)\nassert reverse_sequence == 'ED[1]ITPEP[1.2345]-[Amide]'\n```\n\n## Calculating mass and m/z\n\n```python\nimport peptacular as pt\n\n# Calculate mass (monoisotopic)\npeptide_mass = pt.mass('PEP[1.0]TIDE-[2.0]', charge=2, precision=3)\nassert peptide_mass == 804.375\n\n# Calculate m/z (monoisotopic)\npeptide_mz = pt.mz('PEP[1.0]TIDE-[2.0]', charge=2, precision=3)\nassert peptide_mz == 402.187\n\n# Calculate m/z (average)\npeptide_mz = pt.mz('PEP[1.0]TIDE-[2.0]', charge=2, monoisotopic=False, precision=3)\nassert peptide_mz == 402.419\n\n# For a given ion type\npeptide_mz = pt.mz('PEP[1.0]TIDE-[2.0]', ion_type='y', charge=2, precision=3)\nassert peptide_mz == 402.419\n```\n\n## Building Fragment Ions\n\n```python\nimport peptacular as pt\n\n# Calculate the m/z values for the y+ fragments.\npt.fragment('P[1.0]TIDE-[2.0]', ion_types='y', charges=1, monoisotopic=True)\n\n# Or for multiple ion types and charges.\npt.fragment('P[1.0]EP', ion_types=['y', 'b'], charges=[1, 2], monoisotopic=True)\n\n# Or for internal ions\npt.fragment('P[1.0]EP', ion_types='by', charges=[1, 2], monoisotopic=True)\n\n# Immonium ions\npt.fragment('P[1.0]EP', ion_types='i', charges=1, monoisotopic=True)\n\n# Can also return M/Z values rather than Fragment objects\npt.fragment('P[1.0]EP', ion_types='y', charges=1, monoisotopic=True, return_type='mz')\n```\n\n## Digesting Sequences\n```python\nimport peptacular as pt\n\n# Can use enzyme name from Constants.PROTEASES\npeptides = pt.digest('TIDERTIDEKT[1]IDE-[2]', enzyme_regex='trypsin/P', missed_cleavages=2)\nassert set(peptides) == {'TIDER', 'TIDERTIDEK', 'TIDERTIDEKT[1]IDE-[2]', 'TIDEK',\n                    'TIDEKT[1]IDE-[2]', 'T[1]IDE-[2]'}\n\n# or use a custom regex\npeptides = pt.digest('TIDERTIDEKT[1]IDE-[2]', enzyme_regex='([KR])', missed_cleavages=2)\nassert set(peptides) == {'TIDER', 'TIDERTIDEK', 'TIDERTIDEKT[1]IDE-[2]', 'TIDEK',\n                    'TIDEKT[1]IDE-[2]', 'T[1]IDE-[2]'}\n\n# Also supports semi-enzymatic digestion (might want to use min/max len to filter)\npeptides = pt.digest('TIDERTIDEKT[1]IDE-[2]', enzyme_regex='trypsin/P', missed_cleavages=2,\n                  semi=True, min_len=10)\nassert set(peptides) == {'TIDERTIDEK', 'TIDERTIDEKT[1]IDE-[2]', 'TIDERTIDEKT[1]ID', 'TIDERTIDEKT[1]I',\n                    'TIDERTIDEKT[1]', 'IDERTIDEKT[1]IDE-[2]', 'DERTIDEKT[1]IDE-[2]',\n                    'ERTIDEKT[1]IDE-[2]', 'RTIDEKT[1]IDE-[2]'}\n```\n\n## Static and Variable Modifications\n\n```python\nimport peptacular as pt\n\n# Apply static modifications\npeptide = pt.apply_static_mods('PEPTIDE-[2]', {'P': ['phospho'], '(?\u003c=P)E': [1]})\nassert peptide == 'P[phospho]E[1]P[phospho]TIDE-[2]'\n\n# Apply variable modifications\npeptides = pt.apply_variable_mods('PEPTIDE-[2]', {'P': [['phospho']], '(?\u003c=P)E': [[1]]}, max_mods=2)\nprint(peptides)\nassert peptides == ['P[phospho]E[1]PTIDE-[2]', 'P[phospho]EP[phospho]TIDE-[2]', 'P[phospho]EPTIDE-[2]',\n                    'PE[1]P[phospho]TIDE-[2]', 'PE[1]PTIDE-[2]', 'PEP[phospho]TIDE-[2]', 'PEPTIDE-[2]']\n\n```\n\n## Isotopic Distribution\n```python\nimport peptacular as pt\n\n# 1) Get the isotopic distribution for a chemical composition:\nformula = {'C': 12, 'H': 6, 'N': 3}\nisotopes = pt.isotopic_distribution(chemical_formula=formula, max_isotopes=3)\nassert isotopes == [(192.05617, 1.0), (193.05321, 0.010959894014211729), (193.05952, 0.1297887395127868)]\n\n# 2) Get the isotopic distribution for a peptide sequence:\nsequence = 'PEPTIDE'\ncomposition = pt.comp(sequence)\nisotopes = pt.isotopic_distribution(chemical_formula=composition, max_isotopes=3)\nassert isotopes ==  [(799.35997, 1.0), (800.36332, 0.3677347619528959), (801.36668, 0.06562576793973895)]\n\n\n# 3) Get the estimated isotopic distribution for a given mass value\nmass = 1000.0\ncomposition = pt.estimate_comp(mass)\nisotopes = pt.isotopic_distribution(chemical_formula=composition, max_isotopes=3)\nassert isotopes == [(1000.0000038305802, 1.0), (1001.0033538305802, 0.47589204488021836),\n                     (1002.0067138305802, 0.11066305966308926)]\n\n# 4) By default, the isotopic_distribution function uses the masses of the elements, but it is also possible to use\n#    neutron offsets from the monoisotopic peak.\nsequence = 'PEPTIDE'\ncomposition = pt.comp(sequence)\nisotopes = pt.isotopic_distribution(chemical_formula=composition, max_isotopes=3, use_neutron_count=True)\nassert isotopes == [(0, 1.0), (1, 0.4051174337315902), (2, 0.11084816056223826)]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgarrett-scripps%2Fpeptacular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgarrett-scripps%2Fpeptacular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgarrett-scripps%2Fpeptacular/lists"}