Rename sequence IDs across many sequence files at once.
Example
Section titled “Example”Set the input with input_dir or input_files, then call a renaming method.
import pysegul
def rename_sequences(): rename = pysegul.SequenceRenaming( input_fmt='nexus', datatype='dna', output_path='tests/output', output_format='fasta', ) rename.input_dir = 'tests/align-data' rename.replace_id([('seq1', 'Rattus_rattus'), ('seq2', 'Mus_musculus')])Options
Section titled “Options”| Option | Default | Description |
|---|---|---|
input_fmt | Required | 'auto', 'fasta', 'nexus', 'phylip' |
datatype | Required | 'dna', 'aa', 'ignore' |
output_path | Required | Output directory |
output_format | Required | 'fasta', 'nexus', 'phylip', or interleaved 'fasta-int', 'nexus-int', 'phylip-int' |
dry_run | False | Log the new IDs without writing any files |
| Attribute | Description |
|---|---|
input_dir | Directory of input sequence files |
input_files | List of input sequence files |
Methods
Section titled “Methods”Regular expressions follow the Rust regex syntax.
| Method | Description |
|---|---|
replace_id(names) | Replace IDs using a list of (original ID, new ID) pairs |
replace_id_from_file(path) | Replace IDs using a CSV or TSV file with a header row and two columns: original ID and new ID |
remove_string(input_str) | Remove a string from the IDs |
remove_regex(regex, all=False) | Remove the first regex match, or every match with all=True |
replace_string(from_, to) | Replace a string in the IDs |
replace_regex(regex, to, all=False) | Replace the first regex match, or every match with all=True |
rename.remove_regex(r'_\d+$')rename.replace_string('Rattus', 'R')