Ejemplo n.º 1
0
 def get_driver_line(self):
     query = '''
             SELECT g.name as driver_line
             FROM ophys_experiments oe
             JOIN ophys_sessions os ON oe.ophys_session_id = os.id
             JOIN specimens sp ON sp.id=os.specimen_id
             JOIN donors d ON d.id=sp.donor_id
             JOIN donors_genotypes dg ON dg.donor_id=d.id
             JOIN genotypes g ON g.id=dg.genotype_id
             JOIN genotype_types gt ON gt.id=g.genotype_type_id AND gt.name = 'driver'
             WHERE oe.id= {};
             '''.format(self.get_ophys_experiment_id())
     result = self.fetchall(query)
     if result is None or len(result) < 1:
         raise OneOrMoreResultExpectedError('Expected one or more, but received: {} from query'.format(result))
     return result
Ejemplo n.º 2
0
 def from_lims(cls, behavior_session_id: int,
               lims_db: PostgresQueryMixin) -> "DriverLine":
     query = f"""
         SELECT g.name AS driver_line
         FROM behavior_sessions bs
         JOIN donors d ON bs.donor_id=d.id
         JOIN donors_genotypes dg ON dg.donor_id=d.id
         JOIN genotypes g ON g.id=dg.genotype_id
         JOIN genotype_types gt
             ON gt.id=g.genotype_type_id AND gt.name = 'driver'
         WHERE bs.id={behavior_session_id};
     """
     result = lims_db.fetchall(query)
     if result is None or len(result) < 1:
         raise OneOrMoreResultExpectedError(
             f"Expected one or more, but received: '{result}' "
             f"from query:\n'{query}'")
     driver_line = sorted(result)
     return cls(driver_line=driver_line)
Ejemplo n.º 3
0
 def get_driver_line(self) -> List[str]:
     """Returns the genotype name(s) of the driver line(s).
     :rtype: list
     """
     query = f"""
         SELECT g.name AS driver_line
         FROM behavior_sessions bs
         JOIN donors d ON bs.donor_id=d.id
         JOIN donors_genotypes dg ON dg.donor_id=d.id
         JOIN genotypes g ON g.id=dg.genotype_id
         JOIN genotype_types gt
             ON gt.id=g.genotype_type_id AND gt.name = 'driver'
         WHERE bs.id={self.behavior_session_id};
     """
     result = self.lims_db.fetchall(query)
     if result is None or len(result) < 1:
         raise OneOrMoreResultExpectedError(
             f"Expected one or more, but received: '{result}' "
             f"from query:\n'{query}'")
     return result
Ejemplo n.º 4
0
 def get_driver_line(self) -> str:
     """Get the (gene) driver line for the subject associated with an ophys
     experiment"""
     query = """
             SELECT g.name as driver_line
             FROM ophys_experiments oe
             JOIN ophys_sessions os ON oe.ophys_session_id = os.id
             JOIN specimens sp ON sp.id = os.specimen_id
             JOIN donors d ON d.id = sp.donor_id
             JOIN donors_genotypes dg ON dg.donor_id = d.id
             JOIN genotypes g ON g.id = dg.genotype_id
             JOIN genotype_types gt ON gt.id = g.genotype_type_id
             WHERE gt.name = 'driver'
             AND oe.id = {};
             """.format(self.get_ophys_experiment_id())
     result = self.lims_db.fetchall(query)
     if result is None or len(result) < 1:
         raise OneOrMoreResultExpectedError(
             f"Expected one or more, but received: '{result}' from query")
     return result