Extract sequences by sequence ID, using a regular expression, a list of IDs, or a file of IDs.
Example
Section titled “Example”Set the input with input_dir or input_files, then call an extraction method.
import pysegul
def extract_sequences(): extract = pysegul.SequenceExtraction( input_fmt='nexus', datatype='dna', output_path='tests/output', output_format='fasta', ) extract.input_dir = 'tests/align-data' # Or use a list of files: # extract.input_files = ['tests/align-data/alignment1.nex'] extract.extract_regex('(?i)^(abce)')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' |
| Attribute | Description |
|---|---|
input_dir | Directory of input sequence files |
input_files | List of input sequence files |
Methods
Section titled “Methods”| Method | Extract sequences |
|---|---|
extract_regex(regex) | whose IDs match a regular expression (Rust regex syntax) |
extract_id_list(list) | with the IDs in a list, e.g. ['abce1', 'abce2'] |
extract_id_file(path) (beta) | with the IDs in a text file, one per line. A missing file raises a FileNotFoundError |