Skip to content

Commit

Permalink
Merge pull request #134 from HadrienG/1.4.5
Browse files Browse the repository at this point in the history
1.4.5
  • Loading branch information
HadrienG authored Nov 22, 2019
2 parents 9b65a3b + feca2b7 commit 6a9bca7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions iss/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def generate_reads(args):
if args.draft:
logger.warning('--draft is in early experimental stage.')
logger.warning(
'--draft disables --abundance_file and --coverage')
'disabling --abundance_file, --coverage and --n_genomes')
logger.warning('Defaulting to --abundance.')
genome_files.extend(args.draft)
if args.ncbi and args.n_genomes_ncbi:
Expand Down Expand Up @@ -124,13 +124,22 @@ def generate_reads(args):
genome_files,
output=genome_file)

# for n_genomes we use reservoir sampling to draw random genomes
# from the concatenated genome file. We then override the file.
if args.n_genomes and not args.draft and not args.ncbi:
genome_count = util.count_records(genome_file)
genome_files = [genome for genome in util.reservoir(
SeqIO.parse(genome_file, 'fasta'),
genome_count,
args.n_genomes)]
SeqIO.write(genome_files, genome_file, 'fasta')

assert os.stat(genome_file).st_size != 0
f = open(genome_file, 'r')
with f: # count the number of records
genome_list = util.count_records(f)
except IOError as e:
logger.error('Failed to open genome(s) file:%s' % e)
raise
sys.exit(1)
except AssertionError as e:
logger.error('Genome(s) file seems empty: %s' % genome_file)
Expand Down Expand Up @@ -182,11 +191,8 @@ def generate_reads(args):
f = open(genome_file, 'r') # re-opens the file
with f:
fasta_file = SeqIO.parse(f, 'fasta')
if args.n_genomes and not args.ncbi:
n = args.n_genomes[0][0]
else:
n = None
for record in util.reservoir(fasta_file, genome_list, n):

for record in fasta_file:
# generate reads for records
try:
species_abundance = abundance_dic[record.id]
Expand Down Expand Up @@ -391,7 +397,6 @@ def main():
'--n_genomes',
'-u',
type=int,
action='append',
metavar='<int>',
help='How many genomes will be used for the simulation. is set with \
--genomes/-g or/and --draft to take random genomes from the \
Expand Down Expand Up @@ -545,4 +550,4 @@ def main():
logger = logging.getLogger(__name__)
logger.debug(e)
parser.print_help()
# raise # extra traceback to uncomment if all hell breaks lose
raise # extra traceback to uncomment if all hell breaks lose
2 changes: 1 addition & 1 deletion iss/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.4'
__version__ = '1.4.5'

0 comments on commit 6a9bca7

Please sign in to comment.