Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def unbinned(self, options):
"""Unbinned Command"""
check_dir_exists(options.genome_nt_dir)
genomes_files = self._genome_files(options.genome_nt_dir, options.genome_ext)
if not self._check_nuclotide_seqs(genomes_files):
self.logger.warning('All files must contain nucleotide sequences.')
sys.exit()
unbinned = Unbinned()
unbinned_seqs = unbinned.run(genomes_files, options.scaffold_file, options.min_seq_len)
seq_io.write_fasta(unbinned_seqs, options.output_file)
self.logger.info('Unbinned scaffolds written to: ' + options.output_file)
with open(outlier_file) as f:
f.readline()
for line in f:
if line[0] == '#':
continue
line_split = line.split('\t')
scaffold_id = line_split[0]
rtn = genome_seqs.pop(scaffold_id, None)
if rtn:
bModified = True
# save modified bin
if bModified or not modified_only:
seq_io.write_fasta(genome_seqs, out_genome)
if bin_id == cur_bin_id:
scaffold_ids.add(scaffold_id)
# add compatible sequences to genome
added_seqs = 0
genome_seqs = seq_io.read(genome_file)
for seq_id, seq in seq_io.read_seq(scaffold_file):
if seq_id in scaffold_ids:
if len(seq) >= min_len:
genome_seqs[seq_id] = seq
added_seqs += 1
self.logger.info('Added {:,} scaffolds meeting length criterion.'.format(added_seqs))
# save modified bin
seq_io.write_fasta(genome_seqs, out_genome)
self.logger.info('Identified {:,} compatible scaffolds.'.format(len(compatible_scaffolds)))
# add compatible sequences to genome
added_seqs = 0
genome_seqs = seq_io.read(genome_file)
for seq_id, seq in seq_io.read_seq(scaffold_file):
if seq_id in compatible_scaffolds:
if len(seq) >= min_len:
genome_seqs[seq_id] = seq
added_seqs += 1
self.logger.info('Added {:,} scaffolds meeting length criterion.'.format(added_seqs))
# save modified bin
seq_io.write_fasta(genome_seqs, out_genome)
self.logger.info('Identified {:,} compatible scaffolds.'.format(len(compatible_scaffolds)))
# add compatible sequences to genome
added_seqs = 0
genome_seqs = seq_io.read(genome_file)
for seq_id, seq in seq_io.read_seq(scaffold_file):
if seq_id in compatible_scaffolds:
if len(seq) >= min_len:
genome_seqs[seq_id] = seq
added_seqs += 1
self.logger.info('Added {:,} scaffolds meeting length criterion.'.format(added_seqs))
# save modified bin
seq_io.write_fasta(genome_seqs, out_genome)