Skip to content

Commit 3de586c

Browse files
added remove funcs to proforma annot
1 parent 958fd84 commit 3de586c

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed

src/peptacular/proforma/proforma_parser.py

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,204 @@ def pop_mods(self) -> Dict[str, Any]:
13211321

13221322
return d
13231323

1324+
def remove_labile_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1325+
"""
1326+
Remove all labile mods and return the modified annotation.
1327+
1328+
:param inplace: If True, modify the current annotation. If False, create a copy.
1329+
:type inplace: bool
1330+
:return: The annotation with labile mods removed
1331+
:rtype: ProFormaAnnotation
1332+
"""
1333+
annotation = self
1334+
1335+
if inplace is False:
1336+
annotation = deepcopy(self)
1337+
1338+
_ = annotation.pop_labile_mods()
1339+
1340+
return annotation
1341+
1342+
def remove_unknown_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1343+
"""
1344+
Remove all unknown mods and return the modified annotation.
1345+
1346+
:param inplace: If True, modify the current annotation. If False, create a copy.
1347+
:type inplace: bool
1348+
:return: The annotation with unknown mods removed
1349+
:rtype: ProFormaAnnotation
1350+
"""
1351+
annotation = self
1352+
1353+
if inplace is False:
1354+
annotation = deepcopy(self)
1355+
1356+
_ = annotation.pop_unknown_mods()
1357+
1358+
return annotation
1359+
1360+
def remove_nterm_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1361+
"""
1362+
Remove all N-terminal mods and return the modified annotation.
1363+
1364+
:param inplace: If True, modify the current annotation. If False, create a copy.
1365+
:type inplace: bool
1366+
:return: The annotation with N-terminal mods removed
1367+
:rtype: ProFormaAnnotation
1368+
"""
1369+
annotation = self
1370+
1371+
if inplace is False:
1372+
annotation = deepcopy(self)
1373+
1374+
_ = annotation.pop_nterm_mods()
1375+
1376+
return annotation
1377+
1378+
def remove_cterm_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1379+
"""
1380+
Remove all C-terminal mods and return the modified annotation.
1381+
1382+
:param inplace: If True, modify the current annotation. If False, create a copy.
1383+
:type inplace: bool
1384+
:return: The annotation with C-terminal mods removed
1385+
:rtype: ProFormaAnnotation
1386+
"""
1387+
annotation = self
1388+
1389+
if inplace is False:
1390+
annotation = deepcopy(self)
1391+
1392+
_ = annotation.pop_cterm_mods()
1393+
1394+
return annotation
1395+
1396+
def remove_internal_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1397+
"""
1398+
Remove all internal mods and return the modified annotation.
1399+
1400+
:param inplace: If True, modify the current annotation. If False, create a copy.
1401+
:type inplace: bool
1402+
:return: The annotation with internal mods removed
1403+
:rtype: ProFormaAnnotation
1404+
"""
1405+
annotation = self
1406+
1407+
if inplace is False:
1408+
annotation = deepcopy(self)
1409+
1410+
_ = annotation.pop_internal_mods()
1411+
1412+
return annotation
1413+
1414+
def remove_intervals(self, inplace: bool = False) -> "ProFormaAnnotation":
1415+
"""
1416+
Remove all intervals and return the modified annotation.
1417+
1418+
:param inplace: If True, modify the current annotation. If False, create a copy.
1419+
:type inplace: bool
1420+
:return: The annotation with intervals removed
1421+
:rtype: ProFormaAnnotation
1422+
"""
1423+
annotation = self
1424+
1425+
if inplace is False:
1426+
annotation = deepcopy(self)
1427+
1428+
_ = annotation.pop_intervals()
1429+
1430+
return annotation
1431+
1432+
def remove_charge(self, inplace: bool = False) -> "ProFormaAnnotation":
1433+
"""
1434+
Remove the charge and return the modified annotation.
1435+
1436+
:param inplace: If True, modify the current annotation. If False, create a copy.
1437+
:type inplace: bool
1438+
:return: The annotation with charge removed
1439+
:rtype: ProFormaAnnotation
1440+
"""
1441+
annotation = self
1442+
1443+
if inplace is False:
1444+
annotation = deepcopy(self)
1445+
1446+
_ = annotation.pop_charge()
1447+
1448+
return annotation
1449+
1450+
def remove_charge_adducts(self, inplace: bool = False) -> "ProFormaAnnotation":
1451+
"""
1452+
Remove all charge adducts and return the modified annotation.
1453+
1454+
:param inplace: If True, modify the current annotation. If False, create a copy.
1455+
:type inplace: bool
1456+
:return: The annotation with charge adducts removed
1457+
:rtype: ProFormaAnnotation
1458+
"""
1459+
annotation = self
1460+
1461+
if inplace is False:
1462+
annotation = deepcopy(self)
1463+
1464+
_ = annotation.pop_charge_adducts()
1465+
1466+
return annotation
1467+
1468+
def remove_isotope_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1469+
"""
1470+
Remove all isotope mods and return the modified annotation.
1471+
1472+
:param inplace: If True, modify the current annotation. If False, create a copy.
1473+
:type inplace: bool
1474+
:return: The annotation with isotope mods removed
1475+
:rtype: ProFormaAnnotation
1476+
"""
1477+
annotation = self
1478+
1479+
if inplace is False:
1480+
annotation = deepcopy(self)
1481+
1482+
_ = annotation.pop_isotope_mods()
1483+
1484+
return annotation
1485+
1486+
def remove_static_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1487+
"""
1488+
Remove all static mods and return the modified annotation.
1489+
1490+
:param inplace: If True, modify the current annotation. If False, create a copy.
1491+
:type inplace: bool
1492+
:return: The annotation with static mods removed
1493+
:rtype: ProFormaAnnotation
1494+
"""
1495+
annotation = self
1496+
1497+
if inplace is False:
1498+
annotation = deepcopy(self)
1499+
1500+
_ = annotation.pop_static_mods()
1501+
1502+
return annotation
1503+
1504+
def remove_mods(self, inplace: bool = False) -> "ProFormaAnnotation":
1505+
"""
1506+
Remove all modifications and return the modified annotation.
1507+
1508+
:param inplace: If True, modify the current annotation. If False, create a copy.
1509+
:type inplace: bool
1510+
:return: The annotation with all modifications removed
1511+
:rtype: ProFormaAnnotation
1512+
"""
1513+
annotation = self
1514+
1515+
if inplace is False:
1516+
annotation = deepcopy(self)
1517+
1518+
_ = annotation.pop_mods()
1519+
1520+
return annotation
1521+
13241522
def add_labile_mods(
13251523
self, mods: Optional[Union[List[Mod], Mod]], append: bool = False
13261524
) -> None:

0 commit comments

Comments
 (0)