def __init__(self):
     self.intent = {}
     self._channel = None
     self._control_type = None
     self._contents = []
     self._strains = []
     self._timepoints = []
     self._id_provider = IdProvider()
     self._table_caption = ''
Exemplo n.º 2
0
 def __init__(self):
     self._column_ids = []
     self._dna_reaction_concentrations = []
     self._lab_ids = []
     self._medias = []
     self._num_neg_controls = []
     self._reagents = []
     self._rna_inhibitor_reaction_flags = []
     self._row_ids = []
     self._template_dna_values = []
     self._id_provider = IdProvider()
class MediaIntent(object):
    def __init__(self, media_name: NamedLink):
        self._media_name = media_name
        self._media_values = []
        self._timepoint = None
        self._id_provider = IdProvider()

    def add_media_value(self, value: NamedLink):
        self._media_values.append(value)

    def get_media_name(self) -> NamedLink:
        return self._media_name

    def get_media_values(self):
        return self._media_values

    def get_timepoint(self) -> TimepointIntent:
        return self._timepoint

    def set_timepoint(self, timepoint: TimepointIntent):
        if self._timepoint is not None:
            new_value = '%d %s' % (timepoint.get_value(), timepoint.get_unit())
            curr_value = '%d %s' % (self._timepoint.get_value(),
                                    self._timepoint.get_unit())
            raise IntentParserException(
                'Unable to assign media timepoint value %s when it currently has %s assigned.'
                % (new_value, curr_value))

        self._timepoint = timepoint

    def values_to_opil_components(self):
        media_variants = []
        for media_value in self._media_values:
            media_value_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            media_value_component.name = media_value.get_name()

            if media_value.get_link() is not None:
                media_value_sub_component = SubComponent(
                    media_value.get_link())
                media_value_component.features = [media_value_sub_component]
            media_variants.append(media_value_component)
        return media_variants

    def to_structured_request(self):
        sr_media = []
        for value in self._media_values:
            media = {
                dc_constants.NAME: self._media_name.to_structured_request(),
                dc_constants.VALUE: value.get_name()
            }
            if self._timepoint:
                media[dc_constants.
                      TIMEPOINT] = self._timepoint.to_structured_request()
            sr_media.append(media)
        return sr_media
Exemplo n.º 4
0
 def __init__(self,
              strain_reference_link: str,
              lab_id: str,
              strain_common_name: str,
              lab_strain_names=[]):
     self._strain_reference_link = strain_reference_link
     self._lab_id = lab_id
     self._strain_common_name = strain_common_name
     self._lab_strain_names = lab_strain_names
     self._id_provider = IdProvider()
Exemplo n.º 5
0
 def __init__(self):
     self.intent = {}
     self._measurement_type = None
     self._file_types = []
     self._batches = []
     self._contents = MeasurementContent()
     self._controls = []
     self._optical_densities = []
     self._replicates = []
     self._strains = []
     self._temperatures = []
     self._timepoints = []
     self._id_provider = IdProvider()
 def __init__(self, submit_experiment: bool = True, xplan_reactor: str = 'xplan', test_mode: bool = False):
     self._base_dir = None
     self._xplan_reactor = xplan_reactor
     self._plate_size = None
     self._protocol_name = None
     self._plate_number = None
     self._container_search_strings = dc_constants.GENERATE
     self._strain_property = None
     self._xplan_path = None
     self._submit = submit_experiment
     self._protocol_id = None
     self._test_mode = test_mode
     self._experiment_reference_url_for_xplan = None
     self._default_parameters = {}
     self._id_provider = IdProvider()
Exemplo n.º 7
0
    def __init__(self,
                 experiment_ref,
                 experiment_ref_url,
                 lab_protocol_accessor,
                 sbol_dictionary,
                 lab_names=[]):
        super().__init__()
        self.processed_lab_name = ''
        self.processed_protocol_name = ''
        self.processed_controls = {}
        self.processed_lab = None
        self.measurement_table = None
        self.processed_parameter = None
        self.opil_document = None

        self._experiment_ref = experiment_ref
        self._experiment_ref_url = experiment_ref_url
        self._sbol_dictionary = sbol_dictionary
        self._lab_protocol_accessor = lab_protocol_accessor
        self._lab_names = lab_names
        self._id_provider = IdProvider()
Exemplo n.º 8
0
class StrainIntent(object):
    """
    Intent Parser's data representation of a strain.
    """

    def __init__(self, strain: NamedLink):
        self._id_provider = IdProvider()
        self._lab_name = ''
        self._strain_name = strain
        self._strain_commmon_name = ''

    def get_name(self) -> NamedLink:
        return self._strain_name

    def set_strain_lab_name(self, lab_name):
        if self._lab_name:
            raise IntentParserException('conflict setting stran lab name: Current lab set to %s' % self._lab_name)
        self._lab_name = lab_name

    def set_strain_common_name(self, common_name):
        if self._strain_commmon_name:
            raise IntentParserException('conflict setting strain common name: '
                                        'Current common name set to %s' % self._strain_commmon_name)
        self._strain_commmon_name = common_name

    def to_opil_component(self):
        strain_component = Component(identity=self._id_provider.get_unique_sd2_id(),
                                     types=sbol_constants.SBO_DNA)
        strain_component.name = self._strain_name.get_name()

        if self._strain_name.get_link():
            strain_sub_component = SubComponent(self._strain_name.get_link())
            strain_component.features = [strain_sub_component]
        return strain_component

    def to_structured_request(self):
        return {dc_constants.SBH_URI: self._strain_name.get_link(),
                dc_constants.LABEL: self._strain_commmon_name,
                dc_constants.LAB_ID: 'name.%s.%s' % (self._lab_name.lower(), self._strain_name.get_name())}
Exemplo n.º 9
0
 def __init__(self, strain: NamedLink):
     self._id_provider = IdProvider()
     self._lab_name = ''
     self._strain_name = strain
     self._strain_commmon_name = ''
Exemplo n.º 10
0
class ContentIntent(object):
    def __init__(self):
        self._column_ids = []
        self._dna_reaction_concentrations = []
        self._lab_ids = []
        self._medias = []
        self._num_neg_controls = []
        self._reagents = []
        self._rna_inhibitor_reaction_flags = []
        self._row_ids = []
        self._template_dna_values = []
        self._id_provider = IdProvider()

    def add_media(self, media):
        self._medias.append(media)

    def add_reagent(self, reagent):
        self._reagents.append(reagent)

    def get_medias(self):
        return self._medias

    def get_reagents(self):
        return self._reagents

    def set_column_ids(self, col_ids):
        self._column_ids = col_ids

    def set_dna_reaction_concentrations(self, dna_reaction_concentrations):
        self._dna_reaction_concentrations = dna_reaction_concentrations

    def set_lab_ids(self, lab_ids):
        self._lab_ids = lab_ids

    def set_numbers_of_negative_controls(self, neg_control):
        self._num_neg_controls = neg_control

    def set_rna_inhibitor_reaction_flags(self, rna_inhibitor_reactions):
        self._rna_inhibitor_reaction_flags = rna_inhibitor_reactions

    def set_row_ids(self, row_ids):
        self._row_ids = row_ids

    def set_template_dna_values(self, template_dna_values):
        self._template_dna_values = template_dna_values

    def is_empty(self):
        return (len(self._num_neg_controls) == 0
                and len(self._rna_inhibitor_reaction_flags) == 0
                and len(self._dna_reaction_concentrations) == 0
                and len(self._template_dna_values) == 0
                and len(self._column_ids) == 0 and len(self._row_ids) == 0
                and len(self._lab_ids) == 0 and len(self._reagents) == 0
                and len(self._medias) == 0)

    def to_structured_request(self):
        structure_request = []
        if len(self._num_neg_controls) > 0:
            structure_request.append([
                num_neg_control.to_structured_request()
                for num_neg_control in self._num_neg_controls
            ])
        if len(self._rna_inhibitor_reaction_flags) > 0:
            structure_request.append([
                rna_inhibitor_reaction.to_structured_request() for
                rna_inhibitor_reaction in self._rna_inhibitor_reaction_flags
            ])
        if len(self._dna_reaction_concentrations) > 0:
            structure_request.append([
                dna_reaction_concentration.to_structured_request() for
                dna_reaction_concentration in self._dna_reaction_concentrations
            ])
        if len(self._template_dna_values) > 0:
            structure_request.append([
                template_dna.to_structured_request()
                for template_dna in self._template_dna_values
            ])
        if len(self._column_ids) > 0:
            structure_request.append([
                col_id.to_structured_request() for col_id in self._column_ids
            ])
        if len(self._row_ids) > 0:
            structure_request.append(
                [row_id.to_structured_request() for row_id in self._row_ids])
        if len(self._lab_ids) > 0:
            structure_request.append(
                [lab_id.to_structured_request() for lab_id in self._lab_ids])
        if len(self._reagents) > 0:
            for reagent in self._reagents:
                structure_request.append(reagent.to_structured_request())
        if len(self._medias) > 0:
            for media in self._medias:
                structure_request.append(media.to_structured_request())

        return structure_request

    def size_of_column_id(self):
        return len(self._column_ids)

    def size_of_dna_reaction_concentrations(self):
        return len(self._dna_reaction_concentrations)

    def size_of_lab_ids(self):
        return len(self._lab_ids)

    def size_of_num_of_neg_controls(self):
        return len(self._num_neg_controls)

    def size_of_rna_inhibitor_flags(self):
        return len(self._rna_inhibitor_reaction_flags)

    def size_of_row_ids(self):
        return len(self._row_ids)

    def size_of_template_dna_values(self):
        return len(self._template_dna_values)

    def size_of_reagents(self):
        return len(self._reagents)

    def size_of_medias(self):
        return len(self._medias)

    def col_id_values_to_opil_components(self):
        col_id_components = []
        for value in self._column_ids:
            col_id_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            col_id_component.name = str(value.get_value())
            col_id_components.append(col_id_component)
        return col_id_components

    def dna_reaction_concentration_values_to_opil_components(self):
        dna_reaction_concentration_components = []
        for value in self._dna_reaction_concentrations:
            lab_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            lab_component.name = str(value.get_value())
            dna_reaction_concentration_components.append(lab_component)
        return dna_reaction_concentration_components

    def lab_id_values_to_opil_components(self):
        lab_id_components = []
        for value in self._lab_ids:
            lab_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            lab_component.name = str(value.get_value())
            lab_id_components.append(lab_component)
        return lab_id_components

    def number_of_negative_control_values_to_opil_components(self):
        num_neg_control_components = []
        for value in self._num_neg_controls:
            num_neg_control_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            num_neg_control_component.name = str(value.get_value())
            num_neg_control_components.append(num_neg_control_component)
        return num_neg_control_components

    def use_rna_inhibitor_values_to_opil_components(self):
        use_rna_inhib_components = []
        for value in self._rna_inhibitor_reaction_flags:
            use_rna_inhib_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            use_rna_inhib_component.name = str(value.get_value())
            use_rna_inhib_components.append(use_rna_inhib_component)
        return use_rna_inhib_components

    def row_id_values_to_opil_components(self):
        row_id_components = []
        for value in self._row_ids:
            row_id_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            row_id_component.name = str(value.get_value())
            row_id_components.append(row_id_component)
        return row_id_components

    def template_dna_values_to_opil_components(self):
        template_dna_components = []
        for value in self._template_dna_values:
            template_dna_component = Component(
                identity=self._id_provider.get_unique_sd2_id(),
                types=sbol_constants.SBO_FUNCTIONAL_ENTITY)
            template_dna_component.name = value.get_name()
            template_dna_components.append(template_dna_component)
        return template_dna_components
 def __init__(self, reagent_name: NamedLink):
     self._reagent_name = reagent_name
     self._reagent_values = []
     self._timepoint = None
     self._id_provider = IdProvider()
 def __init__(self, media_name: NamedLink):
     self._media_name = media_name
     self._media_values = []
     self._timepoint = None
     self._id_provider = IdProvider()
class ControlIntent(object):
    def __init__(self):
        self.intent = {}
        self._channel = None
        self._control_type = None
        self._contents = []
        self._strains = []
        self._timepoints = []
        self._id_provider = IdProvider()
        self._table_caption = ''

    def add_content(self, value):
        self._contents.append(value)

    def add_strain(self, strain: StrainIntent):
        self._strains.append(strain)

    def add_timepoint(self, timepoint):
        self._timepoints.append(timepoint)

    def get_contents(self):
        return self._contents

    def get_table_caption(self):
        return self._table_caption

    def is_empty(self):
        return (self._channel is None and self._control_type is None
                and len(self._contents) == 0 and len(self._strains) == 0
                and len(self._timepoints) == 0)

    def size_of_strains(self):
        return len(self._strains)

    def size_of_contents(self):
        return len(self._contents)

    def set_channel(self, value: str):
        self._channel = value

    def set_control_type(self, value: str):
        if self._control_type:
            raise IntentParserException('Conflict setting control type %s. '
                                        'Current set value %s' %
                                        (value, self._control_type))
        self._control_type = value

    def set_table_caption(self, table_caption):
        self._table_caption = table_caption

    def to_opil(self, opil_measurement):
        if self._channel is not None:
            self._encode_channel_using_opil(opil_measurement)
        if self._control_type is not None:
            self._encode_control_type_using_opil(opil_measurement)
        if len(self._timepoints) > 0:
            self._encode_timepoints_using_opil(opil_measurement)

    def to_structured_request(self):
        if self._control_type is None:
            raise IntentParserException('control-type is not set.')

        structure_request = {dc_constants.TYPE: self._control_type}
        if len(self._strains) > 0:
            structure_request[dc_constants.STRAINS] = [
                strain.to_structured_request() for strain in self._strains
            ]
        if self._channel:
            structure_request[dc_constants.CHANNEL] = self._channel
        if len(self._contents) > 0:
            structure_request[dc_constants.CONTENTS] = [
                content.to_structured_request() for content in self._contents
            ]
        if len(self._timepoints) > 0:
            structure_request[dc_constants.TIMEPOINTS] = [
                timepoint.to_structured_request()
                for timepoint in self._timepoints
            ]
        return structure_request

    def _encode_channel_using_opil(self, opil_measurement):
        opil_measurement.channel = TextProperty(
            opil_measurement, ip_constants.SD2E_NAMESPACE + 'channel', 0, 1)
        opil_measurement.channel = self._channel

    def _encode_control_type_using_opil(self, opil_measurement):
        opil_measurement.control_type = TextProperty(
            opil_measurement, self._id_provider.get_unique_sd2_id(), 0, 1)
        opil_measurement.control_type = self._control_type

    def _encode_timepoints_using_opil(self, opil_measurement):
        encoded_timepoints = []
        for timepoint in self._timepoints:
            encoded_timepoints.append(timepoint.to_opil_measure())
        opil_measurement.time = encoded_timepoints

    def strain_values_to_opil_components(self):
        return [strain.to_opil_component() for strain in self._strains]