<commit_before>require 'bio'
require 'query_analysis/upload_cuffdiff.rb'
require 'query_analysis/upload_fasta_sequences.rb'
require 'query_analysis/upload_trinity_with_edger.rb'
require 'query_analysis/find_go_terms_for_dataset.rb'
require 'query_analysis/query_diff_exp_transcripts.rb'
require 'query_analysis/query_transcript_isoforms.rb'
require 'query_analysis/query_diff_exp_genes.rb'
require 'query_analysis/get_gene_fastas.rb'
require 'query_analysis/get_transcript_fasta.rb'
require 'query_analysis/query_using_blastn.rb'
require 'query_analysis/query_using_tblastn.rb'
require 'query_analysis/query_using_tblastx.rb'

class QueryAnalysisController < ApplicationController
    
    before_filter :authenticate_user!
    
    before_filter :confirm_datasets_available, 
      :only => [
        :query_diff_exp_transcripts, 
        :get_transcript_diff_exp_samples_for_dataset, 
        :query_diff_exp_genes, 
        :get_gene_diff_exp_samples_for_dataset,
        :query_transcript_isoforms, 
        :get_transcript_isoforms_samples_for_dataset,
        :get_transcript_fasta, :get_gene_fastas,
        :query_using_blastn, :query_using_tblastn, :query_using_tblastx,
        :get_blastn_gap_costs_for_match_and_mismatch_scores,
        :get_tblastn_gap_costs_for_matrix
      ]
    before_filter :confirm_transcript_isoform_datasets_available,
      :only => [
        :query_transcript_isoforms,
        :get_transcript_isoforms_samples_for_dataset
      ]
    before_filter :confirm_transcript_diff_exp_datasets_available, 
      :only => [
        :query_diff_exp_transcripts,
        :get_transcript_diff_exp_samples_for_dataset
      ]
    before_filter :confirm_gene_diff_exp_datasets_available, 
      :only => [
        :query_diff_exp_genes,
        :get_gene_diff_exp_samples_for_dataset
      ]
    before_filter :confirm_datasets_without_go_terms_available,
      :only => [:find_go_terms_for_dataset]
      
    
    def upload_cuffdiff
      if request.get?
        @upload_cuffdiff = UploadCuffdiff.new(current_user)
        @upload_cuffdiff.set_attributes_and_defaults()
      elsif request.post?
        @upload_cuffdiff = UploadCuffdiff.new(current_user)
        @upload_cuffdiff.set_attributes_and_defaults(params[:upload_cuffdiff])
        if (@upload_cuffdiff.valid?)
          SuckerPunch::Queue[:upload_cuffdiff_queue].async.perform(@upload_cuffdiff)
          flash[:notice] = I18n.t :added_to_upload_queue, 
                                   :name => @upload.dataset_name
          #Reset the upload cuffdiff form
          @upload_cuffdiff = UploadCuffdiff.new(current_user)<commit_msg>Fixed a small bug in the query analysis controller.<commit_after>require 'bio'
require 'query_analysis/upload_cuffdiff.rb'
require 'query_analysis/upload_fasta_sequences.rb'
require 'query_analysis/upload_trinity_with_edger.rb'
require 'query_analysis/find_go_terms_for_dataset.rb'
require 'query_analysis/query_diff_exp_transcripts.rb'
require 'query_analysis/query_transcript_isoforms.rb'
require 'query_analysis/query_diff_exp_genes.rb'
require 'query_analysis/get_gene_fastas.rb'
require 'query_analysis/get_transcript_fasta.rb'
require 'query_analysis/query_using_blastn.rb'
require 'query_analysis/query_using_tblastn.rb'
require 'query_analysis/query_using_tblastx.rb'

class QueryAnalysisController < ApplicationController
    
    before_filter :authenticate_user!
    
    before_filter :confirm_datasets_available, 
      :only => [
        :query_diff_exp_transcripts, 
        :get_transcript_diff_exp_samples_for_dataset, 
        :query_diff_exp_genes, 
        :get_gene_diff_exp_samples_for_dataset,
        :query_transcript_isoforms, 
        :get_transcript_isoforms_samples_for_dataset,
        :get_transcript_fasta, :get_gene_fastas,
        :query_using_blastn, :query_using_tblastn, :query_using_tblastx,
        :get_blastn_gap_costs_for_match_and_mismatch_scores,
        :get_tblastn_gap_costs_for_matrix
      ]
    before_filter :confirm_transcript_isoform_datasets_available,
      :only => [
        :query_transcript_isoforms,
        :get_transcript_isoforms_samples_for_dataset
      ]
    before_filter :confirm_transcript_diff_exp_datasets_available, 
      :only => [
        :query_diff_exp_transcripts,
        :get_transcript_diff_exp_samples_for_dataset
      ]
    before_filter :confirm_gene_diff_exp_datasets_available, 
      :only => [
        :query_diff_exp_genes,
        :get_gene_diff_exp_samples_for_dataset
      ]
    before_filter :confirm_datasets_without_go_terms_available,
      :only => [:find_go_terms_for_dataset]
      
    
    def upload_cuffdiff
      if request.get?
        @upload_cuffdiff = UploadCuffdiff.new(current_user)
        @upload_cuffdiff.set_attributes_and_defaults()
      elsif request.post?
        @upload_cuffdiff = UploadCuffdiff.new(current_user)
        @upload_cuffdiff.set_attributes_and_defaults(params[:upload_cuffdiff])
        if (@upload_cuffdiff.valid?)
          SuckerPunch::Queue[:upload_cuffdiff_queue].async.perform(@upload_cuffdiff)
          flash[:notice] = I18n.t :added_to_upload_queue, 
                                  :name => @upload_cuffdiff.dataset_name
          #Reset the upload cuffdiff form
          @upload_cuffdiff = UploadCuffdiff.new(current_user)
{'fraction_non_alphanumeric': 0.0696489241223103, 'fraction_numerical': 0.0007550018875047187, 'mean_word_length': 4.10009624639076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5315209', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1697, 'n_words': 193}