Merge branch 'master' of mus.cacr.caltech.edu:htsworkflow
[htsworkflow.git] / htsworkflow / pipelines / test / test_retrive_config.py
1 import os
2 import re
3
4 try:
5     import json
6 except ImportError, e:
7     import simplejson as json
8     
9 from django.test import TestCase
10
11 from htsworkflow.frontend.auth import apidata
12 from htsworkflow.pipelines.retrieve_config import format_gerald_config, getCombinedOptions
13
14 class RetrieveTestCases(TestCase):
15     fixtures = ['test_flowcells.json']
16
17     def setUp(self):
18         pass
19
20     def test_format_gerald(self):
21         flowcell_request = self.client.get('/experiments/config/FC12150/json', apidata)
22         self.failUnlessEqual(flowcell_request.status_code, 200)
23
24         print dir(flowcell_request)
25         flowcell_info = json.loads(flowcell_request.content)
26
27         options = getCombinedOptions(['-f','FC12150','-g',os.getcwd()])        
28         genome_map = {u'Homo sapiens': '/tmp/hg18' }
29         
30         config = format_gerald_config(options, flowcell_info, genome_map)
31         config_lines = config.split('\n')
32         lane3 = [ line for line in config_lines if re.search('Lane3', line) ]
33         self.failUnlessEqual(len(lane3), 1)
34         self.failUnlessEqual(lane3[0], '# Lane3: SL039 | Paired ends 99 GM12892')
35         human = [ line for line in config_lines if re.search('hg18', line) ]
36         self.failUnlessEqual(len(human), 1)
37         self.failUnlessEqual(human[0], '345678:ELAND_GENOME /tmp/hg18')
38         # we changed the api to force unknown genomes to be sequencing
39         sequencing = [ line for line in config_lines if re.search('sequence_pair', line) ]
40         self.failUnlessEqual(len(sequencing), 2)
41
42                   
43
44         
45