Skip to content

Commit

Permalink
Remove unit and definition fields from schema and terms, get from CV …
Browse files Browse the repository at this point in the history
…when building markdown docs instead
  • Loading branch information
RalfG committed Jul 7, 2023
1 parent 891fbdb commit 99b8652
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 181 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/scripts/generate_metadata_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

from jsonschema import validate
from tomark import Tomark
import psims


def rules_to_markdown(rules):
cv = psims.load_psims() # load a fresh copy of the PSI-MS CV mapping

rule_dict = defaultdict(lambda: defaultdict(list))
for rule in rules["rules"]:
rule_dict[rule["path"]][rule["requirement_level"]].append(rule)
Expand All @@ -31,13 +34,19 @@ def rules_to_markdown(rules):
for attr in rule_attrs:
field = dict()

# Attempt to lookup term in CV
try:
cv_term = cv[attr["accession"]]
except KeyError:
cv_term = None

# Parse name and accession fields
field["Name"] = f"{attr['name']} ({attr['accession']})"

# Parse definition field
info = []
if "definition" in attr:
info.append(attr["definition"])
if cv_term:
info.append(cv_term.definition)
if "notes" in attr:
info.append(f"**Notes:** {attr['notes']}")
field["Info"] = "<br /><br />".join(info).replace(
Expand All @@ -56,9 +65,15 @@ def rules_to_markdown(rules):
field["Value"] = "Undefined"

# Parse units field
field["Allowed units"] = (
", ".join(attr["units"]) if "units" in attr else "/"
)
if cv_term:
try:
units = [u.comment for u in cv_term.has_units]
except AttributeError:
units = None
else:
units = None

field["Allowed units"] = ", ".join(units) if units else "/"

# Parse repeatable field
field["Repeatable"] = attr["repeatable"]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
tomark
jsonschema
psims
2 changes: 1 addition & 1 deletion docs/metadata-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

| Name | Info | Value | Allowed units | Repeatable |
|-----|-----|-----|-----|-----|
| charge state ([MS:1000041](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1000041)) | "Number of net charges, positive or negative, on an ion." [PSI:MS]<br /><br />**Notes:** The “charge state” attribute has two different meanings depending on its context. When this attribute is included under <Spectrum=...>, it is used to denote the experimental charge state of the precursor as inferred from the data (e.g. by the isotopic pattern of the precursor peak in the MSn-1 spectrum). If the spectrum is identified to an analyte, the charge state refers to that of the analyte believed to produce this spectrum. In such cases, the charge state attribute should be included in the <Analyte=> section instead. | xsd:integer | / | False |
| charge state ([MS:1000041](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1000041)) | "Number of net charges, positive or negative, on an ion." [PSI:MS]<br /><br />**Notes:** The "charge state" attribute has two different meanings depending on its context. When this attribute is included under <Spectrum=...>, it is used to denote the experimental charge state of the precursor as inferred from the data (e.g. by the isotopic pattern of the precursor peak in the MSn-1 spectrum). If the spectrum is identified to an analyte, the charge state refers to that of the analyte believed to produce this spectrum. In such cases, the charge state attribute should be included in the <Analyte=> section instead. | xsd:integer | / | False |
| theoretical mass ([MS:1001117](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1001117)) | "The theoretical neutral mass of the molecule (e.g. the peptide sequence and its modifications) not including its charge carrier." [PSI:PI]<br /><br />**Notes:** This is the theoretical mass of the neutral molecule (does not include the charge-giving moiety. Use the term “[MS:1003243](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1003243)\|adduct ion mass” to refer to the mass of the adduct ion, which includes the charge-giving moiety. | xsd:double | dalton | False |
| adduct ion mass ([MS:1003243](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1003243)) | "The theoretical mass of the adduct ion (e.g. for a singly-charged protonated peptide ion, this value would be the neutral peptide molecule's mass plus the mass of a proton)" [PSI:PI] | xsd:float | / | False |
| adduct ion formula ([MS:1002813](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1002813)) | "Adduct formation formula of the form M+X or M-X, as constrained by the provided regular expression." [PSI:MS]<br /><br />**Notes:** For peptides, absence of this field implies that the adduct ion is [M+nH]n+ where n is the charge state. The regular expression for this field is given in the definition of [MS:1002812](https://www.ebi.ac.uk/ols4/ontologies/ms/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FMS_1002812)\|Regular expression for adduct ion formula. | xsd:string | / | False |
Expand Down
Loading

0 comments on commit 99b8652

Please sign in to comment.