@@ -28,6 +28,9 @@ class TestEBISubmission(TestCase):
2828 def setUp (self ):
2929 self .path = path .dirname (path .abspath (__file__ )) + \
3030 '/test_data/test_ebi'
31+ self .sample1_fp = join (self .path , 'sample1.fastq.gz' )
32+ self .sample2_fp = join (self .path , 'sample2.fastq.gz' )
33+ self .sample3_fp = join (self .path , 'sample3.fastq.gz' )
3134 self .temp_dir = gettempdir ()
3235
3336 def test_init (self ):
@@ -193,15 +196,18 @@ def test_add_sample_prep(self):
193196 new_investigation_type = 'metagenome' )
194197 submission .add_sample ('test1' )
195198 submission .add_sample ('test2' )
199+
196200 submission .add_sample_prep ('test1' , 'ILLUMINA' , 'fastq' ,
197- self .path , 'experiment description' ,
201+ self .sample1_fp , 'experiment description' ,
198202 'library protocol' )
203+
199204 prep_info = submission .samples ['test1' ]['prep' ]
200205 self .assertEqual (prep_info ['platform' ], 'ILLUMINA' )
201- self .assertEqual (prep_info ['file_path' ], self .path )
206+ self .assertEqual (prep_info ['file_path' ], self .sample1_fp )
202207 with self .assertRaises (KeyError ):
203208 submission .add_sample_prep ('test3' , 'ILLUMINA' , 'fastq' ,
204- self .path , 'experiment description' ,
209+ self .sample3_fp ,
210+ 'experiment description' ,
205211 'library protocol' )
206212
207213 def test_add_sample_prep_exception (self ):
@@ -212,11 +218,13 @@ def test_add_sample_prep_exception(self):
212218 submission .add_sample ('test2' )
213219 with self .assertRaises (ValueError ):
214220 submission .add_sample_prep ('test2' , 'DOES-NOT-EXIST' , 'fastq' ,
215- self .path , 'experiment description' ,
221+ self .sample1_fp ,
222+ 'experiment description' ,
216223 'library protocol' )
217224 with self .assertRaises (KeyError ):
218225 submission .add_sample_prep ('test3' , 'DOES-NOT-EXIST' , 'fastq' ,
219- self .path , 'experiment description' ,
226+ self .sample3_fp ,
227+ 'experiment description' ,
220228 'library protocol' )
221229
222230 def test_generate_library_descriptor (self ):
@@ -247,14 +255,17 @@ def test_generate_experiment_xml(self):
247255 new_investigation_type = 'metagenome' )
248256 submission .add_sample ('test1' )
249257 submission .add_sample_prep ('test1' , 'ILLUMINA' , 'fastq' ,
250- 'fakepath' ,
258+ self . sample1_fp ,
251259 'experiment description' ,
252260 'library protocol' )
253261 xmlelement = submission .generate_experiment_xml ()
254262 xml = minidom .parseString (ET .tostring (xmlelement ))
255263 xmlstring = xml .toprettyxml (indent = ' ' , encoding = 'UTF-8' )
256264 obs_stripped = '' .join ([l .strip () for l in xmlstring .splitlines ()])
257- exp_stripped = '' .join ([l .strip () for l in EXPERIMENTXML .splitlines ()])
265+ exp = EXPERIMENTXML % {
266+ 'path' : self .sample1_fp ,
267+ 'organization_prefix' : qiita_config .ebi_organization_prefix }
268+ exp_stripped = '' .join ([l .strip () for l in exp .splitlines ()])
258269 self .assertEqual (obs_stripped , exp_stripped )
259270
260271 def test_generate_run_xml (self ):
@@ -263,7 +274,7 @@ def test_generate_run_xml(self):
263274 new_investigation_type = 'metagenome' )
264275 submission .add_sample ('test1' )
265276 submission .add_sample_prep ('test1' , 'ILLUMINA' , 'fastq' ,
266- join ( self .path , '__init__.py' ) ,
277+ self .sample1_fp ,
267278 'experiment description' ,
268279 'library protocol' )
269280 xmlelement = submission .generate_run_xml ()
@@ -338,13 +349,16 @@ def test_write_experiment_xml(self):
338349 new_investigation_type = 'metagenome' )
339350 submission .add_sample ('test1' )
340351 submission .add_sample_prep ('test1' , 'ILLUMINA' , 'fastq' ,
341- 'fakepath' , 'experiment description' ,
352+ self . sample1_fp , 'experiment description' ,
342353 'library protocol' )
343354 fh , output = mkstemp ()
344355 close (fh )
345356 submission .write_experiment_xml (output )
346357 obs_stripped = '' .join ([l .strip () for l in open (output )])
347- exp_stripped = '' .join ([l .strip () for l in EXPERIMENTXML .splitlines ()])
358+ exp = EXPERIMENTXML % {
359+ 'path' : self .sample1_fp ,
360+ 'organization_prefix' : qiita_config .ebi_organization_prefix }
361+ exp_stripped = '' .join ([l .strip () for l in exp .splitlines ()])
348362 self .assertEqual (obs_stripped , exp_stripped )
349363 remove (output )
350364
@@ -363,7 +377,7 @@ def test_add_samples_from_templates(self):
363377 'ILLUMINA' )
364378 self .assertEqual (
365379 submission .samples ['sample2' ]['prep' ]['file_path' ],
366- self .path + '/sample2.fastq.gz' )
380+ self .sample2_fp )
367381 with self .assertRaises (KeyError ):
368382 submission .samples ['nothere' ]
369383
@@ -388,7 +402,7 @@ def test_from_templates_and_per_sample_fastqs(self):
388402 'ILLUMINA' )
389403 self .assertEqual (
390404 submission .samples ['sample2' ]['prep' ]['file_path' ],
391- self .path + '/sample2.fastq.gz' )
405+ self .sample2_fp )
392406 with self .assertRaises (KeyError ):
393407 submission .samples ['nothere' ]
394408
@@ -553,7 +567,7 @@ def test_generate_curl_command(self):
553567 </EXPERIMENT_ATTRIBUTE>
554568 <EXPERIMENT_ATTRIBUTE>
555569 <TAG>file_path</TAG>
556- <VALUE>fakepath </VALUE>
570+ <VALUE>%(path)s </VALUE>
557571 </EXPERIMENT_ATTRIBUTE>
558572 <EXPERIMENT_ATTRIBUTE>
559573 <TAG>file_type</TAG>
@@ -563,25 +577,29 @@ def test_generate_curl_command(self):
563577 <TAG>library_construction_protocol</TAG>
564578 <VALUE>library protocol</VALUE>
565579 </EXPERIMENT_ATTRIBUTE>
580+ <EXPERIMENT_ATTRIBUTE>
581+ <TAG>md5</TAG>
582+ <VALUE>506d31c82999a2cbcda138a369955e7d</VALUE>
583+ </EXPERIMENT_ATTRIBUTE>
566584 <EXPERIMENT_ATTRIBUTE>
567585 <TAG>platform</TAG>
568586 <VALUE>ILLUMINA</VALUE>
569587 </EXPERIMENT_ATTRIBUTE>
570588 </EXPERIMENT_ATTRIBUTES>
571589 </EXPERIMENT>
572590</EXPERIMENT_SET>
573- """ % { 'organization_prefix' : qiita_config . ebi_organization_prefix }
591+ """
574592
575593RUNXML = """
576594<?xml version="1.0" encoding="UTF-8"?>
577595<RUN_SET xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:no\
578596 NamespaceSchemaLocation="ftp://ftp.sra.ebi.ac.uk/meta/xsd/sra_1_3/SRA.run.xsd">
579- <RUN alias="%(study_alias)s___init__.py_run " center_name="CCME-COLORADO">
597+ <RUN alias="%(study_alias)s_sample1.fastq.gz_run " center_name="CCME-COLORADO">
580598 <EXPERIMENT_REF refname="%(organization_prefix)s_ppdid_001:test1"/>
581599 <DATA_BLOCK>
582600 <FILES>
583- <FILE checksum="612cbff13a4f0e236e5e62ac2e00329a " checksum_method=\
584- "MD5" filename="%(ebi_dir)s/__init__.py " filetype="fastq" \
601+ <FILE checksum="506d31c82999a2cbcda138a369955e7d " checksum_method=\
602+ "MD5" filename="%(ebi_dir)s/sample1.fastq.gz " filetype="fastq" \
585603 quality_scoring_system="phred"/>
586604 </FILES>
587605 </DATA_BLOCK>
0 commit comments