rename datarun to sequencing run, and propogate the change all over the place
authorDiane Trout <diane@ghic.org>
Tue, 26 May 2015 23:58:49 +0000 (16:58 -0700)
committerDiane Trout <diane@ghic.org>
Tue, 26 May 2015 23:58:49 +0000 (16:58 -0700)
experiments/admin.py
experiments/experiments.py
experiments/experiments_factory.py
experiments/migrations/0004_rename_datarun_to_sequencingrun.py [new file with mode: 0644]
experiments/models.py
experiments/templates/experiments/flowcell_header.html
experiments/templates/experiments/flowcell_lane_detail.html
experiments/test_experiments.py
experiments/views.py

index 76888396a6271f3cc23d8893a1be9a8f110422ab..d6bd78a7bc7db3cbbe3e307217689f6c7376e817 100644 (file)
@@ -11,7 +11,7 @@ from django.utils.html import escape, conditional_escape
 
 from .models import (
     FlowCell,
-    DataRun,
+    SequencingRun,
     DataFile,
     FileType,
     ClusterStation,
@@ -23,7 +23,7 @@ from .models import (
 class DataFileForm(ModelForm):
     class Meta:
         model = DataFile
-        fields = ('random_key', 'data_run', 'library',
+        fields = ('random_key', 'sequencing_run', 'library',
                   'file_type', 'relative_pathname')
 
 
@@ -34,7 +34,7 @@ class DataFileInline(admin.TabularInline):
     extra = 0
 
 
-class DataRunOptions(admin.ModelAdmin):
+class SequencingRunOptions(admin.ModelAdmin):
     search_fields = [
         'flowcell_id',
         'run_folder',
@@ -60,7 +60,7 @@ class DataRunOptions(admin.ModelAdmin):
     )
     inlines = [DataFileInline]
     # list_filter = ('run_status', 'run_start_time')
-admin.site.register(DataRun, DataRunOptions)
+admin.site.register(SequencingRun, SequencingRunOptions)
 
 
 class FileTypeAdmin(admin.ModelAdmin):
index 8c82974889574270dd4eb3282d47f61d3d62ebe9..b443a4d7db42e971b9c9f9c5a6a0058c0897799e 100644 (file)
@@ -14,7 +14,7 @@ from django.conf import settings
 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):
@@ -166,7 +166,7 @@ def updStatus(request):
     # 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
@@ -179,7 +179,7 @@ def updStatus(request):
           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
 
@@ -233,14 +233,14 @@ def getConfile(req):
       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:
index 34e9d5f1d90de80042056c7bd22854cbf3524d13..1a18ce3468f6cab4bc92610ea005165bf66c6d78 100644 (file)
@@ -58,9 +58,9 @@ class LaneFactory(DjangoModelFactory):
     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'
diff --git a/experiments/migrations/0004_rename_datarun_to_sequencingrun.py b/experiments/migrations/0004_rename_datarun_to_sequencingrun.py
new file mode 100644 (file)
index 0000000..15974fe
--- /dev/null
@@ -0,0 +1,16 @@
+# -*- 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'),
+    ]
index f84d0e5618b0cb4f9ee2af84dddcc0bb5ec517b9..ef21816f800af19b03c070927e851f863c64d3f4 100644 (file)
@@ -204,7 +204,7 @@ class FlowCell(models.Model):
 
         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:
@@ -219,17 +219,17 @@ class FlowCell(models.Model):
                 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" % (
@@ -264,16 +264,16 @@ class FlowCell(models.Model):
             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'),
@@ -314,7 +314,7 @@ class Lane(models.Model):
         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)
@@ -340,7 +340,7 @@ class DataRun(models.Model):
                 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
@@ -349,7 +349,7 @@ class DataRun(models.Model):
                 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
 
@@ -438,7 +438,7 @@ class DataFile(models.Model):
     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)
index f0cb470102ce3932bbfbe17fbec315a51f152202..d9d2960abe795ee1cfdbed795d2efd20daad6ddb 100644 (file)
     <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/>
index ebe2c59d261be2740b40ab5e6dc9e1c20e30ba7a..c5b560f5c1fa84bed35986bbb9add254a84e9ad3 100644 (file)
@@ -36,7 +36,7 @@
   {% 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>
@@ -50,7 +50,7 @@
          </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>
index ebbaf40cb24093276eef90ece9fe4d55bbe0e879..229f1476e781ba6ba860e2998b7aa33b5adf99cb 100644 (file)
@@ -15,7 +15,7 @@ from django.core.urlresolvers import reverse
 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
@@ -327,24 +327,24 @@ class ExperimentsTestCases(TestCase):
         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,
@@ -357,12 +357,12 @@ class ExperimentsTestCases(TestCase):
         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):
@@ -370,11 +370,11 @@ class ExperimentsTestCases(TestCase):
         """
         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)
index 2b6cc11c48b5f5da6bbb1c1b28f7a00202031eeb..85bb90d614a199eae713d184a676bd8eb754f680 100644 (file)
@@ -15,7 +15,7 @@ from django.shortcuts import render_to_response, get_object_or_404
 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, \
@@ -25,13 +25,13 @@ from samples.models import HTSUser
 
 
 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):
@@ -134,7 +134,7 @@ def finishedEmail(request, pk):
 
 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)
@@ -150,13 +150,13 @@ def flowcell_detail(request, flowcell_id, lane_number=None):
 
 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))
 
@@ -164,7 +164,7 @@ def flowcell_lane_detail(request, lane_pk):
                              {'lib': lane.library,
                               'lane': lane,
                               'flowcell': lane.flowcell,
-                              'filtered_dataruns': dataruns})
+                              'filtered_sequencingruns': sequencingruns})
 
     return render_to_response('experiments/flowcell_lane_detail.html',
                               context)