12
12
import pandas as pd
13
13
from json import dumps
14
14
from random import randint
15
- from itertools import zip_longest
15
+
16
+ try :
17
+ from itertools import zip_longest
18
+ except ImportError :
19
+ from itertools import izip_longest as zip_longest
20
+
16
21
from os .path import basename
17
22
18
23
from .exceptions import (QiitaClientError , NotFoundError , BadRequestError ,
@@ -590,8 +595,9 @@ def artifact_and_preparation_files(self, artifact_id,
590
595
591
596
if artifact_info ['analysis' ] is not None :
592
597
raise RuntimeError (
593
- f'Artifact { artifact_id } is an analysis artifact, this method '
594
- 'is meant to work with artifacts linked to a preparation.' )
598
+ 'Artifact ' + str (artifact_id ) + ' is an analysis artifact, '
599
+ 'this method is meant to work with artifacts linked to '
600
+ 'a preparation.' )
595
601
596
602
prep_info = self .get ('/qiita_db/prep_template/%s/'
597
603
% artifact_info ['prep_information' ][0 ])
@@ -615,8 +621,9 @@ def _process_files_per_sample_fastq(self, files, prep_info,
615
621
revs = sorted (
616
622
files ['raw_reverse_seqs' ], key = lambda x : x ['filepath' ])
617
623
if len (fwds ) != len (revs ):
618
- raise ValueError (f'The fwd ({ len (fwds )} ) and rev ({ len (revs )} )'
619
- ' files should be of the same length' )
624
+ raise ValueError ('The fwd (' + str (len (fwds )) + ') and rev ('
625
+ + str (len (revs )) + ') files should be of the '
626
+ 'same length' )
620
627
621
628
run_prefixes = prep_info ['run_prefix' ].to_dict ()
622
629
@@ -635,15 +642,15 @@ def _process_files_per_sample_fastq(self, files, prep_info,
635
642
run_prefix = rp
636
643
sample_name = sn
637
644
elif fwd_fn .startswith (rp ) and run_prefix is not None :
638
- raise ValueError (
639
- f'Multiple run prefixes match this fwd read: { fwd_fn } ' )
645
+ raise ValueError ('Multiple run prefixes match this fwd '
646
+ ' read: %s' % fwd_fn )
640
647
641
648
if run_prefix is None :
642
649
raise ValueError (
643
- f 'No run prefix matching this fwd read: { fwd_fn } ' )
650
+ 'No run prefix matching this fwd read: %s' % fwd_fn )
644
651
if run_prefix in used_prefixes :
645
652
raise ValueError (
646
- f 'Run prefix matches multiple fwd reads: { run_prefix } ' )
653
+ 'Run prefix matches multiple fwd reads: %s' % run_prefix )
647
654
used_prefixes .append (run_prefix )
648
655
649
656
if rev is not None :
@@ -655,7 +662,7 @@ def _process_files_per_sample_fastq(self, files, prep_info,
655
662
if not rev_fn .startswith (run_prefix ):
656
663
raise ValueError (
657
664
'Reverse read does not match run prefix. run_prefix: '
658
- f' { run_prefix } ; files: { fwd_fn } / { rev_fn } ' )
665
+ '%s ; files: %s / %s' ) % ( run_prefix , fwd_fn , rev_fn )
659
666
660
667
used_prefixes .append (run_prefix )
661
668
0 commit comments