Skip to content

Commit

Permalink
Merge pull request #60 from mobidic/dev
Browse files Browse the repository at this point in the history
Merge Dev
  • Loading branch information
Char-Al authored Oct 11, 2023
2 parents 812d347 + fd5b306 commit fb4f2e6
Show file tree
Hide file tree
Showing 1,726 changed files with 1,849 additions and 135,847 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ python insert_OMIM.py
### Launching the App
Finally, to launch the app, run the following command:
```
```bash
flask --app seal --debug run
```
Expand All @@ -146,6 +146,11 @@ flask --app seal --debug db upgrade
pg_ctl -D ${PWD}/seal/seal.db -l ${PWD}/seal/seal.db.log start
pg_ctl -D ${PWD}/seal/seal.db -l ${PWD}/seal/seal.db.log stop
```
- Dump/Restore the database
```bash
pg_dump -O -C --if-exists --clean --inserts -d seal -x -F t -f seal.tar
pg_restore -x -f seal.tar
```
# License
Expand Down
Binary file modified docs/img/seal.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions seal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os
from datetime import timedelta
import yaml
from pathlib import Path
from datetime import timedelta

from flask import Flask, session, g, request, redirect, url_for
from flask_apscheduler import APScheduler
Expand All @@ -33,7 +34,7 @@

app = Flask(__name__)

with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yaml"), "r") as config_file:
with open(Path(app.root_path).joinpath("config.yaml"), "r") as config_file:
config = yaml.safe_load(config_file)

app.config.update(config['FLASK'])
Expand Down
15 changes: 12 additions & 3 deletions seal/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from seal import app, db, bcrypt
from seal.models import (User, Team, Sample, Family, Variant, Comment_variant,
Comment_sample, Var2Sample, Filter, Transcript, Run,
Region, Bed, Phenotype, Omim, History)
Region, Bed, Phenotype, Omim, History, Clinvar)

###############################################################################

Expand Down Expand Up @@ -342,8 +342,9 @@ def validate_form(self, form):
Variant,
db.session,
category="Variant",
column_searchable_list = ['chr', 'pos', 'ref', 'alt', 'annotations'],
column_editable_list = ['chr', 'pos', 'ref', 'alt', 'class_variant'],
column_searchable_list = ['chr', 'pos', 'ref', 'alt', 'class_variant', 'clinvar_VARID', 'clinvar_CLNSIG', 'clinvar_CLNSIGCONF', 'clinvar_CLNREVSTAT'],
column_editable_list = ['chr', 'pos', 'ref', 'alt', 'class_variant', 'clinvar_VARID', 'clinvar_CLNSIG', 'clinvar_CLNSIGCONF', 'clinvar_CLNREVSTAT'],
column_exclude_list = ['annotations'],
form_excluded_columns = ['samples']
)
)
Expand Down Expand Up @@ -397,6 +398,14 @@ def validate_form(self, form):
)
)

admin.add_view(
CustomView(
Clinvar,
db.session,
category="Analysis"
)
)


###############################################################################

Expand Down
31 changes: 26 additions & 5 deletions seal/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import requests
import pandas as pd

from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import StringField, PasswordField, SubmitField, BooleanField, ValidationError, TextAreaField, SelectMultipleField
from wtforms.validators import DataRequired, Length, Email, Optional, EqualTo
from flask_login import current_user
from seal.models import User, Sample, Run, Team, Bed, Region
from wtforms import (StringField, PasswordField, SubmitField, BooleanField,
ValidationError, TextAreaField, SelectMultipleField,
SelectField, DateField)
from wtforms.validators import DataRequired, Length, Email, Optional, EqualTo

from seal import bcrypt
import pandas as pd
import requests
from seal.models import User, Sample, Run, Team, Bed, Region

################################################################################
# Authentication
Expand Down Expand Up @@ -208,4 +212,21 @@ class SaveFilterForm(FlaskForm):
submit = SubmitField('Add A New Filter')


class UploadClinvar(FlaskForm):
version = DateField(
'Version',
validators=[DataRequired()], format='%Y-%m-%d'
)
genome_version = SelectField(
'Genome',
choices=[('grch37', 'grch37'), ('grch38', 'grch38')],
validators=[DataRequired()]
)
vcf_file = FileField(
'VCF',
validators=[DataRequired(), FileAllowed(['vcf', 'vcf.gz'])]
)
submit = SubmitField('Update Clinvar')


################################################################################
23 changes: 21 additions & 2 deletions seal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.dialects import postgresql



################################################################################
# Authentication

Expand Down Expand Up @@ -136,6 +134,19 @@ def __str__(self):
return self.teamname


class Clinvar(db.Model):
version = db.Column(db.Integer, primary_key=True)
genome = db.Column(db.String(20), unique=False, nullable=False)
date = db.Column(db.TIMESTAMP(timezone=False), nullable=False, default=datetime.now())
current = db.Column(db.Boolean(), default=True, nullable=False)

def __repr__(self):
return f"Clinvar('{self.version}','{self.date}')"

def __str__(self):
return str(self.version)


################################################################################


Expand All @@ -155,6 +166,7 @@ class History(db.Model):
class Sample(db.Model):
id = db.Column(db.Integer, primary_key=True)
samplename = db.Column(db.String(120), unique=False, nullable=False)
alias = db.Column(db.String(120), unique=False, nullable=True)
status = db.Column(db.Integer, unique=False, nullable=False, default=0)
affected = db.Column(db.Boolean(), default=False)
index = db.Column(db.Boolean(), default=False)
Expand Down Expand Up @@ -211,6 +223,8 @@ class Run(db.Model):
name = db.Column(db.String(50), unique=True, nullable=False)
alias = db.Column(db.String(50), unique=False, nullable=True)

summary = db.Column(db.Text, unique=False, nullable=True)

samples = relationship("Sample")
reads = relationship("Read")

Expand All @@ -231,6 +245,11 @@ class Variant(db.Model):
annotations = db.Column(db.JSON, nullable=True)
comments = relationship("Comment_variant")

clinvar_VARID = db.Column(db.Integer, unique=False, nullable=True)
clinvar_CLNSIG = db.Column(db.String(500), unique=False, nullable=True)
clinvar_CLNSIGCONF = db.Column(db.String(500), unique=False, nullable=True)
clinvar_CLNREVSTAT = db.Column(db.String(500), unique=False, nullable=True)

def __repr__(self):
return f"Variant('{self.chr}','{self.pos}','{self.ref}','{self.alt}')"

Expand Down
Loading

0 comments on commit fb4f2e6

Please sign in to comment.