from htsworkflow.frontend import settings
from htsworkflow.frontend.experiments.models import FlowCell, DataRun
from htsworkflow.frontend.samples.models import Library
+from htsworkflow.frontend.auth import require_api_key
def flowcell_information(flowcell_id):
"""
lane_set[lane.lane_number] = {
'cluster_estimate': lane.cluster_estimate,
'comment': lane.comment,
+ 'experiment_type': lane.library.experiment_type.name,
+ 'experiment_type_id': lane.library.experiment_type_id,
'flowcell': lane.flowcell.flowcell_id,
'lane_number': int(lane.lane_number),
'library_name': lane.library.library_name,
- 'library_id': lane.library_id,
- 'pM': float(lane.pM),
+ 'library_id': lane.library.id,
+ 'library_species': lane.library.library_species.scientific_name,
+ 'pM': unicode(lane.pM),
+ 'read_length': lane.flowcell.read_length
}
+
+ if fc.control_lane is None:
+ control_lane = None
+ else:
+ control_lane = int(fc.control_lane)
+
info = {
'advanced_run': fc.advanced_run,
'cluster_station_id': fc.cluster_station_id,
'cluster_station': fc.cluster_station.name,
- 'control_lane': int(fc.control_lane),
+ 'control_lane': control_lane,
# 'datarun_set': how should this be represented?,
'flowcell_id': fc.flowcell_id,
'id': fc.id,
return info
-@login_required
def flowcell_json(request, fc_id):
"""
Return a JSON blob containing enough information to generate a config file.
"""
+ require_api_key(request)
+
fc_dict = flowcell_information(fc_id)
if fc_dict is None:
try:
fc = FlowCell.objects.get(flowcell_id=fcid)
for lane in fc.lane_set.all():
- print dir(lane.library.library_species)
config += [ str(lane.lane_number) +":" + \
genome_dir + lane.library.library_species.scientific_name ]
config += [ str(lane.lane_number) +":" + \
cnfgfile = 'Nothing found'
runfolder = 'unknown'
request = req.REQUEST
- print request, dir(request)
- print request['fcid'], request.has_key('fcid')
- print request['runf']
if request.has_key('fcid'):
fcid = request['fcid']
if request.has_key('runf'):
mydate = year+month+day
outputfile = '<?xml version="1.0" ?>'
outputfile += '\n<SolexaResult Date="'+mydate+'" Flowcell="'+fcid+'" Client="'+settings.ALLOWED_IPS[ClIP]+'">'
- outputfile += '\n<Lane Index="1" Name="'+rec.lane_1_library.library_name+'" Library="'+rec.lane_1_library.library_id+'" Genome="'+rec.lane_1_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="2" Name="'+rec.lane_2_library.library_name+'" Library="'+rec.lane_2_library.library_id+'" Genome="'+rec.lane_2_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="3" Name="'+rec.lane_3_library.library_name+'" Library="'+rec.lane_3_library.library_id+'" Genome="'+rec.lane_3_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="4" Name="'+rec.lane_4_library.library_name+'" Library="'+rec.lane_4_library.library_id+'" Genome="'+rec.lane_4_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="5" Name="'+rec.lane_5_library.library_name+'" Library="'+rec.lane_5_library.library_id+'" Genome="'+rec.lane_5_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="6" Name="'+rec.lane_6_library.library_name+'" Library="'+rec.lane_6_library.library_id+'" Genome="'+rec.lane_6_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="7" Name="'+rec.lane_7_library.library_name+'" Library="'+rec.lane_7_library.library_id+'" Genome="'+rec.lane_7_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
- outputfile += '\n<Lane Index="8" Name="'+rec.lane_8_library.library_name+'" Library="'+rec.lane_8_library.library_id+'" Genome="'+rec.lane_8_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="1" Name="'+rec.lane_1_library.library_name+'" Library="'+rec.lane_1_library.id+'" Genome="'+rec.lane_1_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="2" Name="'+rec.lane_2_library.library_name+'" Library="'+rec.lane_2_library.id+'" Genome="'+rec.lane_2_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="3" Name="'+rec.lane_3_library.library_name+'" Library="'+rec.lane_3_library.id+'" Genome="'+rec.lane_3_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="4" Name="'+rec.lane_4_library.library_name+'" Library="'+rec.lane_4_library.id+'" Genome="'+rec.lane_4_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="5" Name="'+rec.lane_5_library.library_name+'" Library="'+rec.lane_5_library.id+'" Genome="'+rec.lane_5_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="6" Name="'+rec.lane_6_library.library_name+'" Library="'+rec.lane_6_library.id+'" Genome="'+rec.lane_6_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="7" Name="'+rec.lane_7_library.library_name+'" Library="'+rec.lane_7_library.id+'" Genome="'+rec.lane_7_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+ outputfile += '\n<Lane Index="8" Name="'+rec.lane_8_library.library_name+'" Library="'+rec.lane_8_library.id+'" Genome="'+rec.lane_8_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
outputfile += '\n</SolexaResult>'
except ObjectDoesNotExist:
outputfile = 'Flowcell entry not found for: '+fcid
sequencing_time = timedelta(0, cycles * sequencing_seconds_per_cycle)
analysis_time = timedelta(0, cycles * pipeline_seconds_per_cycle)
estimate_mid = sequencing_time + analysis_time
+
+ return estimate_mid
+
+def estimateFlowcellTimeRemaining(flowcell):
+ estimate_mid = estimateFlowcellDuration(flowcell)
+
+ # offset for how long we've been running
+ running_time = datetime.now() - flowcell.run_date
+ estimate_mid -= running_time
+
+ return estimate_mid
+
+def roundToDays(estimate):
+ """
+ Given a time estimate round up and down in days
+ """
# floor estimate_mid
- estimate_low = timedelta(estimate_mid.days, 0)
+ estimate_low = timedelta(estimate.days, 0)
# floor estimate_mid and add a day
- estimate_high = timedelta(estimate_mid.days+1, 0)
+ estimate_high = timedelta(estimate.days+1, 0)
return (estimate_low, estimate_high)