Skip to content

Instantly share code, notes, and snippets.

View raivivek's full-sized avatar
👋

Vivek Rai raivivek

👋
View GitHub Profile
@raivivek
raivivek / Wormhole
Last active December 31, 2015 15:08
Farmer John's hobby of conducting high-energy physics experiments on weekends has backfired, causing
N wormholes (2 <= N <= 12, N even) to materialize on his farm, each located at a distinct point on the 2D map of his farm.
According to his calculations, Farmer John knows that his wormholes will form N/2 connected pairs.
For example, if wormholes A and B are connected as a pair, then any object entering wormhole A will exit wormhole B
moving in the same direction, and any object entering wormhole B will similarly exit from wormhole
A moving in the same direction. This can have rather unpleasant consequences. For example, suppose there are two paired
wormholes A at (0,0) and B at (1,0), and that Bessie the cow starts from position (1/2,0) moving
in the +x direction. Bessie will enter wormhole B, exit from A, then enter B again, and so on, getting
trapped in an infinite cycle! Farmer John knows the exact location of each wormhole on his farm. He
#include <iostream>
#include <vector>
using namespace std;
void calcFibonacci(vector<int> &fibonacci, int no_of_terms) {
fibonacci.push_back(0);
fibonacci.push_back(1);
for(int i=2 ; i < no_of_terms; ++i) {
fibonacci.push_back(fibonacci[i-1]+fibonacci[i-2]);
@raivivek
raivivek / stem_cells.md
Last active August 17, 2018 16:34
Stem Cells!

Introduction

Ever wondered how does a complex multicellular organism develop out of a single zygote after the fertilization? This question took years for scientists to figure out and the answer came to be known in form of Stem Cells. The understanding of Stem cells have revolutionized the field of health, medicine and understanding of biology and evolution on whole.

History

@raivivek
raivivek / rake.txt
Created May 30, 2014 17:44
Afra install
installing gems ...
Using rake (10.1.1)
Using minitest (5.3.4)
Using rack (1.5.2)
Using rack-protection (1.5.3)
Using tilt (1.4.1)
Using sinatra (1.4.5)
Using puma (2.8.2)
Using bcrypt (3.1.7)
Using sequel (4.8.0)
@raivivek
raivivek / blast.xml
Created July 8, 2014 20:03
Blast XML output to Hash
<?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">
<BlastOutput>
<BlastOutput_program>blastp</BlastOutput_program>
<BlastOutput_version>BLASTP 2.2.29+</BlastOutput_version>
<BlastOutput_reference>Stephen F. Altschul, Thomas L. Madden, Alejandro A. Sch&amp;auml;ffer, Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), &quot;Gapped BLAST and PSI-BLAST: a new generation of protein database search programs&quot;, Nucleic Acids Res. 25:3389-3402.</BlastOutput_reference>
<BlastOutput_db>/Users/priyam/biodb/protein/nr/nr /Users/priyam/biodb/protein/Solenopsis_invicta/SI2.2.3.fa</BlastOutput_db>
<BlastOutput_query-ID>Query_1</BlastOutput_query-ID>
<BlastOutput_query-def>gi|323520017|gb|ADX94398.1| OBP1 precursor [Solenopsis invicta]</BlastOutput_query-def>
<BlastOutput_query-len>139</BlastOutput_query-len>
@raivivek
raivivek / blast_format.xml
Created July 12, 2014 19:43
BLAST Output format (XML) - Stripped example.
?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">
<BlastOutput>
<BlastOutput_program>
<BlastOutput_version>
<BlastOutput_reference>
<BlastOutput_db>
<BlastOutput_query-ID>
<BlastOutput_query-def>
<BlastOutput_query-len>
@raivivek
raivivek / lib_blast
Created October 6, 2014 15:01
lib/ss/blast.rb - Rubocop warnings
Inspecting 1 file
C
Offenses:
lib/sequenceserver/blast.rb:114:5: C: Class definition is too long. [147/100]
class Report
^^^^^
lib/sequenceserver/blast.rb:116:7: C: Method has too many lines. [22/10]
def initialize(rfile)
@raivivek
raivivek / code.py
Created January 30, 2015 08:42
code
#!/usr/bin/python3
# -*- coding: utf-8 -*-
""" Calculates the number and percentage composition of different
types of amino acid residues within a protein."""
HYDROPHOBIC_AA = ['ALA', 'GLY', 'VAL', 'ILE', 'LEU', 'PRO']
POSITIVE_AA = ['ARG', 'HIS']
NEGATIVE_AA = ['ASP', 'GLU']
NEUTRAL_AA = ['SER', 'THR', 'HIS', 'CYS', 'MET', 'ASN', 'GLN']
@raivivek
raivivek / seg_fault.txt
Last active August 29, 2015 14:16
scikit-bio
❯ nosetests --with-doctest -v
test_degap (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_distances (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_init_equal_lengths (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_init_not_equal_lengths (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_init_validate (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_iter_positions (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_k_word_frequencies (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_majority_consensus (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
test_omit_gap_positions (skbio.alignment.tests.test_alignment.AlignmentTests) ... ok
@raivivek
raivivek / rex_list.txt
Created March 2, 2016 14:32
A list of random reactions taken from an _E.coli_ model
udpg_e -->
sbt__D_e -->
2dhguln_c + h_c + nadph_c --> idon__L_c + nadp_c
2agpe140_c + atp_c + ttdca_c --> pe140_c + ppi_c + amp_c
3hcinnm_c + o2_c + nadh_c + h_c --> h2o_c + nad_c + dhcinnm_c
h2o_c + adn_c --> ade_c + rib__D_c
duri_e -->
arab__L_c <=> rbl__L_c
hg2_e -->
fum_c + dhor__S_c --> succ_c + orot_c