Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e36c78a
🚀 Add group heuristic
vadyushkins Mar 6, 2022
5bb9c3b
🚀 Add setup.py
vadyushkins Mar 6, 2022
b0e992a
🚀 Add weights folder to package
vadyushkins Mar 7, 2022
ae98fb5
🚀 Remove binarization argument
vadyushkins Mar 7, 2022
419dd5b
🔧 Fix setup.py
vadyushkins Mar 9, 2022
d8e8372
🔧 Add docstrings and test for cfpq_pyalgo.py
vadyushkins Mar 9, 2022
7716089
🔧 Add docstrings and test for parsing.py
vadyushkins Mar 9, 2022
9576fcc
🔧 Add docstrings and test for predict.py
vadyushkins Mar 9, 2022
e87bb95
🔧 Add docstrings and tests for main.py
vadyushkins Mar 12, 2022
738b543
🔧 Add docstrings and tests for utils.py
vadyushkins Mar 12, 2022
cae0358
🚀 Add cli entry_point
vadyushkins Mar 12, 2022
fa41843
🚀 Add test workflow
vadyushkins Mar 12, 2022
d8c7e36
🚀 Update README.md
vadyushkins Mar 12, 2022
26e8d48
🧹 Remove Pipfile
vadyushkins Mar 12, 2022
c60f2f3
🧹 Fix Python versions
vadyushkins Mar 12, 2022
1e34706
🧹 Fix Python versions
vadyushkins Mar 12, 2022
efb93cb
🧹 Fix requirements installation
vadyushkins Mar 12, 2022
9e187f9
🧹 Fix requirements installation
vadyushkins Mar 12, 2022
2f3c0be
🧹 Fix requirements
vadyushkins Mar 12, 2022
6f709d8
🧹 Fix requirements
vadyushkins Mar 12, 2022
87d702f
🧹 Update cfpq_pyalgo.py
vadyushkins Mar 13, 2022
2aad8d7
🧹 Update parsing.py
vadyushkins Mar 13, 2022
376cdc4
🧹 Update predict.py
vadyushkins Mar 13, 2022
81c6c47
🧹 Update utils.py
vadyushkins Mar 13, 2022
54038c1
🧹 Update default requirements
vadyushkins Mar 13, 2022
4fcc357
🧹 Move to Ubuntu 18.04
vadyushkins Apr 2, 2022
40b10e3
🧹 Update black
vadyushkins Apr 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,29 @@
# This is a basic workflow to help you get started with Actions

name: Check code style

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events
[ push, pull_request ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

# This workflow contains a single job called "Check_code_style"
Check_code_style:

# The type of runner that the job will run on
runs-on: ubuntu-latest

# A strategy creates a build matrix for your jobs
runs-on: ubuntu-18.04
strategy:

# You can define a matrix of different job configurations
matrix:

# Each option you define in the matrix has a key and value
python-version: [ 3.8 ]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Set up Git repository
uses: actions/checkout@v2

# Setup Python with version from matrix
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# Install pre-commit
- name: Install pre-commit
run: |
python -m pip install pre-commit==2.15.0
pre-commit install

# Run pre-commit on all the files in the repo
- name: Run pre-commit
run: |
pre-commit run --all-files --color always --verbose --show-diff-on-failure
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on: [ push, pull_request ]

jobs:
tests:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [ "3.8" ]
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install .
python -m pip install -r requirements/test.txt
python -m pip list

- name: Test Genegram
run: |
pytest -vv -s tests
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

1,107 changes: 0 additions & 1,107 deletions Pipfile.lock

This file was deleted.

117 changes: 95 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,131 @@
[![Check code style](https://github.com/JetBrains-Research/Genegram/actions/workflows/check_code_style.yml/badge.svg)](https://github.com/JetBrains-Research/Genegram/actions/workflows/check_code_style.yml)
[![Check code style](https://github.com/JetBrains-Research/Genegram/actions/workflows/lint.yml/badge.svg)](https://github.com/JetBrains-Research/Genegram/actions/workflows/lint.yml)
[![Check code style](https://github.com/JetBrains-Research/Genegram/actions/workflows/test.yml/badge.svg)](https://github.com/JetBrains-Research/Genegram/actions/workflows/test.yml)
---
# Genegram

# Genegram: RNA Secondary Structure Prediction by Combination of Formal Grammars and Neural Networks

## Description

[comment]: <> (TODO)
Command Line Tool for Predicting RNA Secondary Structure Connectivity Table

## Install
## FASTA format

We use [`Pipenv`](https://pipenv.pypa.io/en/latest/) to manage dependencies.
**⚠️ We use a slightly more strict FASTA format than the [standard](https://en.wikipedia.org/wiki/FASTA_format) ⚠️**

### [Install Pipenv](https://pipenv.pypa.io/en/latest/#install-pipenv-today)
### Our format

```shell
pip install --user pipenv
```text
>RNA description
RNA sequence
...
>RNA description
RNA sequence
```

### Install Genegram (from sources)
### Example

```text
>34551
GGCCUCCAAGCUGUGCCUUGGGUGGCC
>34552
CCUCCCUUACAAGGAGG
>34553
GGAGUGGCCGAAAGGCAUCUCC
>34735
GGCUCUCAGUGAGCC
```

```shell
git clone https://github.com/JetBrains-Research/Genegram
cd Genegram
pipenv install --ignore-pipfile
## Requirements

### Hardware

* Genegram requires only a standard computer with around 16 GB RAM to support the in-memory operations for RNAs sequence length less than 500

### OS

* [`Ubuntu 18.04`](https://releases.ubuntu.com/18.04/)

### Software

* [`Python 3.8`](https://www.python.org/downloads/release/python-380/)
* [`Virtualenv`](https://virtualenv.pypa.io/en/latest/installation/)
* [`CUDA 11.2`](https://developer.nvidia.com/cuda-11.2.0-download-archive) *(Optional If using GPU)*
* [`cuDNN 8.1`](https://developer.nvidia.com/cudnn) *(Optional If using GPU)*

### Python packages

```text
tensorflow==2.7.0
pygraphblas==4.2.2
pyformlang==0.1.26
```

## Installation

### From PyPI

To install **Gengram** from PyPI following commands can be used in terminal:

1. `virtualenv -p python3.8 venv`
2. `source ./venv/bin/activate`
3. `pip install genegram`

### From sources

To install **Gengram** from sources following commands can be used in terminal:

1. `git clone https://github.com/JetBrains-Research/Genegram.git`
2. `cd Genegram`

Either follow `virtualenv` column steps or `conda` column steps to create virtual environment
and to install **Genegram** dependencies given in table below:

| | virtualenv | conda |
| --- |--------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 3. | `virtualenv -p python3.8 venv` | `conda create -n venv python=3.8` |
| 4. | `source ./venv/bin/activate` | `conda activate venv` |
| 5. | To run Genegram on **CPU:** <br> `pip install tensorflow-cpu==2.7.0` <br> or <br> To run Genegram on **GPU:** <br> `pip install tensorflow-gpu==2.7.0` | To run Genegram on **CPU:** <br> `conda install tensorflow-cpu==2.7.0 --channel conda-forge` <br> or <br> To run Genegram on **GPU:** <br> `conda install tensorflow-gpu==2.7.0 --channel conda-forge` |
| 6. | `pip install .` | `pip install .` |

## Usage

Run the following command with arguments.
After successfully installing the package, you have three options to use it:

```bash
python -m genegram
```
1. `python -m genegram <arguments>`
2. `genegram <arguments>`
3. ```Python
from genegram import process_fasta_group
process_fasta_group(<arguments>)
```

### **Arguments**
### Arguments

Argument | Required | Description
:--- | :---: | :---
-i, --inp | True | Path to the [`FASTA`](http://genetics.bwh.harvard.edu/pph/FASTA.html) file
-o, --out | True | Path to the folder where the [`Connectivity Tables`](http://rna.urmc.rochester.edu/Text/File_Formats.html#CT) will be saved
-m, --model | False | Type of the model to be used: </br> `main` -- The default model, the best on average </br> `mps` -- Multiplet prediction model </br> `pks` -- Pseudoknots prediction model
-l, --log | False | Type of the logging level to be used: </br> `INFO` -- Confirmation that things are working as expected </br> `WARNING` -- An indication that something unexpected happened, the software is still working as expected </br> `ERROR` -- Due to a more serious problem, the software has not been able to perform some function </br> `CRITICAL` -- A serious error, indicating that the program itself may be unable to continue running </br> `DEBUG` -- Detailed information, typically of interest only when diagnosing problems

## Code style
## Examples

If you have installed Genegram from sources, you can run the following example (in the Genegram folder)

`genegram -i tests/data/seq.fasta -o EXAMPLE_FOLDER -m main`

## Information for Developers

### Code Style

We recommend you use a [pre-commit](https://pre-commit.com/#install) hook, which runs [black](https://github.com/psf/black) when you type git commit.

### Install pre-commit
#### Install pre-commit

```shell
pipenv install --dev
pre-commit install
```

### Use pre-commit
#### Use pre-commit

```shell
pre-commit run --all-files --color always --verbose
Expand Down
8 changes: 8 additions & 0 deletions genegram/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
__version__ = "1.0.0"

import genegram.shared
from genegram.shared import *

import genegram.utils
from genegram.utils import *

import genegram.cfpq_pyalgo
from genegram.cfpq_pyalgo import *

Expand All @@ -9,3 +14,6 @@

import genegram.predict
from genegram.predict import *

import genegram.main
from genegram.main import *
55 changes: 10 additions & 45 deletions genegram/__main__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import logging
"""Genegram CLI"""
from argparse import ArgumentParser, RawTextHelpFormatter
from pathlib import Path

from genegram.parsing import read_fasta
from genegram.predict import rna_predict, setup_model, clear_session
from genegram.shared import ROOT
from genegram.main import process_fasta_group

if __name__ == "__main__":

def main():
parser = ArgumentParser(
description="Genegram", formatter_class=RawTextHelpFormatter
)
Expand Down Expand Up @@ -34,49 +33,15 @@
"\npks -- Pseudoknots prediction model"
),
)
parser.add_argument(
"-l",
"--log",
required=False,
type=str,
choices=["INFO", "WARNING", "ERROR", "CRITICAL", "DEBUG"],
default="INFO",
help=(
"Type of the logging level to be used:"
"\nINFO -- Confirmation that things are working as expected"
"\nWARNING -- An indication that something unexpected happened, the software is still working as expected"
"\nERROR -- Due to a more serious problem, the software has not been able to perform some function"
"\nCRITICAL -- A serious error, indicating that the program itself may be unable to continue running"
"\nDEBUG -- Detailed information, typically of interest only when diagnosing problems"
),
)

args = parser.parse_args()

logging.basicConfig(
level=args.log,
format="[%(asctime)s]>%(levelname)s>%(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
process_fasta_group(
fasta=Path(args.inp).resolve(),
out=Path(args.out).resolve(),
weights=args.model,
)

logging.info(f"Parse {args=}")

out = Path(args.out).resolve()
if not out.exists():
out.mkdir(parents=True, exist_ok=True)
logging.info(f"Create {out} dir")

model = setup_model(ROOT / "weights" / f"{args.model}.h5")

for rna in read_fasta(Path(args.inp).resolve()):
pred = rna_predict(rna, model)

target_path = out / f"{rna.description}.ct"

with open(target_path, "w") as fout:
fout.write(pred.ct)
logging.info(
f"Save {rna=} secondary structure connectivity table to {target_path=}"
)

clear_session()
if __name__ == "__main__":
main()
Loading