Skip to content

Instantly share code, notes, and snippets.

View latticetower's full-sized avatar

Tanya Malygina latticetower

View GitHub Profile
type Profile{T}
raw_data :: Array{Char, 2}
data :: Array{Dict{Char, T}, 1}
size :: Int64
Profile(raw :: Array{Char, 2}) = get_pr(raw)
Profile(str :: String) = Profile{T}( reshape([ letter for letter in str ], length(str), 1) )
function get_pr(raw::Array{Char, 2})
raw_data = copy(raw)
@latticetower
latticetower / permutations.Rmd
Last active August 29, 2015 14:11
statistical learning project raw script fragment
```{r}
library(knitr)
library(lattice)
library(MASS)
library(latticeExtra)
library(rgl)
library(hash)
```
```{r}
# from file MASS/R/add.R
# dropterm method redefined
addterm2 <-
function(object, ...) UseMethod("addterm2")
addterm2.default <-
function(object, scope, scale = 0, test = c("none"),
k = 2, sorted = FALSE, trace = FALSE, ...)
{
if(missing(scope) || is.null(scope)) stop("no terms in scope")
@latticetower
latticetower / gist:349fd1477ed2ebc51a34
Last active December 23, 2015 21:49
# The following code solves this problem: http://rosalind.info/problems/glob/ # * it takes data from the input file, in FASTA format (as the problem states). Input file name may be given as a parameter to script # * it writes the result to file named 'output.txt' # * Additionally, it writes to console result && backtracing log # ruby version: 1.…
# The following code solves this problem: http://rosalind.info/problems/glob/
# * it takes data from the input file, in FASTA format (as the problem states). Input file name may be given as a parameter to script
# * it writes the result to file named 'output.txt'
# * Additionally, it writes to console result && backtracing log
# P.S. - Yeees, I know, my english is awful. Please, feel free to review it too =)
#
# ruby version: 1.9.3
# version 1 - doesn't show backtracing
# version 2 - shows some optimal alignment
# version 3 - shows all possible backtracings recursively
require 'rsa' # using rsa gem: http://rsa.rubyforge.org/index.html
# core library has some methods for modular arithmetics, but rsa gem has some additional methods.
# I've tried to use them to find plaintext
# -----------
#known constants
# -------------
E = 29
M_POWER = 3
@latticetower
latticetower / problem4_benchmarker.rb
Last active December 24, 2015 20:09
hw 5 problem 4 solution (Algorithms and datastructures course)
# hw 5 problem 4 solution (Algorithms and datastructures course)
# Problem is stated as follows: as input we get array of n elements a[0].. a[n - 1]
# !!!!!!!!!!!!!! in this code elements numerated from zero index
# must find a way to process it and find l and r indices such that (r - l + 1)*min(a[i], i in [l, r]) is maximized
#
# ruby 1.9.3
require './problem4_functions'
#!~/bin/ruby
require 'ostruct'
require "rubyvis"
require './plotter_utility.rb'
#------------
#
#------------
@latticetower
latticetower / hw7_search_problem.rb
Created October 16, 2013 19:13
hw7 problem 3 (incomplete: works when k<m, k<n, k>1)
# ruby 1.9.3
puts "Print first array elements (divided by spaces):"
a = gets().split(' ').map{|x| x.to_i }.sort #presorted array N1
puts "Print second array elements (divided by spaces):"
b = gets().split(' ').map{|x| x.to_i }.sort #presorted array N2
puts "print k value u wanna get"
k = gets().to_i
@latticetower
latticetower / xmatrix.rb
Last active December 27, 2015 09:18
Unix & script languages, hw3 problem 1
=begin
xmatrix should meet the following conditions:
1. there must be class for 3*3 matrices.
2. There must be class for 3dimentional vectors
3. there must be ancestor of matrix class, describing matrix of rotation near z axis
4. Should overload operations:
- matrix addition
- multiplication by number
- multiplication by vector
- multiplication by matrix
@latticetower
latticetower / xfiles.rb
Last active December 27, 2015 09:18
Unix & script languages, hw3 problem 2
=begin
XFiles should meet the following conditions:
1. there must be class for student with his marks. with the following properties:
- print self with ther format shown as '<Student Full Name>: <mark1> <mark2> ... <markN>'
- should be able to calculate median (mean) mark.
- should be able to add new marks
- construct Student by his full name
2. There also should be class for simple file-based database, which should meet the following conditions:
- class should be initialized by filename, when gets filename - load all information from file specified, thus creating a set (array) of Student objects.
- should have possibility to add, remove students, to output all students to file.