from .models import (
FlowCell,
- DataRun,
+ SequencingRun,
DataFile,
FileType,
ClusterStation,
class DataFileForm(ModelForm):
class Meta:
model = DataFile
- fields = ('random_key', 'data_run', 'library',
+ fields = ('random_key', 'sequencing_run', 'library',
'file_type', 'relative_pathname')
extra = 0
-class DataRunOptions(admin.ModelAdmin):
+class SequencingRunOptions(admin.ModelAdmin):
search_fields = [
'flowcell_id',
'run_folder',
)
inlines = [DataFileInline]
# list_filter = ('run_status', 'run_start_time')
-admin.site.register(DataRun, DataRunOptions)
+admin.site.register(SequencingRun, SequencingRunOptions)
class FileTypeAdmin(admin.ModelAdmin):
from django.utils import timezone
from htsworkflow.auth import require_api_key
-from .models import FlowCell, DataRun, Lane, LANE_STATUS_MAP
+from .models import FlowCell, SequencingRun, Lane, LANE_STATUS_MAP
from samples.models import Library, MultiplexIndex, HTSUser
def flowcell_information(flowcell_id):
# Update Data Run status in DB
# Try get rec. If not found return 'entry not found + <fcid><runfolder>', if found try update and return updated
try:
- rec = DataRun.objects.get(run_folder=runfolder)
+ rec = SequencingRun.objects.get(run_folder=runfolder)
rec.run_status = UpdatedStatus
#if there's a message update that too
rec.run_note = "Started ("+mytimestamp+")"
rec.save()
- output = "Hello "+settings.ALLOWED_IPS[ClIP]+". Updated to:'"+DataRun.RUN_STATUS_CHOICES[int(UpdatedStatus)][1].__str__()+"'"
+ output = "Hello "+settings.ALLOWED_IPS[ClIP]+". Updated to:'"+SequencingRun.RUN_STATUS_CHOICES[int(UpdatedStatus)][1].__str__()+"'"
except ObjectDoesNotExist:
output = "entry not found: "+fcid+", "+runfolder
if 'runf' in request:
runfolder = request['runf']
try:
- rec = DataRun.objects.get(run_folder=runfolder) #,flowcell_id=fcid)
+ rec = SequencingRun.objects.get(run_folder=runfolder) #,flowcell_id=fcid)
cnfgfile = rec.config_params
#match_str = re.compile(r"READ_LENGTH.+$")
match_str = re.compile('^READ_LENGTH.+')
if not match_str.search(cnfgfile):
cnfgfile = generateConfile(request,fcid)
if match_str.search(cnfgfile):
- rec = DataRun.objects.get(run_folder=runfolder) #,flowcell_id=fcid)
+ rec = SequencingRun.objects.get(run_folder=runfolder) #,flowcell_id=fcid)
rec.config_params = cnfgfile
rec.save()
else:
comment = 'lane comment'
-class DataRunFactory(DjangoModelFactory):
+class SequencingRunFactory(DjangoModelFactory):
class Meta:
- model = models.DataRun
+ model = models.SequencingRun
flowcell = factory.SubFactory(FlowCellFactory)
runfolder_name = '102030_UAW-EAS22_1234AAAAXX'
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('experiments', '0003_migrate_fcid_status'),
+ ]
+
+ operations = [
+ migrations.RenameModel('DataRun', 'SequencingRun'),
+ migrations.RenameField('datafile', 'data_run', 'sequencing_run'),
+ ]
return os.path.join(settings.RESULT_HOME_DIR, flowcell_id)
- def update_data_runs(self):
+ def update_sequencing_runs(self):
result_root = self.get_raw_data_directory()
LOGGER.debug("Update data runs flowcell root: %s" % (result_root,))
if result_root is None:
if run_xml_re.match(filename):
# we have a run directory
relative_pathname = get_relative_pathname(dirpath)
- self.import_data_run(relative_pathname, filename)
+ self.import_sequencing_run(relative_pathname, filename)
- def import_data_run(self, relative_pathname, run_xml_name, force=False):
+ def import_sequencing_run(self, relative_pathname, run_xml_name, force=False):
"""Given a result directory import files"""
now = timezone.now()
run_dir = get_absolute_pathname(relative_pathname)
run_xml_path = os.path.join(run_dir, run_xml_name)
- runs = DataRun.objects.filter(result_dir = relative_pathname)
+ runs = SequencingRun.objects.filter(result_dir = relative_pathname)
if len(runs) == 0:
- run = DataRun()
+ run = SequencingRun()
created = True
elif len(runs) > 1:
raise RuntimeError("Too many data runs for %s" % (
run.update_result_files()
-# FIXME: should we automatically update dataruns?
-# Or should we expect someone to call update_data_runs?
-#def update_flowcell_dataruns(sender, instance, *args, **kwargs):
-# """Update our dataruns
+# FIXME: should we automatically update sequencing run?
+# Or should we expect someone to call update_sequencing_runs?
+#def update_flowcell_sequencingruns(sender, instance, *args, **kwargs):
+# """Update our sequencing rungs
# """
# if not os.path.exists(settings.RESULT_HOME_DIR):
# return
#
-# instance.update_data_runs()
-#post_init.connect(update_flowcell_dataruns, sender=FlowCell)
+# instance.update_sequencing_runs()
+#post_init.connect(update_flowcell_sequencingruns, sender=FlowCell)
LANE_STATUS_CODES = [(0, 'Failed'),
(1, 'Marginal'),
return self.flowcell.flowcell_id + ':' + str(self.lane_number)
-class DataRun(models.Model):
+class SequencingRun(models.Model):
flowcell = models.ForeignKey(FlowCell, verbose_name="Flowcell Id")
runfolder_name = models.CharField(max_length=50)
result_dir = models.CharField(max_length=255)
pathname = os.path.join(dirname, filename)
relative_pathname = get_relative_pathname(pathname)
datafiles = self.datafile_set.filter(
- data_run=self,
+ sequencing_run=self,
relative_pathname=relative_pathname)
if len(datafiles) > 0:
continue
if metadata is not None:
metadata['filename'] = filename
newfile = DataFile()
- newfile.data_run = self
+ newfile.sequencing_run = self
newfile.file_type = metadata['file_type']
newfile.relative_pathname = relative_pathname
random_key = models.CharField(max_length=64,
db_index=True,
default=str_uuid)
- data_run = models.ForeignKey(DataRun, db_index=True)
+ sequencing_run = models.ForeignKey(SequencingRun, db_index=True, null=True)
library = models.ForeignKey(Library, db_index=True, null=True, blank=True)
file_type = models.ForeignKey(FileType)
relative_pathname = models.CharField(max_length=255, db_index=True)
<br/>
</div>
</div>
- {% for datarun in flowcell.datarun_set.all %}
+ {% for sequencingrun in flowcell.sequencingrun_set.all %}
<b>Image Analysis</b>:
- <span property="libns:image_software">{{datarun.image_software}}</span>
- <span property="libns:image_version">{{datarun.image_version}}</span><br/>
+ <span property="libns:image_software">{{sequencingrun.image_software}}</span>
+ <span property="libns:image_version">{{sequencingrun.image_version}}</span><br/>
<b>Base Caller</b>:
- <span property="libns:basecall_software">{{datarun.basecall_software}}</span>
- <span property="libns:basecall_version">{{datarun.basecall_version}}</span><br/>
+ <span property="libns:basecall_software">{{sequencingrun.basecall_software}}</span>
+ <span property="libns:basecall_version">{{sequencingrun.basecall_version}}</span><br/>
<b>Alignment</b>:
- <span property="libns:alignment_software">{{datarun.alignment_software}}</span>
- <span property="libns:alignment_version">{{datarun.alignment_version}}</span><br/>
+ <span property="libns:alignment_software">{{sequencingrun.alignment_software}}</span>
+ <span property="libns:alignment_version">{{sequencingrun.alignment_version}}</span><br/>
{% endfor %}
<b>Run Date</b>:
<span property="libns:date" content="{{flowcell.run_date|date:'Y-m-d\TH:i:s'}}" datatype="xsd:dateTime">{{ flowcell.run_date }}</span><br/>
{% include "sample_header.html" %}
<hr/>
<div class="htsw_flowcell_ivc">
- {% for run in flowcell.datarun_set.all %}
+ {% for run in flowcell.sequencingrun_set.all %}
<h2>Run {{ run.runfolder_name }}</h2>
<table>
<thead>
</tr>
</thead>
<tbody>
- {% for run, lane_number, lane_file_set in filtered_dataruns %}
+ {% for run, lane_number, lane_file_set in filtered_sequencingruns %}
{% if lane_file_set.ivc_all %}
<tr>
<td>{{lane_number}}</td>
from django.test import TestCase
from django.utils.encoding import smart_text
-from .models import DataRun, Sequencer, FlowCell, FileType
+from .models import SequencingRun, Sequencer, FlowCell, FileType
from samples.models import HTSUser
from .experiments import flowcell_information, lanes_for
from .experiments_factory import FlowCellFactory, LaneFactory
fc.flowcell_id = flowcell_id + " (failed)"
self.assertEqual(fc.get_raw_data_directory(), raw_dir)
- def test_data_run_import(self):
+ def test_sequencing_run_import(self):
srf_file_type = FileType.objects.get(name='SRF')
runxml_file_type = FileType.objects.get(name='run_xml')
flowcell_id = self.fc1_id
flowcell = FlowCell.objects.get(flowcell_id=flowcell_id)
- flowcell.update_data_runs()
- self.assertEqual(len(flowcell.datarun_set.all()), 1)
+ flowcell.update_sequencing_runs()
+ self.assertEqual(len(flowcell.sequencingrun_set.all()), 1)
- run = flowcell.datarun_set.all()[0]
+ run = flowcell.sequencingrun_set.all()[0]
result_files = run.datafile_set.all()
result_dict = dict(((rf.relative_pathname, rf) for rf in result_files))
srf4 = result_dict['FC12150/C1-37/woldlab_070829_SERIAL_FC12150_4.srf']
self.assertEqual(srf4.file_type, srf_file_type)
self.assertEqual(srf4.library_id, '12154')
- self.assertEqual(srf4.data_run.flowcell.flowcell_id, 'FC12150')
+ self.assertEqual(srf4.sequencing_run.flowcell.flowcell_id, 'FC12150')
self.assertEqual(
- srf4.data_run.flowcell.lane_set.get(lane_number=4).library_id,
+ srf4.sequencing_run.flowcell.lane_set.get(lane_number=4).library_id,
'12154')
self.assertEqual(
srf4.pathname,
self.assertEqual(runxml.file_type, runxml_file_type)
self.assertEqual(runxml.library_id, None)
- import1 = len(DataRun.objects.filter(result_dir='FC12150/C1-37'))
+ import1 = len(SequencingRun.objects.filter(result_dir='FC12150/C1-37'))
# what happens if we import twice?
- flowcell.import_data_run('FC12150/C1-37',
- 'run_FC12150_2007-09-27.xml')
+ flowcell.import_sequencing_run('FC12150/C1-37',
+ 'run_FC12150_2007-09-27.xml')
self.assertEqual(
- len(DataRun.objects.filter(result_dir='FC12150/C1-37')),
+ len(SequencingRun.objects.filter(result_dir='FC12150/C1-37')),
import1)
def test_read_result_file(self):
"""
flowcell_id = self.fc1_id
flowcell = FlowCell.objects.get(flowcell_id=flowcell_id)
- flowcell.update_data_runs()
+ flowcell.update_sequencing_runs()
#self.client.login(username='supertest', password='BJOKL5kAj6aFZ6A5')
- result_files = flowcell.datarun_set.all()[0].datafile_set.all()
+ result_files = flowcell.sequencingrun_set.all()[0].datafile_set.all()
for f in result_files:
url = '/experiments/file/%s' % ( f.random_key,)
response = self.client.get(url)
from django.template import RequestContext
from django.template.loader import get_template
-from .models import DataRun, DataFile, FlowCell, Lane, Sequencer
+from .models import SequencingRun, DataFile, FlowCell, Lane, Sequencer
from .admin import LaneOptions
from .experiments import estimateFlowcellDuration, estimateFlowcellTimeRemaining, roundToDays, \
getUsersForFlowcell, \
def index(request):
- all_runs = DataRun.objects.order_by('-run_start_time')
+ all_runs = SequencingRun.objects.order_by('-run_start_time')
return render_to_response('experiments/index.html',{'data_run_list': all_runs})
def detail(request, run_folder):
html_str = '<h2>Exp Track Details Page</h2>'
html_str += 'Run Folder: '+run_folder
- r = get_object_or_404(DataRun,run_folder=run_folder)
+ r = get_object_or_404(SequencingRun,run_folder=run_folder)
return render_to_response('experiments/detail.html',{'run_f': r})
def makeFCSheet(request,fcid):
def flowcell_detail(request, flowcell_id, lane_number=None):
fc = get_object_or_404(FlowCell, flowcell_id__startswith=flowcell_id)
- fc.update_data_runs()
+ fc.update_sequencing_runs()
if lane_number is not None:
lanes = fc.lane_set.filter(lane_number=lane_number)
def flowcell_lane_detail(request, lane_pk):
lane = get_object_or_404(Lane, id=lane_pk)
- lane.flowcell.update_data_runs()
+ lane.flowcell.update_sequencing_runs()
- dataruns = []
- lane.flowcell.update_data_runs()
- for run in lane.flowcell.datarun_set.all():
+ sequencingruns = []
+ lane.flowcell.update_sequencing_runs()
+ for run in lane.flowcell.sequencingrun_set.all():
files = run.lane_files().get(lane.lane_number, None)
- dataruns.append((run,
+ sequencingruns.append((run,
lane.lane_number,
files))
{'lib': lane.library,
'lane': lane,
'flowcell': lane.flowcell,
- 'filtered_dataruns': dataruns})
+ 'filtered_sequencingruns': sequencingruns})
return render_to_response('experiments/flowcell_lane_detail.html',
context)