Files
snpr/app/controllers/das_controller.rb
Philipp Bayer cf25d77185 Mateus' PR (#365), closes #264 #333
* Renaming '.env.example' to '.env'

* Removing bootstrap gem

* Adding newest version of Bootstrap(3.3.6) and setting it up

* Renamed 'database.yml.example' to 'database.yml'

* Deleted common.css.scss

* Deleting active_admin/application requirement

* Adding style file that import all style partials and adding javascript file

* Updating application.html.erb and includes(footer and navbar)

* Removing from news all the updates(new users, new pheno...) and putting on updates page

* Updating user views

* Updating phenotype views

* Updating index page

* Updating FAQ and Stats pages

* Updating genotype views

* Updating messages views

* Updating snps views and signin page

* Updating fitbit and picture_phenotype views

* Updating warning

* Adding base style and variable of style

* Adding style of index, faq and stats page

* Adding style for user views

* Adding style for footer and navbar

* Adding modules of style

* Adding style for fitbit, genotype, phenotype and message views

* Adding style for snps and updates views

* Updating serverscript

* Adding new logo and RSS new image

* Adding style files for: comments, password reset, picture phenotypes, achievements and search results

* Removing !important and updating some styles

* Updating view from achievements

* Updating views from fitbit profiles

* Updating genotypes views

* Updating navbar view

* Updating password reset view

* Updating phenotype comments views

* Updating phenotypes views

* Updating views: search result, snps, user phenotypes and users

* Updating views: updates and picture phenotypes

* Adding updates page's routes

* Modify flash messages and change number of fitbit profiles and genotypes per page(20 -> 15)

* Replace will_paginate to a version that works with bootstraps

* Change serverscript to make Sidekiq work propely

* Updates user's views

* Updates script to run only when page is fully loaded

* Moves script tags to head and updates flash messages' views

* Updates and add style for: picture_phenotypes, snps, userpages, press, warnings

* Updates views for: genotypes, messages, fitbit_profiles, phenotype comments, phenotypes

* Updates views for: picture phenotype, picture phenotype comments, warnings and errors, snps, snps comments

* Updates views for: press, picture phenotype user, user session and snps user

* Updates views from: user, updates, press and stats

* Updates views from: snps, picture phenotypes, phenotypes, genotypes

* Updates views from: fitbit profiles, navbar, application, messages and news

* Updates script file

* Updates style files

* Changes modal views

* Renaming '.env.example' to '.env'

* Removing bootstrap gem

* Adding newest version of Bootstrap(3.3.6) and setting it up

* Renamed 'database.yml.example' to 'database.yml'

* Deleted common.css.scss

* Deleting active_admin/application requirement

* Adding style file that import all style partials and adding javascript file

* Updating application.html.erb and includes(footer and navbar)

* Removing from news all the updates(new users, new pheno...) and putting on updates page

* Updating user views

* Updating phenotype views

* Updating index page

* Updating FAQ and Stats pages

* Updating genotype views

* Updating messages views

* Updating snps views and signin page

* Updating fitbit and picture_phenotype views

* Updating warning

* Adding base style and variable of style

* Adding style of index, faq and stats page

* Adding style for user views

* Adding style for footer and navbar

* Adding modules of style

* Adding style for fitbit, genotype, phenotype and message views

* Adding style for snps and updates views

* Updating serverscript

* Adding new logo and RSS new image

* Adding style files for: comments, password reset, picture phenotypes, achievements and search results

* Removing !important and updating some styles

* Updating view from achievements

* Updating views from fitbit profiles

* Updating genotypes views

* Updating navbar view

* Updating password reset view

* Updating phenotype comments views

* Updating phenotypes views

* Updating views: search result, snps, user phenotypes and users

* Updating views: updates and picture phenotypes

* Adding updates page's routes

* Modify flash messages and change number of fitbit profiles and genotypes per page(20 -> 15)

* Replace will_paginate to a version that works with bootstraps

* Change serverscript to make Sidekiq work propely

* Updates user's views

* Updates script to run only when page is fully loaded

* Moves script tags to head and updates flash messages' views

* Updates and add style for: picture_phenotypes, snps, userpages, press, warnings

* Updates views for: genotypes, messages, fitbit_profiles, phenotype comments, phenotypes

* Updates views for: picture phenotype, picture phenotype comments, warnings and errors, snps, snps comments

* Updates views for: press, picture phenotype user, user session and snps user

* Updates views from: user, updates, press and stats

* Updates views from: snps, picture phenotypes, phenotypes, genotypes

* Updates views from: fitbit profiles, navbar, application, messages and news

* Updates script file

* Updates style files

* Changes modal views

* Updates script file

* Add style file for modal

* Updates views from: snp comments, user phenotypes, modal and picture phenotypes

* Removes empty style files

* Moves comments style to modules directory

* Creates a more general class for containers and titles

* Removing more specific classes for containers and titles

* Changes load order, now variables are loaded before base styles

* Replaces all containers and titles classes with the more general class for them

* Corrects styles order and organization

* Updates minimum height for content container

* Organizes and refactors script file

* Updates views for fitbit and user

* Removes 'test-' from all classes and updates some views

* Updates settings view

* Updates gitignore

* Changes config files

* Removes some file from .gitignore

* Readds the example files

* Changes all unnecessary double-quotes to single-quotes

* Corrects script file

* Updates hound file to ignore JS files

* Hopefully merged both

* fixes typos, gem installation

* Adds missing pagination gem

* Deletes Vagrantfile

* Automatically replaced all pre Ruby 1.9 hashes with new style to satisfy Hound

* More changes for Hound, triggered by me automatically changing the hash syntax

* More hound changes

* Fully satisfy the hound

* Fix some more style issues, delete some old Vagrant stuff

* Fix usermailer complaints

* Changed some stuff in fitbit notification worker - prob. needs bigger refactor, long lines, cannot change

* Two more borked tests

* Get rid of useless asset pipeline errors

* Skipping search test for now.

* added about us here

* disclaimer now also for genotypes

* working a bit on the hound

* fixed FAQ language
2017-06-01 14:47:00 +02:00

123 lines
5.0 KiB
Ruby

# frozen_string_literal: true
class DasController < ApplicationController
def show
@user = User.find_by_id(params[:id])
@genotype = @user.genotypes.first
# make arrays of positions and ids in case we have several
# segments defined
@positions = []
@id = []
@unkown_chromosome = []
@known_chromosomes = ('1'..'22').to_a << 'X' << 'MT' << 'Y'
# user_snps is an array of arrays, each inner array having all user_snps from one specified segment
@user_snps = []
@has_start = []
@start_and_end = []
# first, split up all segments if they are present
# TODO: Refactor this - Philipp
if request.query_string
@query_string = CGI.parse request.query_string
@types = []
@query_string['type'].each do |t|
@types << t
end
@query_string['segment'].each do |q|
@pos = q.split(':')
# append chromosome-id to the array of ids
@id << @pos[0]
if @known_chromosomes.include? @pos[0]
@unkown_chromosome << false
else
@unkown_chromosome << true
end
if @pos[1] != nil
@start_and_end << @pos[1].split(',')
@start = @pos[1].split(',')[0]
@end = @pos[1].split(',')[1]
@has_start << true
@snps = @user.snps.where('CAST(position as integer) <= ? AND CAST(position as integer) >= ? AND CAST(chromosome as text) = ?', @end, @start, @pos[0])
@tmp_user_snps = []
@snps.each do |s|
# 2014-8-26 There are several UserSNPs. Just take first one. - Philipp
if @types != []
@single_user_snp = s.user_snps.find_by_genotype_id(@genotype.id)
if @types.include? @single_user_snp.local_genotype
@tmp_user_snps << @single_user_snp
end
else
@tmp_user_snps << s.user_snps.find_by_genotype_id(@genotype.id)
end
end
@user_snps << @tmp_user_snps
else
# there are no positions, so use only chromosome
@snps = @user.snps.where('CAST(chromosome as text) = ?', @id)
@tmp_user_snps = []
@snps.each do |s|
# there is only one user_snp for each snps
if @types != []
@single_user_snp = s.user_snps.find_by_genotype_id(@genotype.id)
if @types.include? @single_user_snp.local_genotype
@tmp_user_snps << @single_user_snp
end
else
@tmp_user_snps << s.user_snps.find_by_genotype_id(@genotype.id)
end
end
@user_snps << @tmp_user_snps
@has_start << false
end
end
# When everything went correctly, send back 200
response.headers['X-DAS-Status'] = '200'
else
# no chromosome or start/end, so get nothing
@user_snps = [] #@user.user_snps
@id = ''
@start = ''
@end = ''
# Bad command arguments (arguments invalid)
response.headers['X-DAS-Status'] = '402'
end
response.headers['X-DAS-Version'] = 'DAS/1.53E'
# Change these capabilities once we implement more
response.headers['X-DAS-Capabilities'] = 'features/1.1; sources/1.0'
# Put in the servername and version
response.headers['X-DAS-Server'] = request.env['SERVER_SOFTWARE'].split(' ')[0]
response.headers['Access-Control-Allow-Origin'] = '*'
render template: 'das/show.xml.erb', layout: false
end
def sources
@users = User.all
response.headers['X-DAS-Version'] = 'DAS/1.53E'
response.headers['X-DAS-Status'] = '200'
response.headers['X-DAS-Capabilities'] = 'features/1.1; sources/1.0'
response.headers['X-DAS-Server'] = request.env['SERVER_SOFTWARE'].split(' ')[0]
render template: 'das/sources.xml.erb', layout: false
end
def startpoint
@user = User.find_by_id(params[:id])
response.headers['X-DAS-Version'] = 'DAS/1.53E'
response.headers['X-DAS-Status'] = '200'
response.headers['X-DAS-Capabilities'] = 'features/1.1; sources/1.0'
response.headers['X-DAS-Server'] = request.env['SERVER_SOFTWARE'].split(' ')[0]
render template: 'das/startpoint.xhtml.erb', layout: false
end
end