Skip to content

Commit

Permalink
Merge pull request #136 from bfrgoncalves/flowcraft_reports
Browse files Browse the repository at this point in the history
Flowcraft reports
  • Loading branch information
bfrgoncalves authored Sep 11, 2018
2 parents 1a02ff4 + 96dad74 commit 34e8139
Show file tree
Hide file tree
Showing 36 changed files with 1,528 additions and 1,672 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
# INNUENDO

[![Documentation Status](https://readthedocs.org/projects/innuendo/badge/?version=latest)](https://innuendo.readthedocs.io/en/latest/?badge=latest)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0fffb6e32a564841a1dfb9230616d5f6)](https://app.codacy.com/app/bfrgoncalves/INNUENDO_REST_API?utm_source=github.com&utm_medium=referral&utm_content=bfrgoncalves/INNUENDO_REST_API&utm_campaign=Badge_Grade_Dashboard)

#### A novel cross-sectorial platform for the integration of genomics in surveillance of foodborne pathogens

In this repository you will find all the necessary information regarding platform architecture, installation and source code.
In this repository you will find all the necessary information regarding
platform architecture, installation and source code.

> **Architecture**
INNUENDO platform is divided into two distinct applications that comunicate between each other. The first one, the **INNUENDO frontend server**, comprises the user web interface and mechanisms to allow secure user authentication with LDAP and data storage into a dedicated database. It also comunicates with the **INNUENDO process controller**, which was developed with the aim of working as a bridge to allow running analytical procedures on a laptop or in a High Performance Computer (HPC), with the help of SLURM process manager.
INNUENDO platform is divided into two distinct applications that communicate
between each other. The first one, the **INNUENDO frontend server**, comprises
the user web interface and mechanisms to allow secure user authentication
using LDAP (if required), and database communication. It also communicates
with the **INNUENDO process controller**, which was developed with the aim of working as
a bridge to allow running analytical procedures on a laptop or in a High
Performance Computer (HPC), with the help of SLURM process manager.

In this repository you can find the source code regarding the **INNUENDO
frontend server** and its associated RESTful API.

> **Installation**
Information about the platform instalation can be found at the documentation.
Information about the platform installation can be found at the documentation.

> **Source code**
* [**INNUENDO frontend server**](https://github.com/B-UMMI/INNUENDO_REST_API)
* [**INNUENDO process controller server**](https://github.com/B-UMMI/INNUENDO_PROCESS_CONTROLLER)
* [**INNUENDO frontend server**](https://github.com/bfrgoncalves/INNUENDO_REST_API)
* [**INNUENDO process controller server**](https://github.com/bfrgoncalves/INNUENDO_PROCESS_CONTROLLER)

> **Docker-Compose**
A docker-compose version of the INNUENDO Platform is also available and can
be used for an easier deployment since it installs all the components
automatically.

* [**Docker-Compose version**](https://github.com/bfrgoncalves/INNUENDO_docker)
4 changes: 1 addition & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
- app_configuration (before first request and override login post of the flask-login package to deal with ldap)
'''


# Setup app
app = Flask(__name__)
# Reads the config file located at ../
Expand All @@ -48,7 +47,6 @@ def simple(env, resp):
# SET THE REDIS QUEUE
q = Queue(connection=conn)


from app.models.models import User, Role

user_datastore = SQLAlchemyUserDatastore(db, User, Role)
Expand All @@ -60,7 +58,7 @@ def simple(env, resp):
# setup agraph
server = AllegroGraphServer(AG_HOST, AG_PORT, AG_USER, AG_PASSWORD)
catalog = server.openCatalog()

myRepository = catalog.getRepository(AG_REPOSITORY, Repository.OPEN)
myRepository.initialize()
dbconAg = myRepository.getConnection()
Expand Down
4 changes: 1 addition & 3 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
NGSOnto_ProcessListPipelineResource, NGSOnto_ProcessResource, \
NGSOnto_ProcessJobID, NGSOnto_ProcessOutputResource
from resources.jobs.jobs import Job_queue, Job_results, Job_Result_Download, \
Job_classify_chewbbaca, Job_Result_Download_click, Job_Reports, \
Job_Result_Download_click, Job_Reports, \
NextflowLogs, Job_Report_Download_click, FlowcraftInspect
from resources.phyloviz.phyloviz import PHYLOViZResource, TreeResource, \
TreeUserResource, PHYLOViZJobResource, getProfilesResource, \
Expand Down Expand Up @@ -151,8 +151,6 @@
api.add_resource(NextflowLogs, '/api/v1.0/jobs/logs/nextflow/')
api.add_resource(FlowcraftInspect, '/api/v1.0/jobs/inspect/')

api.add_resource(Job_classify_chewbbaca, '/api/v1.0/jobs/classify/')

################################# PHYLOVIZ REQUESTS ###########################

api.add_resource(PHYLOViZResource, '/api/v1.0/phyloviz/')
Expand Down
8 changes: 3 additions & 5 deletions app/app_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
from flask import request, after_this_request, redirect, current_app
from flask_security.utils import do_flash, get_message, get_url
from flask_security.signals import password_changed
from config import obo,localNSpace,dcterms, SFTP_HOST, LOGIN_METHOD, \
from config import localNSpace,dcterms, SFTP_HOST, LOGIN_METHOD, \
LOGIN_USERNAME, LOGIN_GID, LOGIN_HOMEDIR, LOGIN_PASSWORD, LOGIN_EMAIL, \
ALL_SPECIES
from franz.openrdf.vocabulary.rdf import RDF

'''
App configuration:
'''App configuration:
- Set of functions to be applied before the first app request and an
handle override for the flask-login post function
'''
handle override for the flask-login post function'''


# Executes before the first request is processed.
Expand Down
16 changes: 3 additions & 13 deletions app/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
from app import db
from flask_security import UserMixin, RoleMixin
from sqlalchemy.dialects.postgresql import ARRAY, JSON
from config import LDAP_PROVIDER_URL, baseDN, LDAP_ADMIN_NAME, LDAP_ADMIN_PASS
from config import LDAP_PROVIDER_URL, baseDN, LDAP_ADMIN_PASS
from passlib.hash import ldap_md5

'''
Models:
- Defines every model to be used on the postgres database
'''
'''Models:
- Defines every model to be used on the postgres database'''

# Secondary role table
roles_users = db.Table('roles_users',
Expand Down Expand Up @@ -129,14 +127,6 @@ def try_login(email, password):
except Exception as e:
return False

#conn.unbind()

'''try:
conn.simple_bind_s("cn=" + LDAP_ADMIN_NAME + "," + baseDN, LDAP_ADMIN_PASS)
except Exception as e:
print e
return False'''

search_filter = "uid="+email
entry = ""
result = conn.search_s(baseDN, ldap.SCOPE_SUBTREE, search_filter)
Expand Down
12 changes: 5 additions & 7 deletions app/resources/file_resources/file_resources.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask import jsonify, send_file
from flask_restful import Resource, reqparse
from flask import send_file

from flask_security import current_user, login_required, roles_required, auth_token_required
from flask_security import login_required
import os

'''
File resources:
- Get template for strain batch submission
'''
'''File resources:
- Get template for strain batch submission'''


class TemplateResource(Resource):
Expand Down
10 changes: 6 additions & 4 deletions app/resources/jobs/checks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app import db
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_restful import Api, Resource, reqparse, abort, marshal_with
from config import JOBS_ROOT, LDAP_PROVIDER_URL, phyloviz_root
import ldap
from app.models.models import Ecoli, Project, Platform
Expand All @@ -8,7 +8,7 @@
from flask_security import current_user

# Imports for allegrograph check
from config import AG_HOST, AG_PORT, AG_REPOSITORY, AG_USER, AG_PASSWORD
from config import AG_HOST, AG_PORT, AG_USER, AG_PASSWORD
from franz.openrdf.sail.allegrographserver import AllegroGraphServer


Expand All @@ -31,8 +31,9 @@ def get(self):

try:
project = db.session.query(Project).first()

print project
except Exception as e:
print e
return False

return True
Expand All @@ -44,8 +45,9 @@ def get(self):

try:
project = db.session.query(Ecoli).first()

print project
except Exception as e:
print e
return False

return True
Expand Down
25 changes: 1 addition & 24 deletions app/resources/jobs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from flask_security import current_user, login_required, roles_required, auth_token_required
import datetime
from config import CURRENT_ROOT, JOBS_ROOT, OUTPUT_URL, USER_STORAGES
from config import obo,localNSpace,protocolsTypes,processTypes,processMessages
from config import obo,localNSpace
from franz.openrdf.query.query import QueryLanguage
from app.models.models import Protocol
from app.models.models import Strain
Expand Down Expand Up @@ -611,29 +611,6 @@ def get(self):
return report.report_data


# Load job results and classify it
class Job_classify_chewbbaca(Resource):
"""
Class to classify chewbbaca
"""

def get(self):
"""Classify profile
Classify a profile by giving its job_id
(DEPRECATED)
Returns
-------
"""

args = job_classify_chewbbaca_post_parser.parse_args()
database_processor.classify_profile(args.job_id,
args.database_to_include)


# Load job results to display on graphical interface
class Job_Result_Download(Resource):

Expand Down
2 changes: 1 addition & 1 deletion app/resources/ngs_onto/ngs_onto_pipelines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from app import dbconAg
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_security import current_user, login_required
from flask_security import login_required
from app.utils.queryParse2Json import parseAgraphStatementsRes

from config import obo,localNSpace,protocolsTypes,processTypes,processMessages
Expand Down
5 changes: 0 additions & 5 deletions app/resources/ngs_onto/ngs_onto_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,6 @@ def post(self, id, id2):
pprocid = args.parent_process_id
rpipid = args.real_pipeline_id

parentProcessURI = dbconAg.createURI(
namespace=localNSpace+"projects/",
localname=str(ppropid)+"/pipelines/" +
str(ppipid)+"/processes/"+str(pprocid))

if ppipid == rpipid:
for proc_json in procJsonResult:
if int(proc_json["StrIndex"].replace('"', '')) > int(pprocid):
Expand Down
2 changes: 1 addition & 1 deletion app/resources/ngs_onto/ngs_onto_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from app.utils.queryParse2Json import parseAgraphStatementsRes
from flask_security import current_user, login_required, roles_required
from config import obo,localNSpace,protocolsTypes,processTypes,processMessages
from config import obo,localNSpace, processTypes,processMessages
from franz.openrdf.vocabulary.rdf import RDF


Expand Down
2 changes: 1 addition & 1 deletion app/resources/ngs_onto/ngs_onto_protocols.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app import dbconAg
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_restful import Resource, reqparse, abort, fields
from flask_security import current_user, login_required
from app.utils.queryParse2Json import parseAgraphQueryRes
from config import obo,localNSpace,protocolsTypes,processTypes,processMessages
Expand Down
2 changes: 1 addition & 1 deletion app/resources/ngs_onto/ngs_onto_strains.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from app import dbconAg
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from app.utils.queryParse2Json import parseAgraphStatementsRes
from flask_security import current_user, login_required, roles_required
from flask_security import login_required, roles_required
from config import obo,localNSpace,protocolsTypes,processTypes,processMessages
from franz.openrdf.vocabulary.rdf import RDF

Expand Down
4 changes: 2 additions & 2 deletions app/resources/ngs_onto/ngs_onto_users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from app import dbconAg,dedicateddbconAg
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_security import current_user, login_required
from config import obo,localNSpace,dcterms
from flask_security import login_required
from config import localNSpace,dcterms
from franz.openrdf.vocabulary.rdf import RDF
from app.utils.queryParse2Json import parseAgraphStatementsRes

Expand Down
2 changes: 1 addition & 1 deletion app/resources/ngs_onto/ngs_onto_workflows.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app import dbconAg
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_restful import Resource, reqparse, fields
from app.utils.queryParse2Json import parseAgraphStatementsRes,parseAgraphQueryRes
from config import obo,localNSpace,protocolsTypes,processTypes,processMessages
from franz.openrdf.vocabulary.rdf import RDF
Expand Down
2 changes: 1 addition & 1 deletion app/resources/phyloviz/phyloviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_security import current_user, login_required, roles_required, \
auth_token_required
from config import CURRENT_ROOT, JOBS_ROOT, phyloviz_root
from config import JOBS_ROOT, phyloviz_root
from app.models.models import Tree
import requests
import os
Expand Down
3 changes: 2 additions & 1 deletion app/resources/postgres/messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from app import db, mail
from app.models.models import Message, User
from flask_restful import Api, Resource, reqparse, abort, fields, marshal_with
from flask_security import current_user, login_required, roles_required
from flask_security import current_user, login_required
from sqlalchemy import desc
import datetime

Expand Down Expand Up @@ -245,6 +245,7 @@ def post(self):
mail.send(msg)

except Exception as e:
print e
return False

return True
7 changes: 2 additions & 5 deletions app/resources/postgres/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

############################################ NOT BEING USED ####################

"""
Processes are being defined in the ngsonto resources
"""Processes are being defined in the ngsonto resources
DEPRECATED
"""
DEPRECATED"""

# Defining post arguments parser
process_post_parser = reqparse.RequestParser()
Expand Down
12 changes: 6 additions & 6 deletions app/resources/postgres/projects.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from app import db
from flask_restful import Api, Resource, reqparse, abort, fields, \
marshal_with #filters data according to some fields
# filters data according to some fields
from flask_restful import Resource, reqparse, abort, fields, \
marshal_with

from app.models.models import Project, User
from flask_security import current_user, login_required, roles_required, \
auth_token_required
from flask_security import current_user, login_required, roles_required
import datetime
import random
import string
Expand Down Expand Up @@ -249,13 +249,13 @@ def post(self):
name=args.name,
timestamp=datetime.datetime.utcnow())
if not project:
abort(404, message="An error as occurried when uploading the data"
.format(id))
abort(404, message="An error as occurried when uploading the data")

try:
db.session.add(project)
db.session.commit()
except Exception as e:
print e
abort(409, message="Project name already exists.")
return project, 201

Expand Down
6 changes: 2 additions & 4 deletions app/resources/postgres/protocols.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app import db
from flask_restful import Api, Resource, reqparse, abort, fields, \
from flask_restful import Resource, reqparse, abort, fields, \
marshal_with # filters data according to some fields

import json
Expand All @@ -19,9 +19,7 @@
protocol_post_parser.add_argument('version', dest='version', type=str,
required=True, help="Protocol version")

"""
STEPS -> Parameters which define the protocol
"""
"""STEPS -> Parameters which define the protocol"""

# Defining get arguments parser
protocol_get_parser = reqparse.RequestParser()
Expand Down
Loading

0 comments on commit 34e8139

Please sign in to comment.