Commit 50d49cf8 authored by Laros's avatar Laros
Browse files

Added library usage examples.

parent b5998bc6
......@@ -69,3 +69,40 @@ Additionally, a good set of barcodes can be extracted by providing an output
file via the `-o` option:
barcode test -o good_barcodes.txt barcodes.txt
## Library usage
Barcode design via the library is done in three steps. First obtain the full
set of permutations with the `all_barcodes` function:
```python
>>> from backtranslate import all_barcodes, filter_distance, filter_stretches
>>>
>>> # Generate all barcodes of length 2.
>>> all_barcodes(2)
['AA', 'AC', 'AG', 'AT', 'CA', 'CC', 'CG', 'CT', 'GA', 'GC', 'GG', 'GT', 'TA',
'TC', 'TG', 'TT']
```
The resulting list can be filtered with the `filter_distance` and
`filter_stretches` functions:
```python
>>> # Filter all barcodes of length 3 for a minimal edit distance of 3.
>>> filter_distance(all_barcodes(3), 3)
['AAA', 'CCC', 'GGG', 'TTT']
>>>
>>> # Filter all barcodes of lenght 2 for mononucleotide stretches of length
>>> # longer than 1.
>>> filter_stretches(all_barcodes(2), 1)
['AC', 'AG', 'AT', 'CA', 'CG', 'CT', 'GA', 'GC', 'GT', 'TA', 'TC', 'TG']
```
For the best result, apply the `filter_stretches` function before applying the
`filter_distance` function:
```python
>>> # Make a set of barcodes of length 3, having no mononucleotide stretches
>>> # and a minimum edit distance of 3.
>>> filter_distance(filter_stretches(all_barcodes(3), 1), 3)
['ACA', 'CGC', 'GAG']
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment