diff --git a/bin/split_fasta.py b/bin/split_fasta.py index d85b394..dbec63f 100755 --- a/bin/split_fasta.py +++ b/bin/split_fasta.py @@ -36,11 +36,11 @@ def log(string, newline_before=False): if line.startswith('>'): # new sequence - seq_name = line.strip().split()[0][1:] + seq_name = line.strip()[1:] assert seq_name != '', f'Empty header in file: {fasta_file}' # sanitize - seq_name = seq_name.replace('/', '_').replace(':', '_').replace('|','_') + seq_name = seq_name.replace(' ', '_').replace('/', '_').replace(':', '_').replace('|','_') # handle duplicates if seq_name in sequence_names: @@ -59,7 +59,10 @@ def log(string, newline_before=False): log(f'Writing {outfile}') outfh = open(outfile, 'w') outfh.write(f'>{seq_name}\n') - + + elif line in ['\n','\r\n']: + continue + else: # write rest of lines (and fix windows line endings) outfh.write(line.replace('\r',''))