Skip to content

Commit 8e42f7d

Browse files
committed
ENH: reproin - consider all accessions (not assume there is 1) in fix_canceled_runs
Since we now have -g all at heudiconv level, we might get files / seqinfos from multiple accessions. So the code should be robust to that use case.
1 parent 8866cc5 commit 8e42f7d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

heudiconv/heuristics/reproin.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,17 @@ def get_study_hash(seqinfo):
381381
def fix_canceled_runs(seqinfo):
382382
"""Function that adds cancelme_ to known bad runs which were forgotten
383383
"""
384-
accession_number = get_unique(seqinfo, 'accession_number')
385-
if accession_number in fix_accession2run:
386-
lgr.info("Considering some runs possibly marked to be "
387-
"canceled for accession %s", accession_number)
388-
badruns = fix_accession2run[accession_number]
389-
badruns_pattern = '|'.join(badruns)
390-
for i, s in enumerate(seqinfo):
384+
if not fix_accession2run:
385+
return seqinfo # nothing to do
386+
for i, s in enumerate(seqinfo):
387+
accession_number = getattr(s, 'accession_number')
388+
if accession_number and accession_number in fix_accession2run:
389+
lgr.info("Considering some runs possibly marked to be "
390+
"canceled for accession %s", accession_number)
391+
# This code is reminiscent of prior logic when operating on
392+
# a single accession, but left as is for now
393+
badruns = fix_accession2run[accession_number]
394+
badruns_pattern = '|'.join(badruns)
391395
if re.match(badruns_pattern, s.series_id):
392396
lgr.info('Fixing bad run {0}'.format(s.series_id))
393397
fixedkwargs = dict()

0 commit comments

Comments
 (0)