@@ -677,6 +677,28 @@ def setUp(self):
677
677
678
678
self ._clean_up_files = [self .fp1 , self .fp2 , self .fp3 , self .fp4 ]
679
679
680
+ # per_sample_FASTQ Metagenomic example
681
+
682
+ self .prep_template_per_sample_fastq = \
683
+ qdb .metadata_template .prep_template .PrepTemplate .create (
684
+ metadata , qdb .study .Study (1 ), "Metagenomic" )
685
+ fd , self .fwd = mkstemp (prefix = 'SKB8.640193' , suffix = '_R1.fastq' )
686
+ close (fd )
687
+ with open (self .fwd , 'w' ) as f :
688
+ f .write ("@HWI-ST753:189:D1385ACXX:1:1101:1214:1906 1:N:0:\n "
689
+ "NACGTAGGGTGCAAGCGTTGTCCGGAATNA\n "
690
+ "+\n "
691
+ "#1=DDFFFHHHHHJJJJJJJJJJJJGII#0\n " )
692
+ fd , self .rev = mkstemp (prefix = 'SKB8.640193' , suffix = '_R2.fastq' )
693
+ close (fd )
694
+ with open (self .rev , 'w' ) as f :
695
+ f .write ("@HWI-ST753:189:D1385ACXX:1:1101:1214:1906 1:N:0:\n "
696
+ "NACGTAGGGTGCAAGCGTTGTCCGGAATNA\n "
697
+ "+\n "
698
+ "#1=DDFFFHHHHHJJJJJJJJJJJJGII#0\n " )
699
+
700
+ self ._clean_up_files .extend ([self .fwd , self .rev ])
701
+
680
702
def tearDown (self ):
681
703
for f in self ._clean_up_files :
682
704
if exists (f ):
@@ -1364,6 +1386,26 @@ def test_descendants_with_jobs_one_element(self):
1364
1386
exp = [('artifact' , artifact )]
1365
1387
self .assertCountEqual (obs , exp )
1366
1388
1389
+ def test_has_human (self ):
1390
+ # testing a FASTQ artifact (1), should be False
1391
+ self .assertFalse (qdb .artifact .Artifact (1 ).has_human )
1392
+
1393
+ # create a per_sample_FASTQ
1394
+ artifact = qdb .artifact .Artifact .create (
1395
+ [(self .fwd , 1 ), (self .rev , 2 )], "per_sample_FASTQ" ,
1396
+ prep_template = self .prep_template_per_sample_fastq )
1397
+
1398
+ # this should be False as there are no human samples
1399
+ self .assertFalse (artifact .has_human )
1400
+
1401
+ # let's make it True by making the samle human-*
1402
+ df = pd .DataFrame .from_dict (
1403
+ {'1.SKB8.640193' : {'env_package' : 'human-oral' }},
1404
+ orient = 'index' , dtype = str )
1405
+ artifact .study .sample_template .update (df )
1406
+
1407
+ self .assertTrue (artifact .has_human )
1408
+
1367
1409
1368
1410
@qiita_test_checker ()
1369
1411
class ArtifactArchiveTests (TestCase ):
0 commit comments