Code Monkey home page Code Monkey logo

elixir-task's Introduction

elixir-task

Development task for Elixir.no position candidates.

Run

From the root of this repo, run the simple test examples as follows:

python src/task.py test/X.s test/Y.s
python src/task.py test/X.f test/Y.f
python src/task.py test/X.f test/Y.s
python src/task.py test/X.s test/Y.f

For the larger test files given in the task (not available in this repo due to their large size), you can run for example:

python src/task.py testfile_a.s testfile_b.f

Things to consider

  • Make separate child classes of a main (maybe abstract?) ElixirTask, each one implementing a subsequent task/method? (be able to expand to more tasks as separate classes vs now that's more like adding new methods to the same class)
  • Optimize calculation of Pearson's correlation coefficient?
  • Faster reading of FUNCTION files?
  • Best alternative to warnings.warn() used?

Inputs

Given two types of text files of genomic information, using the SEGMENT format and the FUNCTION format, as defined below:

SEGMENT (file suffix: ".s")

2 columns tab-separated file containing the coordinates of a set of regions (or segments/intervals) located along the reference DNA of some creature. The 1st column is the start coordinate (starting from 0) and the 2nd column is the end coordinate of the region (end-exclusive). Example:

100	200
300	400

In this task, the regions within one SEGMENT file are not allowed to overlap. i.e.:

100	200
150	250

is not allowed in one file. But

100	200
200	300

is allowed (because of the end-exclusiveness of column 2).

The SEGMENT files are also always in sorted order.

FUNCTION (file suffix: ".f")

One floating point number per position along the genome (i.e. per genome base pair), starting at position 0. E.g.:

25.0
26.0
10.0
11.0
...

The "genome"

The "genome" in this test is just a line of positions from 0 to 10.000.000 (end exclusive). All FUNCTION files must be fully defined, with one value per position. A FUNCTION file thus always has 10 million lines. A SEGMENT file, on the other hand, may have varying number of lines.

Task overview

The program should take two input files. Based on the types of file (SEGMENT or FUNCTION), the program should calculate a value as follows:

  • 2 SEGMENT files: calculate the overlap (in number of positions) of the regions from file X.s with regions from file Y.s.

Example:

file X.s:

1	2
3	6

file Y.s:

0	1
1	5

has an overlap of 3 (i.e. for positions 1, 3 and 4).

Note that the example files shown here have a "genome" of length 7

  • 2 FUNCTION files: calculate the sample Pearson correlation coefficient of the two number lists (see here for the formula)

Example: the two files

X.f

10.0
11.0
12.0
13.0
14.0
15.0
16.0

Y.f

10.5
11.5
12.0
13.0
13.5
15.0
14.0

Have a Pearson correlation of 0.9452853.

  • 1 SEGMENT and 1 FUNCTION file: The mean of the numbers in the FUNCTION file whose positions are covered by the regions in the SEGMENT file. That is, the regions in the SEGMENT file refer to positions on the genome and hence to the index of the lines in the FUNCTION file.

Example: for files X.s and Y.f, the covered numbers are (11.5, 13.0, 13.5, 15.0), which are on lines with index 1,3,4 and 5, the ones covered by the SEGMENT regions. These numbers have a mean of 13.25.

Notes on Implementation

The program should be written in Python, with limited use of external libraries. The goal is to write quick code that still tries to follow good programming practices as regards object-oriented programming, system architecture, unit testing, and such. This is to be regarded as pilot code designed in such a way to support the possible expansion with other file types and analyses in a simple manner. The code does not need to be fully polished, but please comment places where improvements may be made.

Performance is not an issue; a basic Python implementation is enough. However, all combinations of the input files provided should be runnable. Also some thought should be made on the algorithmic performance.

elixir-task's People

Contributors

bblodfon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.