thtools.fasta.FParser¶
- class thtools.fasta.FParser(text)¶
A basic FASTA parser with miRBase built in.
Extracts main FASTA sub-components. Supports slice syntax and summation.
- Parameters
- textstr
The FASTA text to parse.
Notes
Upon instantiation, the
textattribute is formatted using theformat()method.Examples
>>> import thtools as tt >>> ths = "UUAGCCGCUGUCACACGCACAGGGAUUUACAAAAAGAGGAGAGUAAAAUGCUGUGCGUGCACCAUAAAACGAACAUAGAC" >>> rbs = "AGAGGAGA" >>> fasta = tt.FParser.fromspecies("Homo sapiens")[295:305] # slice a small chunk of the database >>> triggers = fasta.seqs >>> trigger_names = fasta.ids >>> my_test = tt.autoconfig(ths, rbs, triggers, names=trigger_names) >>> my_result = my_test.run(max_size=3, n_samples=100) >>> my_result.specificity 0.9999981076197236
- Attributes
- idsList[str]
- seqsList[str]
- headersList[str]
- descriptionsList[str]
- numint
- textstr
- sourceset, defaults to set()
- line_lengthint, defaults to 70
- copy()¶
Implement copy protocol.
- Returns
- FParser
A copy of self.
- format(line_length=70)¶
Format the text of a FASTA to be a certain line length in each sequence.
- Parameters
- linelengthint, default=FParser.line_length
The max length of each sequence line.
- Returns
- str
The formatted text of the FParser object.
- classmethod fromregistry(part=None, parts=None, retries=0)¶
Create a
FParserinstance from a part or list of parts in the Registry of Standard Biological Parts.- Parameters
- partstr, optional
- partsCollection[str], optional
- retriesint, default=0
- Returns
- FParser | list[FParser]
- Raises
- ValueError
If neither part nor parts is supplied.
- classmethod fromspecies(species)¶
Create a
FParserinstance based on the miRNAs in miRBase.Full species list available via
FParser.specieslist.- Parameters
- speciesstr
- Returns
- FParser
- index(key)¶
Get the index of a key in IDs, sequences, descriptions or headers.