Skip to content

Commit

Permalink
handle barcode for finished libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Galithil committed Sep 2, 2016
1 parent d63c22d commit 647c026
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions LIMS2DB/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ def get_library_preps(self, sample):

try:
agrlibvals=get_children_processes(self.session, one_libprep.processid, pc_cg.AGRLIBVAL.keys(), sample.processid, 'daterun desc')
agrlibval=None
for agrlv in agrlibvals:
#for small rna (and maybe others), there is more than one agrlibval, and I should not get the latest one,
#but the latest one that ran at sample level, not a pool level.
Expand All @@ -590,7 +591,21 @@ def get_library_preps(self, sample):
break
except NoResultFound:
pass

#Get barcode for finlib
if not agrlibval and 'By user' in self.obj['details']['library_construction_method']:
#Get initial artifact for given sample
query="select art.* from artifact art \
inner join artifact_sample_map asm on asm.artifactid=art.artifactid \
inner join sample sa on sa.processid=asm.processid \
where sa.processid = {sapid} and art.isoriginal=True".format(sapid=sample.processid)
try:
initial_artifact=self.session.query(Artifact).from_statement(text(query)).one()
self.obj['samples'][sample.name]['library_prep'][prepname]['reagent_label']=initial_artifact.reagentlabels[0].name
except:
pass


#raises AttributeError on no aggregate
self.obj['samples'][sample.name]['library_prep'][prepname]['library_validation'][agrlibval.luid]={}
try:
self.obj['samples'][sample.name]['library_prep'][prepname]['library_validation'][agrlibval.luid]['finish_date']=agrlibval.daterun.strftime("%Y-%m-%d")
Expand Down Expand Up @@ -669,7 +684,7 @@ def get_library_preps(self, sample):

except NoResultFound:
self.log.info("Did not find the output resultfile of the Neoprep step for sample {}".format(sample.name))
except IndexError:
except AttributeError:
self.log.info("No aggregate for sample {} prep {}".format(sample.name, one_libprep.luid))
#get output analyte of a given process that belongs to sample
query="select art.* from artifact art \
Expand Down

0 comments on commit 647c026

Please sign in to comment.