semvec/pypi-packages huggingface dataset:
flask-scotch 0.0.2
Tape a REST API with a local database
License: MIT
Requires Python: >=3.9

# Flask Scotch

Tape a REST API with a local database

## Key Features

- Represent remote model in the form of a python class to be able to manipuldate easily
- Fetch objects from the database or from the remote API using the attributes of the declared models
- Update/delete/create object on the remote API using the declared models

## Install

`pip install flask-scotch`

## Getting started

First, you need to register the extension in flask

```python
from flask_scotch import FlaskScotch
from flask import Flask

# Configure the URL of the remote API with the configuration
# SCOTCH_API_URL='https://mysite.com/api/v1'

# Register the sqlAlchemy engine with flask-sqlalchemy, or provide it directly
# in the constructor

scotch = FlaskScotch()

app = Flask()

scotch.init_app(app)
```

Then, you can declare the "remote model", that is, the model present on the remote server.

```python
from flask_scotch import RemoteModel, LocalRelationship, LocalModel, RemoteRelationship
import sqlalchemy as sa

db = sa.create_engine()


class Item(LocalModel, db.Model):
    __remote_directory__ = 'items'

    id: int
    name: str
    description: str
    storage_id: int

    storage = RemoteRelationship("Storage")


class Storage(RemoteModel):
    id = sa.Column(sa.Integer, primary_key=True)
    name = sa.Column(sa.String)

    items = LocalRelationship("Item")


# You can then use this model to fetch data from the remote api:


all_items = Storage.api.all()

my_storage = Storage(id=10, name='pen')

final_storage = Storage.api.create(my_storage)

final_storage.name = 'green pen'
final_storage.update()

items = [Item(storage_id=10, name="item1"), Item(storage_id=10, name="item2")]
db.session.add(*items)
db.session.commit()

# Can now access the local items from
# the storage object
for item in my_storage.items:
    print(item)

final_storage.delete()
```

## TODO

- [x] ForeignModel: to be able to access an object from the API when it's accessed from a local model
    - [x] Handle 1:1 relations
    - [ ] Handle 1:N relations
- [x] LocalModel:
    - [x] Handle 1:1 relations
    - [x] Handle 1:N relations
- [x] ForeignModel and LocalModel: ability to reference a class with a string, rather than with the class directly
- [ ] LocalModel, propagates changes when added to list, so that sqlAlchemy updates the id when necessary (maybe
  using [InstrumentedList](https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/orm/collections.py) can
  help)
- [ ] Improve handling of return values from the API, and throw error based on the HTTP code returned
- [ ] Improve typing of all public functions and classes
- [ ] Automatically detect cross-referencing PartialModels and RemoteModel to avoid having to declare everything
- [ ] Have a 100% code coverage
kmer-counter 0.2.1
Count kmers in regions or at SNVs or at indel breakpoints.
License: MIT
Requires Python: >=3.6,<4.0

# kmer_counter

Count kmers in regions or at SNVs or at indel breakpoints.

## Requirements

kmer_counter requires Python 3.7 or above.

## Installation

With `pip`:
```bash
pip install kmer_counter
```

With [`pipx`](https://github.com/pipxproject/pipx):
```bash
pipx install kmer_counter
```

## Usage 

### Counting k-mers at SNVs
To count the 3-mers at SNVs do:
```bash
kmer_counter snv {genome}.2bit {snv_file}
```
Where the `{snv_file}` should be a vcf-like text file where the first four columns are: Chromosome, Position, Ref_Allele, Alt_Allele. Fx:

```
chr1  1000000  A G
chr1  1000200  G C
chr1  1000300  A T
chr1  1000500  C G
```
Comments or header lines starting with "#" are allowed and will be ignored and any additional columns are also allowed but ignored. So a vcf file is also a valid input file.
The Ref_Allele column should match the reference genome provided by the 2bit file. 2bit files can be downloaded from:
`https://hgdownload.cse.ucsc.edu/goldenpath/{genome}/bigZips/{genome}.2bit` where `{genome}` is a valid UCSC genome assembly name (fx. "hg38").

### Counting k-mers in genomic regions
To count all 5-mers in a bed file called {regions}.bed do:
```
kmer_counter background --bed {regions}.bed -radius 2 {genome}.2bit
```
By default all k-mers where the middle base is not A or C will be reverse complemented before being counted. This behaviour can be changed using the "--reverse_complement_method".
If we instead wants to count 4-mers, we can use the "--before_after" option: 
```
kmer_counter background --bed {regions}.bed --before_after 2 1 {genome}.2bit
```
When this option is used the default is not to reverse complement any of the k-mers but count all.

### Counting k-mers at indels
To count one of the possible insertion breakpoint 4-mer for each insertion in a vcf-like file with variants do:
```
kmer_counter indel -r 2 --sample {genome}.2bit {variants} ins
```
And for deletion start breakpoints:
```
kmer_counter indel -r 2 --sample {genome}.2bit {variants} del_start
```
This will produce 2 counts for each deletion; one for the start breakpoint and one for the reverse complement at the k-mer at end breakpoint.