semvec/pypi-packages huggingface dataset:
olha 0.1.2
Fast generation of TCR/BCR sequences with olga
License: MIT

# olha
A package to generate TCR/BCR sequences fast, based on [olga](https://github.com/statbiophys/OLGA). Use the same syntax as olga but is up to 20x faster and can optionally generate non-functional sequences and include point-mutation "sequencing" errors. It also allows for selection of specific V/J pairs for generation. 

Written in C++, interface with python3 via pybind11.

## Installation

```sh
pip install olha
```


## Example

```py
import olga
import olga.sequence_generation
import olga.load_model
import olha

## olga model loading
params_file_name = f'{olga.__path__[0]}/default_models/human_T_beta/model_params.txt'
marginals_file_name = f'{olga.__path__[0]}/default_models/human_T_beta/model_marginals.txt'
V_anchor_pos_file =f'{olga.__path__[0]}/default_models/human_T_beta/V_gene_CDR3_anchors.csv'
J_anchor_pos_file = f'{olga.__path__[0]}/default_models/human_T_beta/J_gene_CDR3_anchors.csv'

genomic_data = olga.load_model.GenomicDataVDJ()
genomic_data.load_igor_genomic_data(params_file_name, V_anchor_pos_file, J_anchor_pos_file)
generative_model = olga.load_model.GenerativeModelVDJ()
generative_model.load_and_process_igor_model(marginals_file_name)

# sequence generation
olha_gen = olha.SequenceGeneration(genomic_data, generative_model, error_rate=0.1)
olha_gen.gen_rnd_prod_CDR3()
# ('TGCGCCAGCAGCTCCATGGACGGCTCCGAAAAACTGTTTTTT', 'CASSSMDGSEKLFF', 49, 3)
```

## Comparison
```py
import timeit
olha_gen = olha.SequenceGeneration(genomic_data, generative_model, error_rate=0.1)
olga_gen = olga.sequence_generation.SequenceGenerationVDJ(generative_model, genomic_data)

timeit.timeit(olha_gen.gen_rnd_prod_CDR3) # 3.31 μs
timeit.timeit(olga_gen.gen_rnd_prod_CDR3) # 103 μs
```
sparse-lut 1.0.0
Sparse Look-Up-Table
License: MIT
Requires Python: >=3.7.0
Keywords: SparseLUT,Sparse,Look-Up Table

稀疏查找表的用处及其优势请参见[SparseLUT在Github上的README.md](https://github.com/bowen-xu/SparseLUT)


## 使用方法

通过以下命令即可安装稀疏查找表的Python包：

```
pip install sparse_lut
```

下面介绍使用稀疏查找表的方法。


首先，通过如下代码初始化稀疏查找表

```Python
from sparse_lut import SparseLUT

# initialization
lut = SparseLUT((3, 3, 3, 3, 3))
```

其次，通过`add`方法，向稀疏查找表中加入多条*特征序列*，例如

```Python
# adding feature-lists
lut.add([[0,1,2], [0,1,2], [0,1,2], [0,1,2], [0,1,2]], "A")
lut.add([[1,2], [0], [0,1,2], [0,1,2], [0,1,2]], "B")
lut.add([[1,2], [1], [0,1,2], [0,1,2], [0,1,2]], "C")
```

第三，构建稀疏查找表。如果要进一步进行可视化，则需要传入参数 `False`，否则，程序构建好后会将相关的中间变量清空，以至于无法进行进一步的可视化。

```Python
# building the sparse-lut
lut.build(False) # set True is visualization is not required 
```

第四，如果需要可视化，则通过`draw`方法进行。
图8

第五，通过下标访问。例如

```Python
# accessing the value
result = lut[0,1,0,0,0]
print(result)
```

程序会打印“OrderedSet(['A'])”，即成功访问到了对应的值。