* Added links in the library view to get access to "accessable" data.
If the data is not "accessable", no link will be provided.
--- /dev/null
+from gaworkflow.frontend import settings
+
+import glob
+import os
+import re
+
+s_paren = re.compile("^\w+")
+
+def get_flowcell_result_dict(flowcell_id):
+ """
+ returns a dictionary following the following pattern for
+ a given flowcell_id:
+
+
+ d['C1-33']['summary'] = #Summary.htm file path
+ d['C1-33']['eland_results'][5] # C1-33 lane 5 file eland results file path
+ """
+
+ flowcell_id = flowcell_id.strip()
+
+ d = {}
+
+ ################################
+ # Flowcell Directory
+ fc_dir = glob.glob(os.path.join(settings.RESULT_HOME_DIR, flowcell_id))
+
+ # Not found
+ if len(fc_dir) == 0:
+ return None
+
+ # No duplicates!
+ assert len(fc_dir) <= 1
+
+ # Found fc dir
+ fc_dir = fc_dir[0]
+
+ ################################
+ # C#-## dirs
+ c_dir_list = glob.glob(os.path.join(fc_dir, 'C*'))
+
+ # Not found
+ if len(c_dir_list) == 0:
+ return d
+
+ for c_dir_path in c_dir_list:
+ summary_file = glob.glob(os.path.join(c_dir_path, 'Summary.htm'))
+ pathdir, c_dir = os.path.split(c_dir_path)
+
+ # Create sub-dictionary
+ d[c_dir] = {}
+
+
+ ###############################
+ # Summary.htm file
+
+ # Not found
+ if len(summary_file) == 0:
+ d[c_dir]['summary'] = None
+
+ # Found
+ else:
+ # No duplicates!
+ assert len(summary_file) == 1
+
+ summary_file = summary_file[0]
+ d[c_dir]['summary'] = summary_file
+
+ ###############################
+ # Result files
+
+ d[c_dir]['eland_results'] = {}
+
+ result_filepaths = glob.glob(os.path.join(c_dir_path, 's_*_eland_result.txt*'))
+
+ for filepath in result_filepaths:
+
+ junk, result_name = os.path.split(filepath)
+
+ #lanes 1-8, single digit, therefore s_#; # == index 2
+ lane = int(result_name[2])
+ d[c_dir]['eland_results'][lane] = filepath
+
+ ###############################
+ # run*.xml file
+ run_xml_filepath = glob.glob(os.path.join(c_dir_path, 'run_*.xml'))
+
+ if len(run_xml_filepath) == 0:
+ d[c_dir]['run_xml'] = None
+ else:
+ # No duplicates
+ assert len(run_xml_filepath) == 1
+
+ d[c_dir]['run_xml'] = run_xml_filepath[0]
+
+ ###############################
+ # scores.tar.gz
+ scores_filepath = glob.glob(os.path.join(c_dir_path, 'scores*'))
+
+ if len(scores_filepath) == 0:
+ d[c_dir]['scores'] = None
+ else:
+ # No duplicates
+ assert len(scores_filepath) == 1
+
+ d[c_dir]['scores'] = scores_filepath[0]
+
+ return d
+
+
+def cn_mTobp(cn_m):
+ """
+ Converts CN-M (i.e. C1-33, C1-26, C4-28) cycle information into
+ number of base pairs.
+ """
+ pass
+
+
+def flowcellIdStrip(flowcell_id):
+ """
+ Removes (<words>) from flowcell id
+ """
+ mo = s_paren.search(flowcell_id)
+
+ if mo:
+ return flowcell_id[mo.start():mo.end()]
+ else:
+ return flowcell_id
+
\ No newline at end of file
# Create your views here.
from gaworkflow.frontend.fctracker.models import Library
+from gaworkflow.frontend.fctracker.results import get_flowcell_result_dict, flowcellIdStrip
+from gaworkflow.util import opener
from django.http import HttpResponse
#from django.db.models import base
output.append('<b>FLOWCELL - LANE:</b>')
- output.extend([ '%s - Lane 1' % (fc.flowcell_id) for fc in lib.lane_1_library.all() ])
- output.extend([ '%s - Lane 2' % (fc.flowcell_id) for fc in lib.lane_2_library.all() ])
- output.extend([ '%s - Lane 3' % (fc.flowcell_id) for fc in lib.lane_3_library.all() ])
- output.extend([ '%s - Lane 4' % (fc.flowcell_id) for fc in lib.lane_4_library.all() ])
- output.extend([ '%s - Lane 5' % (fc.flowcell_id) for fc in lib.lane_5_library.all() ])
- output.extend([ '%s - Lane 6' % (fc.flowcell_id) for fc in lib.lane_6_library.all() ])
- output.extend([ '%s - Lane 7' % (fc.flowcell_id) for fc in lib.lane_7_library.all() ])
- output.extend([ '%s - Lane 8' % (fc.flowcell_id) for fc in lib.lane_8_library.all() ])
+ output.extend([ '%s - Lane 1 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 1)) for fc in lib.lane_1_library.all() ])
+ output.extend([ '%s - Lane 2 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 2)) for fc in lib.lane_2_library.all() ])
+ output.extend([ '%s - Lane 3 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 3)) for fc in lib.lane_3_library.all() ])
+ output.extend([ '%s - Lane 4 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 4)) for fc in lib.lane_4_library.all() ])
+ output.extend([ '%s - Lane 5 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 5)) for fc in lib.lane_5_library.all() ])
+ output.extend([ '%s - Lane 6 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 6)) for fc in lib.lane_6_library.all() ])
+ output.extend([ '%s - Lane 7 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 7)) for fc in lib.lane_7_library.all() ])
+ output.extend([ '%s - Lane 8 %s' % (fc.flowcell_id, _files(fc.flowcell_id, 8)) for fc in lib.lane_8_library.all() ])
record_count = lib.lane_1_library.count() + \
lib.lane_2_library.count() + \
output.append("None Found")
return HttpResponse('<br />\n'.join(output))
+
+
+def result_fc_cnm_eland_lane(request, fc_id, cnm, lane):
+ """
+ returns an eland_file upon calling.
+ """
+ fc_id = flowcellIdStrip(fc_id)
+ d = get_flowcell_result_dict(fc_id)
+
+ if d is None:
+ return HttpResponse('<b>Results for Flowcell %s not found.' % (fc_id))
+
+ if cnm not in d:
+ return HttpResponse('<b>Results for Flowcell %s; %s not found.' % (fc_id, cnm))
+
+ erd = d[cnm]['eland_results']
+ lane = int(lane)
+
+ if lane not in erd:
+ return HttpResponse('<b>Results for Flowcell %s; %s; lane %s not found.' % (fc_id, cnm, lane))
+
+ filepath = erd[lane]
+
+ f = opener.autoopen(filepath, 'r')
+
+ return HttpResponse(f)
+
+
+def _files(flowcell_id, lane):
+ """
+ Sets up available files for download
+ """
+ flowcell_id = flowcellIdStrip(flowcell_id)
+ d = get_flowcell_result_dict(flowcell_id)
+
+ if d is None:
+ return ''
+
+ output = []
+
+ # c_name == 'CN-M' (i.e. C1-33)
+ for c_name in d:
+ erd = d[c_name]['eland_results']
+
+ if int(lane) in erd:
+ output.append('<a href="/results/%s/%s/eland_result/%s">eland_result(%s)</a>' % (flowcell_id, c_name, lane, c_name))
+
+ if len(output) == 0:
+ return ''
+
+ return '(' + '|'.join(output) + ')'
+
\ No newline at end of file
UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')
UPLOADTO_BED_PACKS = os.path.join(UPLOADTO_HOME, 'bed_packs')
+RESULT_HOME_DIR = os.path.abspath('../../results')
# Databrowser:
from django.contrib import databrowse
from fctracker.models import Library, FlowCell
-databrowse.site.register(Library)
-databrowse.site.register(FlowCell)
+#databrowse.site.register(Library)
+#databrowse.site.register(FlowCell)
urlpatterns = patterns('',
# Base:
# Admin:
(r'^admin/', include('django.contrib.admin.urls')),
# Databrowser:
- (r'^databrowse/(.*)', databrowse.site.root),
+ #(r'^databrowse/(.*)', databrowse.site.root),
(r'^library/$', 'gaworkflow.frontend.fctracker.views.library'),
- (r'^library/(?P<lib_id>\w+)/$', 'gaworkflow.frontend.fctracker.views.library_to_flowcells')
+ (r'^library/(?P<lib_id>\w+)/$', 'gaworkflow.frontend.fctracker.views.library_to_flowcells'),
+ (r'^results/(?P<fc_id>\w+)/(?P<cnm>C[1-9]-[0-9]+)/eland_result/(?P<lane>[1-8])','gaworkflow.frontend.fctracker.views.result_fc_cnm_eland_lane')
)