pulsarpy_dx.utils

exception pulsarpy_dx.utils.BarcodeNotSet[source]

Bases: Exception

Raised when a barcode (paired or single-end) is expected to be set on a Library record but isn’t.

exception pulsarpy_dx.utils.MissingSequencingRequest[source]

Bases: Exception

Raised when a SequencingRequest was expected to be found in Pulsar but was not.

pulsarpy_dx.utils.get_or_create_srun_by_ids(sreq_id, dx_project_id)[source]

A wrapper over get_or_create_srun() below that simplifies the parameters to use IDs instead of objects.

Parameters:
  • sreq_idint. A Pulsar SequencingRequest record ID.
  • dx_project_idstr. The project ID of a DNAnexus project, i.e. FPg8yJQ900P4ZgzxFZbgJZY2.
Returns:

pulsarpy.models.SequencingRun instance.

pulsarpy_dx.utils.get_or_create_srun(sreq, dxres)[source]

Checks whether a given SequencingRequest record already has a SequencingRun record for a particular DNAnexus project. This check is satisfied if either of the following are true:

  1. There is a SequencingRun whose name attribute is equal to the value of the DNAnexus project’s name (case-insensitive).
  2. There is a SequencingRun with an associated DataStorage whose project_identifier attribute is equal to the project ID if the DNAnexus project.

If such a SequencingRun record exists, it is returned, otherwise a new SequencingRun record based off of the provided DNAnexus sequencing results is created and then returned.

Parameters:
  • sreqpulsarpy.models.SequencingRequest instance.
  • - scgpm_seqresults_dnanexus.dnanexus_utils.du.DxSeqResults() instance that contains (dxres) – sequencing results metadata from DNAnexus that represents a sequencing run of the given pulsarpy.models.SequencingRequest.
Returns:

pulsarpy.models.SequencingRun instance.

pulsarpy_dx.utils.create_srun(sreq, dxres)[source]

Creates a SequencingRun record based on the provided DNAnexus sequencing results, to be linked to the given SequencingRequest object.

Note that I would also like to try and set the attributes SequencingRun.forward_read_len and SequencingRun.reverse_read_len, however, I can’t obtain these results from DNAnexus based on the existing metadata that’s sent there via GSSC.

Parameters:
  • sreq – A pulsarpy.models.SequencingRequest instance.
  • dxresscgpm_seqresults_dnanexus.dnanexus_utils.du.DxSeqResults() instance that contains sequencing results metadata in DNAnexus for the given srun.
pulsarpy_dx.utils.create_data_storage(dxres)[source]

Creates a DataStorage record for the given DNAnexus sequencing results.

Parameters:dxresscgpm_seqresults_dnanexus.dnanexus_utils.du.DxSeqResults() instance that contains sequencing results metadata in DNAnexus for the given srun.
Returns:
dict. The response from the server containing the JSON serialization of the new
DataStorage record.
pulsarpy_dx.utils.check_pairedend_correct(sreq, dx_pe_val)[source]

Checks whether the SequencingRequest.paired_end attribute and the ‘paired’ property of the DNAnexus project in question are in accordance. It’s possible that the request originally went in as SE (or the tech forgot to check PE), but the sequencing run was acutally done PE. If this is the case, then the SequencingRequest.paired_end attribute will be updated to be set to True in order that PE sequencing results will be allowed (PE attributes of a SequencingResult will be hidden in the UI if the SequencingRequest is set to paired_end being false).

Parameters:
  • sreq – A pulsarpy.models.SequencingRequest instance.
  • dx_pe_valstr. The value of the ‘paired’ property of the DNAnexus project in questions.
pulsarpy_dx.utils.import_dx_project(dx_project_id)[source]

Attemps to import DNAnexus sequencing results for the given DNAnexus project ID. This entails having a SequencingRequest object in Pulsar that in turn has a SequecingRun object to import the results into, creating SequencingResult objects in the process. Thus, we must first try to find the appropriate SequencingRequest if it exists. If it doesn’t, an Exception will be raised.

We first try to find the SequencingRequest by matching the value of its name attribute to the DNAnexus project’s library_name property value. Normally, when provinding the sequencing center a name for their library to be sequenced, the lab uses the record ID of the SequencingRequest object, which is the concatenation of the model abbreviation in Pulsar, a hyphen, and the record’s primary ID (i.e. SREQ-25). Normally, we could just search by the integer portion on the primary ID field. However, SequencingRequests from the old Syapse LIMS have been backported into Pulsar, and they used the same record ID forming convention there too. So for these records, the Syaspe record ID has been added into a Pulsar SequencingRequest via the name attribute. Thus, as a precaution, a SequencingRequest is first searched on its name attribute. If that fails, then the SequencingRequests are searched on the primary ID attribute using only the interger portion of the DNAnexus project’s library_name property.

Raises:
  • pulsarpy.elasticsearch_utils.MultipleHitsException – Multiple SequencingRequest records were found in searching by name in pulsarpy.models.Model.replace_name_with_id().
  • MissingSequencingRequest – A relevant SequencingRequest record to import the DNAnexus sequencing results into could not be found.
  • BarcodeNotSet – A library on the SequencingRequest object at hand does not have a barcode set, making it impossible to import sequening results from DNAnexus for it.
  • scgpm_seqresults_dnanexus.dnanexus_utils.FastqNotFound – There aren’t any FASTQ files in the DNAnexus project for a given Library, based on the barcode specified for that Library.