from django.db.models.signals import post_init
from htsworkflow.frontend.samples.models import Library
-from htsworkflow.frontend.samples.results import parse_flowcell_id
+from htsworkflow.util.conversion import parse_flowcell_id
from htsworkflow.pipelines import runfolder
+logger = logging.getLogger(__name__)
default_pM = 5
try:
default_pM = int(settings.DEFAULT_PM)
except ValueError,e:
- logging.error("invalid value for frontend.default_pm")
+ logger.error("invalid value for frontend.default_pm")
RUN_STATUS_CHOICES = (
(0, 'Sequencer running'), ##Solexa Data Pipeline Not Yet Started'),
@models.permalink
def get_absolute_url(self):
+ flowcell_id, status = parse_flowcell_id(self.flowcell_id)
return ('htsworkflow.frontend.experiments.views.flowcell_detail',
- [str(self.flowcell_id)])
+ [str(flowcell_id)])
def get_raw_data_directory(self):
"""Return location of where the raw data is stored"""
result_root = self.get_raw_data_directory()
if result_root is None:
return
-
+
result_home_dir = os.path.join(settings.RESULT_HOME_DIR,'')
run_xml_re = re.compile(glob.fnmatch.translate('run*.xml'))
run.cycle_start = run_xml_data.image_analysis.start
run.cycle_stop = run_xml_data.image_analysis.stop
run.run_start_time = run_xml_data.image_analysis.date
+
run.last_update_time = datetime.datetime.now()
run.save()
run.update_result_files()
+
# FIXME: should we automatically update dataruns?
# Or should we expect someone to call update_data_runs?
LANE_STATUS_MAP = dict((int(k),v) for k,v in LANE_STATUS_CODES )
LANE_STATUS_MAP[None] = "Unknown"
+def is_valid_lane(value):
+ if value >= 1 and value <= 8:
+ return True
+ else:
+ return False
+
class Lane(models.Model):
flowcell = models.ForeignKey(FlowCell)
- lane_number = models.IntegerField(choices=[(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8)])
+ lane_number = models.IntegerField()
library = models.ForeignKey(Library)
pM = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
cluster_estimate = models.IntegerField(blank=True, null=True)
@models.permalink
def get_absolute_url(self):
return ('htsworkflow.frontend.experiments.views.flowcell_lane_detail',
- [str(self.flowcell.flowcell_id), str(self.lane_number)])
+ [str(self.id)])
+
+ def __unicode__(self):
+ return self.flowcell.flowcell_id + ':' + unicode(self.lane_number)
-
### -----------------------
class DataRun(models.Model):
flowcell = models.ForeignKey(FlowCell,verbose_name="Flowcell Id")
def update_result_files(self):
abs_result_dir = get_absolute_pathname(self.result_dir)
-
+
for dirname, dirnames, filenames in os.walk(abs_result_dir):
for filename in filenames:
pathname = os.path.join(dirname, filename)
#return u"<FileType: %s>" % (self.name,)
return self.name
+def str_uuid():
+ """Helper function to set default UUID in DataFile"""
+ return str(uuid.uuid1())
class DataFile(models.Model):
"""Store map from random ID to filename"""
- random_key = models.CharField(max_length=16,
+ random_key = models.CharField(max_length=64,
db_index=True,
- default=uuid.uuid1)
+ default=str_uuid)
data_run = models.ForeignKey(DataRun, db_index=True)
library = models.ForeignKey(Library, db_index=True, null=True, blank=True)
file_type = models.ForeignKey(FileType)