Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
649dc73
Add `parse_status` to Genotype
tsujigiri Dec 31, 2017
f96250a
Validate `parse_status`
tsujigiri Dec 31, 2017
dff4341
Update parse status when parsing
tsujigiri Dec 31, 2017
cdeae98
Introduce ParseError
tsujigiri Dec 31, 2017
06cde9e
Add TODO
tsujigiri Dec 31, 2017
46f39f8
Add test for `parse_status` update in Preparsing
tsujigiri Dec 31, 2017
e87be90
Don't hit the database twice when creating Genotype
tsujigiri Dec 31, 2017
21718c8
Remove unneded `=> e`
tsujigiri Dec 31, 2017
e656ac0
Add `parse_error_message` to Genotype
tsujigiri Dec 31, 2017
00aeada
WIP
tsujigiri Jan 1, 2018
98d5d1e
Add a list of uploaded genotypes to user settings
tsujigiri Jan 2, 2018
a96183c
Revert "Add `parse_error_message` to Genotype"
tsujigiri Jan 2, 2018
969aa5f
Order parse status cases logically
tsujigiri Jan 2, 2018
4e38535
Add line-breaks
tsujigiri Jan 2, 2018
13d2a3f
Fix indentation
tsujigiri Jan 2, 2018
4074972
Adapt feature spec to use genotypes list
tsujigiri Jan 2, 2018
87dcb06
Don't delete genotype on error in Preparsing
tsujigiri Jan 2, 2018
bd041af
Move genotype delete button to user's genotypes table
tsujigiri Jan 2, 2018
713c551
fixup! Don't delete genotype on error in Preparsing
tsujigiri Jan 2, 2018
83fd9c8
Refactor download and delete buttons
tsujigiri Jan 2, 2018
2e49e8e
Don't retry parsing
tsujigiri Jan 3, 2018
1fbbdec
Use i18n for table headers
tsujigiri Jan 3, 2018
1bfc9f2
Add button for uploading new genotype
tsujigiri Jan 3, 2018
1165df8
Add info on what to do when the parsing errored
tsujigiri Jan 3, 2018
d1d916d
Use warning label for "parsing" status
tsujigiri Jan 3, 2018
a769713
Switch to Chrome for feature specs
tsujigiri Jan 3, 2018
f87ecc0
Only show successfully parsed genotypes
tsujigiri Jan 4, 2018
62c9063
Hound happiness 🐶
tsujigiri Jan 4, 2018
c49f373
Merge branch 'master' into genotype-parsing-status
tsujigiri Jan 4, 2018
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
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ Style/FrozenStringLiteralComment:

Metrics/LineLength:
Max: 100

Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ addons:
apt:
packages:
- libhiredis-dev
chrome: stable
postgresql: '9.3'
services:
- redis-server
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ group :test do
gem 'webmock'
gem 'vcr'
gem 'capybara'
gem 'poltergeist'
gem 'selenium-webdriver', require: false
gem 'chromedriver-helper'
gem 'database_cleaner'
gem 'timecop'
end
Expand Down
22 changes: 13 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
archive-zip (0.7.0)
io-like (~> 0.3.0)
arel (6.0.4)
ast (2.3.0)
authlogic (3.6.0)
Expand All @@ -86,9 +88,13 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.8.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.1.0)
archive-zip (~> 0.7.0)
nokogiri (~> 1.6)
chronic (0.10.2)
climate_control (0.2.0)
cliver (0.3.2)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.1)
Expand Down Expand Up @@ -146,6 +152,7 @@ GEM
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (0.8.1)
io-like (0.3.0)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -212,10 +219,6 @@ GEM
plos (0.0.7)
nokogiri
rest-client
poltergeist (1.15.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
power_assert (1.0.2)
powerpack (0.1.1)
pry (0.10.4)
Expand Down Expand Up @@ -317,6 +320,9 @@ GEM
tilt (>= 1.1, < 3)
scrypt (3.0.5)
ffi-compiler (>= 1.0, < 2.0)
selenium-webdriver (3.8.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
sentry-raven (2.7.1)
faraday (>= 0.7.6, < 1.0)
shellany (0.0.1)
Expand Down Expand Up @@ -376,9 +382,6 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.7)
chronic (>= 0.6.3)
will_paginate (3.1.5)
Expand All @@ -397,6 +400,7 @@ DEPENDENCIES
bcrypt-ruby
capistrano (~> 2.0)
capybara
chromedriver-helper
composite_primary_keys (~> 8.0)
database_cleaner
dotenv-rails
Expand All @@ -420,7 +424,6 @@ DEPENDENCIES
pg
pg_search
plos
poltergeist
pry-rails
rails (~> 4.2)
rails3-generators
Expand All @@ -432,6 +435,7 @@ DEPENDENCIES
rvm-capistrano (= 1.4.4)
sanitize
sass-rails
selenium-webdriver
sentry-raven
shoulda-context
sidekiq
Expand Down
26 changes: 19 additions & 7 deletions app/controllers/genotypes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class GenotypesController < ApplicationController

def index
@title = "Listing all genotypings"
@genotypes =
Genotype
.includes(:user)
.order("#{sort_column} #{sort_direction}")
@genotypes = Genotype
.successfully_parsed
.includes(:user)
.order("#{sort_column} #{sort_direction}")
@genotypes_paginate = @genotypes.paginate(page: params[:page], per_page: 20)
end

Expand All @@ -19,8 +19,9 @@ def new
end

def create
@genotype = Genotype.create(genotype_params)
@genotype = Genotype.new(genotype_params)
@genotype.user = current_user
@genotype.parse_status = 'queued'
if @genotype.valid? && @genotype.save
Preparsing.perform_async(@genotype.id)
# award for genotyping-upload
Expand All @@ -36,7 +37,11 @@ def create
if current_user.has_sequence == false
current_user.toggle!(:has_sequence)
end
redirect_to(current_user, notice: 'Genotype was successfully uploaded! Parsing and annotating might take a couple of <strike>hours</strike> days.')

redirect_to(
edit_user_path(current_user, anchor: 'genotypes'),
notice: t('.uploaded_successfully')
)
else
render action: 'new'
end
Expand All @@ -61,6 +66,14 @@ def destroy
redirect_to current_user
end

def download
genotype = Genotype.find(params[:id])
send_data(
File.open(genotype.genotype.path),
filename: genotype.genotype_file_name
)
end

private

def sort_column
Expand All @@ -74,5 +87,4 @@ def sort_direction
def genotype_params
params.require(:genotype).permit(:genotype, :filetype)
end

end
23 changes: 23 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,27 @@ def page_navigation_links(pages)
def table_row_sequence_number(paginated, current_page_index)
paginated.per_page * (paginated.current_page - 1) + current_page_index + 1
end

def download_button(url)
link_to(url, class: 'btn btn-default btn-sm', title: t('download')) do
glyphicon('download-alt')
end
end

def delete_button(url, opts = {})
opts = {
method: 'delete',
class: 'btn btn-danger btn-sm',
title: t('delete'),
data: {
confirm: t('.confirm_delete', default: t('confirm_delete'))
}
}.deep_merge(opts)

link_to(url, opts) { glyphicon('trash') }
end

def glyphicon(name)
tag('span', class: "glyphicon glyphicon-#{name}")
end
end
13 changes: 13 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module UsersHelper
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing magic comment # frozen_string_literal: true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing magic comment # frozen_string_literal: true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def genotype_parse_status_label(parse_status)
label_class = case parse_status
when 'queued' then 'label-default'
when 'parsing' then 'label-warning'
when 'done' then 'label-success'
when 'error' then 'label-danger'
end
content_tag('span', parse_status, class: "label #{label_class}")
end
end
6 changes: 6 additions & 0 deletions app/models/genotype.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class Genotype < ActiveRecord::Base
belongs_to :user
has_many :user_snps, dependent: :delete_all
validates_presence_of :user
validates :parse_status, inclusion: { in: %w[queued parsing done error] },
allow_nil: true

has_attached_file :genotype, url: '/data/:fs_filename',
path: "#{Rails.root}/public/data/:fs_filename"
Expand All @@ -14,6 +16,10 @@ class Genotype < ActiveRecord::Base
size: { in: 0..400.megabytes }
do_not_validate_attachment_file_type :genotype

def self.successfully_parsed
where("parse_status IS NULL OR parse_status = 'done'")
end

def is_image?
false
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/genotypes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<td class="table-cell vertical-centered"><%= g.id %></td>
<td class="table-cell vertical-centered"><%= g.created_at%></td>
<td class="table-cell vertical-centered"><%= g.filetype %></td>
<td class="table-cell vertical-centered"><%= link_to "Download", '../data/' + g.fs_filename, class: "btn btn-default" %></td>
<td class="table-cell vertical-centered"><%= download_button(download_genotype_path(g)) %></td>
</tr>
<% end %>
</table>
Expand Down
94 changes: 78 additions & 16 deletions app/views/users/_edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,41 @@
<div id="post_errors" style="display:none"></div>

<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#general" aria-controls="general" role="tab" data-toggle="tab">General</a></li>
<li role="presentation"><a href="#phenotypes" aria-controls="phenotypes" role="tab" data-toggle="tab">Your phenotypes</a></li>
<li role="presentation"><a href="#details" aria-controls="details" role="tab" data-toggle="tab">Details</a></li>
<li role="presentation"><a href="#openhumans" aria-controls="openhumans" role="tab" data-toggle="tab">Open Humans</a></li>
<li role="presentation"><a href="#notifications" aria-controls="notifications" role="tab" data-toggle="tab">Notifications</a></li>
<li role="presentation"><a href="#deleting" aria-controls="deleting" role="tab" data-toggle="tab">Deleting</a></li>
<li role="presentation" class="active">
<a href="#general" aria-controls="general" role="tab" data-toggle="tab">
General
</a>
</li>
<li role="presentation">
<a href="#genotypes" aria-controls="genotypes" role="tab" data-toggle="tab">
Your genotypes
</a>
</li>
<li role="presentation">
<a href="#phenotypes" aria-controls="phenotypes" role="tab" data-toggle="tab">
Your phenotypes
</a>
</li>
<li role="presentation">
<a href="#details" aria-controls="details" role="tab" data-toggle="tab">
Details
</a>
</li>
<li role="presentation">
<a href="#openhumans" aria-controls="openhumans" role="tab" data-toggle="tab">
Open Humans
</a>
</li>
<li role="presentation">
<a href="#notifications" aria-controls="notifications" role="tab" data-toggle="tab">
Notifications
</a>
</li>
<li role="presentation">
<a href="#deleting" aria-controls="deleting" role="tab" data-toggle="tab">
Deleting
</a>
</li>
</ul>

<div class="tab-content">
Expand Down Expand Up @@ -39,8 +68,48 @@
</div>
</div>

<div role="tabpanel" class="tab-pane well tabs__one-tab settings__genotypes" id="genotypes">
<h2 class="tabs__one-tab-title">Your Genotypes</h2>
<%= link_to(t('.genotypes.upload_new'), new_genotype_path, class: 'btn btn-default pull-right') %>
<table class="table">
<thead>
<tr>
<th><%= Genotype.human_attribute_name(:filetype) %></th>
<th><%= Genotype.human_attribute_name(:filename) %></th>
<th><%= Genotype.human_attribute_name(:created_at) %></th>
<th><%= Genotype.human_attribute_name(:parse_status) %></th>
<th><%= t('.genotypes.imported_snps') %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @user.genotypes.order('created_at DESC').each do |genotype| %>
<tr>
<td><%= genotype.filetype %></td>
<td><%= genotype.genotype_file_name %></td>
<td><%= genotype.created_at %></td>
<td><%= genotype_parse_status_label(genotype.parse_status) %></td>
<td><%= genotype.user_snps.count %></td>
<td class="pull-right">
<%= download_button(download_genotype_path(genotype)) %>
<%= delete_button(
genotype,
data: {
confirm: t('.genotypes.confirm_delete', file_name: genotype.genotype_file_name)
}
) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="well well-sm">
<%= t('.genotypes.parse_error_info', error_label: genotype_parse_status_label('error')).html_safe %>
</div>
</div>

<div role="tabpanel" class="tab-pane well tabs__one-tab settings__phenotypes" id="phenotypes">
<h2 class="tabs__one-tab-title">Your Phenotypes</h2>
<h2 class="tabs__one-tab-title">Your Phenotypes</h2>
<div class="row settings__phenotypes-options">
<div class="col-md-offset-1 col-md-4 settings__phenotypes-options-sex">
<h4 class="text-center"><%= f.label :sex, "Chromosomal Sex"%></h4>
Expand Down Expand Up @@ -74,7 +143,7 @@
<%= link_to "Add phenotype", {controller: "phenotypes", action: "new"}, class:"btn btn-default center-block settings__add-phenotype-button" %>
</div>
</div>
</div>
</div>

<div role="tabpanel" class="tab-pane well tabs__one-tab settings__details" id="details">
<div class="clearfix">
Expand Down Expand Up @@ -118,14 +187,7 @@
</dl>
</div>
<div role="tabpanel" class="tab-pane well tabs__one-tab settings__deleting" id="deleting">
<h2 class="tabs__one-tab-title">Deleting</h2>
<h3>Genotypes</h3>
<% if not @user.genotypes.empty? %>
<% @user.genotypes.each do |ug| %>
<p><%= link_to "Genotype #{ug.genotype_file_name}", ug, method: "delete", confirm: "Are you sure you want to delete genotype #{ug.genotype_file_name.to_s}?", class: "btn btn-default settings__deleting-button" %> </p>
<% end %>
<% end %>
<h3>Account</h3>
<h2 class="tabs__one-tab-title">Delete account</h2>
<p><%= link_to "Delete this account", @user, method: "delete", class: "btn btn-default settings__deleting-button", data: { confirm: 'Are you sure you want to delete your account?' } %></p>
</div>

Expand Down
Loading