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

Specify version of CV to use? #8

Open
bretttully opened this issue Apr 9, 2019 · 3 comments
Open

Specify version of CV to use? #8

bretttully opened this issue Apr 9, 2019 · 3 comments

Comments

@bretttully
Copy link

My unit tests fail each time the CV obo versions change, is there any way to control which version is used when calling writer.controlled_vocabularies()?

e.g.

$ diff a.mzml b.mzml 
5,6c5,6
<       <cv URI="https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo" fullName="PSI-MS" id="PSI-MS" version="4.1.24"/>
<       <cv URI="http://ontologies.berkeleybop.org/uo.obo" fullName="UNIT-ONTOLOGY" id="UO" version="releases/2019-03-29"/>
---
>       <cv URI="https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo" fullName="PSI-MS" id="PSI-MS" version="4.1.25"/>
>       <cv URI="http://ontologies.berkeleybop.org/uo.obo" fullName="UNIT-ONTOLOGY" id="UO" version="releases/2019-04-01"/>
56c56
<   <fileChecksum>25aefe7cfa862b2d10c1de97b8610e8bba2874d9</fileChecksum>
---
>   <fileChecksum>19cac13f7e784d39512d32eae6d77a14319f8651</fileChecksum>
@mobiusklein
Copy link
Owner

I seem to have made this difficult to manipulate directly. When instantiating a writer, you can pass in a list of CV objects for it to use, but it automatically uses the default vocabularies for the format too. The mzML vocabularies are located in psims.mzml.components.default_cv_list. I'll have to make the CV type a bit more user friendly and put deduplication logic in place.

In the meantime, to avoid updating the CV, you can configure the OBO cache by calling psims.controlled_vocabulary.controlled_vocabulary.configure_obo_store prior to running your test. This will download any OBOs that the document needs and save them in that directory, and if a CV is requested by URI that can be found in the cache, it will be read from the cache instead of downloading it from the provided URI. This means that if you're running your unit tests on an ephemeral file system like a CI server, you'll need to populate the cache yourself. You can use the static files in psims/controlled_vocabulary/vendor as seeds for that, but I tend to update them periodically so you'll want to make a static copy. I have psi-ms.obo at 4.1.22, so a few releases behind the ontology.

My intention (rather, what I do in my own applications and do not document anywhere) was that during installation/update, a program using psims would get a directory along the user's local config path, and create a subdirectory in it, declare that to be the OBO cache directory, and then write a known good version of the OBOs to that subdirectory, and never deal with it again. Should a problem arise with the cache, or from retrieving the OBO from the internet, the vendored OBO will still be available.

The pymzML repository maintains a historical list of psi-ms.obo releases, if you're looking for a specific version and the source repository history is too muddy.

@mobiusklein
Copy link
Owner

Sorry for the delay in getting back to this.

The version at 36ddbcf now supports this behavior properly:

import psims
from psims.mzml import MzMLWriter

cvs = [
    psims.xml.CV("PSI-MS", 'PSI-MS', "4.1.42",
                           "https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo")
]
...
with MzMLWriter(path, vocabularies=cvs) as f:
    f.controlled_vocabularies()
    ...

This will render as:

<?xml version='1.0' encoding='utf-8'?>
<indexedmzML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://psi.hupo.org/ms/mzml" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.2_idx.xsd">
  <mzML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://psi.hupo.org/ms/mzml" xsi:schemaLocation="http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" version="1.1.0">
    <cvList count="2">
      <cv URI="https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo" fullName="PSI-MS" id="PSI-MS" version="4.1.42"/>
      <cv URI="http://ontologies.berkeleybop.org/uo.obo" fullName="UNIT-ONTOLOGY" id="UO" version="releases/2019-04-01"/>
    </cvList>

You can specify a custom URI to load the vocabulary's obo file from, and it will be requested when the CV has to be loaded. If you specify a custom version over a URI, it will simply be rendered in the XML file, having no bearing on the version loaded, as there is no protocol in place for requesting a specific version by URI.

@mobiusklein
Copy link
Owner

@bretttully Congratulations on the press on your pre-print on toffee. Did I solve your problem, or is this a recurring issue still?

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