{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "mkdir -p /mnt/storage/r0303410/jupyternotebooks\n",
    "cd /mnt/storage/r0303410/jupyternotebooks\n",
    "ln -sf /mnt/storage/r0303410/chipseq/* ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Read 34217500 spots for SRR771829.sra\r\n",
      "Written 34217500 spots for SRR771829.sra\r\n",
      "Read 34344609 spots for SRR771830.sra\r\n",
      "Written 34344609 spots for SRR771830.sra\r\n"
     ]
    }
   ],
   "source": [
    "fastq-dump SRR771829.sra --split-files \n",
    "fastq-dump SRR771830.sra --split-files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Settings:\r\n",
      "  Output files: \"hCHR8.*.bt2\"\r\n",
      "  Line rate: 6 (line is 64 bytes)\r\n",
      "  Lines per side: 1 (side is 64 bytes)\r\n",
      "  Offset rate: 4 (one in 16)\r\n",
      "  FTable chars: 10\r\n",
      "  Strings: unpacked\r\n",
      "  Max bucket size: default\r\n",
      "  Max bucket size, sqrt multiplier: default\r\n",
      "  Max bucket size, len divisor: 4\r\n",
      "  Difference-cover sample period: 1024\r\n",
      "  Endianness: little\r\n",
      "  Actual local endianness: little\r\n",
      "  Sanity checking: disabled\r\n",
      "  Assertions: disabled\r\n",
      "  Random seed: 0\r\n",
      "  Sizeofs: void*:8, int:4, long:8, size_t:8\r\n",
      "Input files DNA, FASTA:\r\n",
      "  chr8.fa\r\n",
      "Reading reference sizes\r\n",
      "  Time reading reference sizes: 00:00:01\r\n",
      "Calculating joined length\r\n",
      "Writing header\r\n",
      "Reserving space for joined string\r\n",
      "Joining reference sequences\r\n",
      "  Time to join reference sequences: 00:00:02\r\n",
      "bmax according to bmaxDivN setting: 35722230\r\n",
      "Using parameters --bmax 26791673 --dcv 1024\r\n",
      "  Doing ahead-of-time memory usage test\r\n",
      "  Passed!  Constructing with these parameters: --bmax 26791673 --dcv 1024\r\n",
      "Constructing suffix-array element generator\r\n",
      "Building DifferenceCoverSample\r\n",
      "  Building sPrime\r\n",
      "  Building sPrimeOrder\r\n",
      "  V-Sorting samples\r\n",
      "  V-Sorting samples time: 00:00:02\r\n",
      "  Allocating rank array\r\n",
      "  Ranking v-sort output\r\n",
      "  Ranking v-sort output time: 00:00:01\r\n",
      "  Invoking Larsson-Sadakane on ranks\r\n",
      "  Invoking Larsson-Sadakane on ranks time: 00:00:01\r\n",
      "  Sanity-checking and returning\r\n",
      "Building samples\r\n",
      "Reserving space for 12 sample suffixes\r\n",
      "Generating random suffixes\r\n",
      "QSorting 12 sample offsets, eliminating duplicates\r\n",
      "QSorting sample offsets, eliminating duplicates time: 00:00:00\r\n",
      "Multikey QSorting 12 samples\r\n",
      "  (Using difference cover)\r\n",
      "  Multikey QSorting samples time: 00:00:00\r\n",
      "Calculating bucket sizes\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:05\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Split 2, merged 6; iterating...\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:04\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Avg bucket size: 1.78611e+07 (target: 26791672)\r\n",
      "Converting suffix-array elements to index image\r\n",
      "Allocating ftab, absorbFtab\r\n",
      "Entering Ebwt loop\r\n",
      "Getting block 1 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 20814389\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:04\r\n",
      "Returning block of 20814390\r\n",
      "Getting block 2 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 13669349\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 13669350\r\n",
      "Getting block 3 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 21615161\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:04\r\n",
      "Returning block of 21615162\r\n",
      "Getting block 4 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 25490896\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:05\r\n",
      "Returning block of 25490897\r\n",
      "Getting block 5 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 15371727\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:03\r\n",
      "Returning block of 15371728\r\n",
      "Getting block 6 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 13371325\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 13371326\r\n",
      "Getting block 7 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 16004185\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:03\r\n",
      "Returning block of 16004186\r\n",
      "Getting block 8 of 8\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 16551883\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:03\r\n",
      "Returning block of 16551884\r\n",
      "Exited Ebwt loop\r\n",
      "fchr[A]: 0\r\n",
      "fchr[C]: 42767293\r\n",
      "fchr[G]: 71471276\r\n",
      "fchr[T]: 100173897\r\n",
      "fchr[$]: 142888922\r\n",
      "Exiting Ebwt::buildToDisk()\r\n",
      "Returning from initFromVector\r\n",
      "Wrote 51824250 bytes to primary EBWT file: hCHR8.1.bt2\r\n",
      "Wrote 35722236 bytes to secondary EBWT file: hCHR8.2.bt2\r\n",
      "Re-opening _in1 and _in2 as input streams\r\n",
      "Returning from Ebwt constructor\r\n",
      "Headers:\r\n",
      "    len: 142888922\r\n",
      "    bwtLen: 142888923\r\n",
      "    sz: 35722231\r\n",
      "    bwtSz: 35722231\r\n",
      "    lineRate: 6\r\n",
      "    offRate: 4\r\n",
      "    offMask: 0xfffffff0\r\n",
      "    ftabChars: 10\r\n",
      "    eftabLen: 20\r\n",
      "    eftabSz: 80\r\n",
      "    ftabLen: 1048577\r\n",
      "    ftabSz: 4194308\r\n",
      "    offsLen: 8930558\r\n",
      "    offsSz: 35722232\r\n",
      "    lineSz: 64\r\n",
      "    sideSz: 64\r\n",
      "    sideBwtSz: 48\r\n",
      "    sideBwtLen: 192\r\n",
      "    numSides: 744214\r\n",
      "    numLines: 744214\r\n",
      "    ebwtTotLen: 47629696\r\n",
      "    ebwtTotSz: 47629696\r\n",
      "    color: 0\r\n",
      "    reverse: 0\r\n",
      "Total time for call to driver() for forward index: 00:01:07\r\n",
      "Reading reference sizes\r\n",
      "  Time reading reference sizes: 00:00:01\r\n",
      "Calculating joined length\r\n",
      "Writing header\r\n",
      "Reserving space for joined string\r\n",
      "Joining reference sequences\r\n",
      "  Time to join reference sequences: 00:00:01\r\n",
      "  Time to reverse reference sequence: 00:00:00\r\n",
      "bmax according to bmaxDivN setting: 35722230\r\n",
      "Using parameters --bmax 26791673 --dcv 1024\r\n",
      "  Doing ahead-of-time memory usage test\r\n",
      "  Passed!  Constructing with these parameters: --bmax 26791673 --dcv 1024\r\n",
      "Constructing suffix-array element generator\r\n",
      "Building DifferenceCoverSample\r\n",
      "  Building sPrime\r\n",
      "  Building sPrimeOrder\r\n",
      "  V-Sorting samples\r\n",
      "  V-Sorting samples time: 00:00:02\r\n",
      "  Allocating rank array\r\n",
      "  Ranking v-sort output\r\n",
      "  Ranking v-sort output time: 00:00:00\r\n",
      "  Invoking Larsson-Sadakane on ranks\r\n",
      "  Invoking Larsson-Sadakane on ranks time: 00:00:01\r\n",
      "  Sanity-checking and returning\r\n",
      "Building samples\r\n",
      "Reserving space for 12 sample suffixes\r\n",
      "Generating random suffixes\r\n",
      "QSorting 12 sample offsets, eliminating duplicates\r\n",
      "QSorting sample offsets, eliminating duplicates time: 00:00:00\r\n",
      "Multikey QSorting 12 samples\r\n",
      "  (Using difference cover)\r\n",
      "  Multikey QSorting samples time: 00:00:00\r\n",
      "Calculating bucket sizes\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:05\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Split 1, merged 6; iterating...\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:03\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Avg bucket size: 2.04127e+07 (target: 26791672)\r\n",
      "Converting suffix-array elements to index image\r\n",
      "Allocating ftab, absorbFtab\r\n",
      "Entering Ebwt loop\r\n",
      "Getting block 1 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 23069782\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:04\r\n",
      "Returning block of 23069783\r\n",
      "Getting block 2 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 20464913\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:03\r\n",
      "Returning block of 20464914\r\n",
      "Getting block 3 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 22180666\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:04\r\n",
      "Returning block of 22180667\r\n",
      "Getting block 4 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 19784382\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:03\r\n",
      "Returning block of 19784383\r\n",
      "Getting block 5 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 12359611\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 12359612\r\n",
      "Getting block 6 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 24097898\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:04\r\n",
      "Returning block of 24097899\r\n",
      "Getting block 7 of 7\r\n",
      "  Reserving size (26791673) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:02\r\n",
      "  Sorting block of length 20931664\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:03\r\n",
      "Returning block of 20931665\r\n",
      "Exited Ebwt loop\r\n",
      "fchr[A]: 0\r\n",
      "fchr[C]: 42767293\r\n",
      "fchr[G]: 71471276\r\n",
      "fchr[T]: 100173897\r\n",
      "fchr[$]: 142888922\r\n",
      "Exiting Ebwt::buildToDisk()\r\n",
      "Returning from initFromVector\r\n",
      "Wrote 51824250 bytes to primary EBWT file: hCHR8.rev.1.bt2\r\n",
      "Wrote 35722236 bytes to secondary EBWT file: hCHR8.rev.2.bt2\r\n",
      "Re-opening _in1 and _in2 as input streams\r\n",
      "Returning from Ebwt constructor\r\n",
      "Headers:\r\n",
      "    len: 142888922\r\n",
      "    bwtLen: 142888923\r\n",
      "    sz: 35722231\r\n",
      "    bwtSz: 35722231\r\n",
      "    lineRate: 6\r\n",
      "    offRate: 4\r\n",
      "    offMask: 0xfffffff0\r\n",
      "    ftabChars: 10\r\n",
      "    eftabLen: 20\r\n",
      "    eftabSz: 80\r\n",
      "    ftabLen: 1048577\r\n",
      "    ftabSz: 4194308\r\n",
      "    offsLen: 8930558\r\n",
      "    offsSz: 35722232\r\n",
      "    lineSz: 64\r\n",
      "    sideSz: 64\r\n",
      "    sideBwtSz: 48\r\n",
      "    sideBwtLen: 192\r\n",
      "    numSides: 744214\r\n",
      "    numLines: 744214\r\n",
      "    ebwtTotLen: 47629696\r\n",
      "    ebwtTotSz: 47629696\r\n",
      "    color: 0\r\n",
      "    reverse: 1\r\n",
      "Total time for backward call to driver() for mirror index: 00:01:03\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-build chr8.fa hCHR8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Settings:\r\n",
      "  Output files: \"hCHR17.*.bt2\"\r\n",
      "  Line rate: 6 (line is 64 bytes)\r\n",
      "  Lines per side: 1 (side is 64 bytes)\r\n",
      "  Offset rate: 4 (one in 16)\r\n",
      "  FTable chars: 10\r\n",
      "  Strings: unpacked\r\n",
      "  Max bucket size: default\r\n",
      "  Max bucket size, sqrt multiplier: default\r\n",
      "  Max bucket size, len divisor: 4\r\n",
      "  Difference-cover sample period: 1024\r\n",
      "  Endianness: little\r\n",
      "  Actual local endianness: little\r\n",
      "  Sanity checking: disabled\r\n",
      "  Assertions: disabled\r\n",
      "  Random seed: 0\r\n",
      "  Sizeofs: void*:8, int:4, long:8, size_t:8\r\n",
      "Input files DNA, FASTA:\r\n",
      "  chr17.fa\r\n",
      "Reading reference sizes\r\n",
      "  Time reading reference sizes: 00:00:01\r\n",
      "Calculating joined length\r\n",
      "Writing header\r\n",
      "Reserving space for joined string\r\n",
      "Joining reference sequences\r\n",
      "  Time to join reference sequences: 00:00:01\r\n",
      "bmax according to bmaxDivN setting: 19448802\r\n",
      "Using parameters --bmax 14586602 --dcv 1024\r\n",
      "  Doing ahead-of-time memory usage test\r\n",
      "  Passed!  Constructing with these parameters: --bmax 14586602 --dcv 1024\r\n",
      "Constructing suffix-array element generator\r\n",
      "Building DifferenceCoverSample\r\n",
      "  Building sPrime\r\n",
      "  Building sPrimeOrder\r\n",
      "  V-Sorting samples\r\n",
      "  V-Sorting samples time: 00:00:00\r\n",
      "  Allocating rank array\r\n",
      "  Ranking v-sort output\r\n",
      "  Ranking v-sort output time: 00:00:01\r\n",
      "  Invoking Larsson-Sadakane on ranks\r\n",
      "  Invoking Larsson-Sadakane on ranks time: 00:00:00\r\n",
      "  Sanity-checking and returning\r\n",
      "Building samples\r\n",
      "Reserving space for 12 sample suffixes\r\n",
      "Generating random suffixes\r\n",
      "QSorting 12 sample offsets, eliminating duplicates\r\n",
      "QSorting sample offsets, eliminating duplicates time: 00:00:00\r\n",
      "Multikey QSorting 12 samples\r\n",
      "  (Using difference cover)\r\n",
      "  Multikey QSorting samples time: 00:00:00\r\n",
      "Calculating bucket sizes\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:02\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Split 1, merged 6; iterating...\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:02\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Split 1, merged 1; iterating...\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:02\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Avg bucket size: 9.7244e+06 (target: 14586601)\r\n",
      "Converting suffix-array elements to index image\r\n",
      "Allocating ftab, absorbFtab\r\n",
      "Entering Ebwt loop\r\n",
      "Getting block 1 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 10276307\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 10276308\r\n",
      "Getting block 2 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 9223491\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 9223492\r\n",
      "Getting block 3 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 7107629\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:01\r\n",
      "Returning block of 7107630\r\n",
      "Getting block 4 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 11450108\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:01\r\n",
      "Returning block of 11450109\r\n",
      "Getting block 5 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 13484959\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 13484960\r\n",
      "Getting block 6 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 3607715\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:01\r\n",
      "Returning block of 3607716\r\n",
      "Getting block 7 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 11011055\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 11011056\r\n",
      "Getting block 8 of 8\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:00\r\n",
      "  Sorting block of length 11633939\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 11633940\r\n",
      "Exited Ebwt loop\r\n",
      "fchr[A]: 0\r\n",
      "fchr[C]: 21159933\r\n",
      "fchr[G]: 38887889\r\n",
      "fchr[T]: 56588229\r\n",
      "fchr[$]: 77795210\r\n",
      "Exiting Ebwt::buildToDisk()\r\n",
      "Returning from initFromVector\r\n",
      "Wrote 30126331 bytes to primary EBWT file: hCHR17.1.bt2\r\n",
      "Wrote 19448808 bytes to secondary EBWT file: hCHR17.2.bt2\r\n",
      "Re-opening _in1 and _in2 as input streams\r\n",
      "Returning from Ebwt constructor\r\n",
      "Headers:\r\n",
      "    len: 77795210\r\n",
      "    bwtLen: 77795211\r\n",
      "    sz: 19448803\r\n",
      "    bwtSz: 19448803\r\n",
      "    lineRate: 6\r\n",
      "    offRate: 4\r\n",
      "    offMask: 0xfffffff0\r\n",
      "    ftabChars: 10\r\n",
      "    eftabLen: 20\r\n",
      "    eftabSz: 80\r\n",
      "    ftabLen: 1048577\r\n",
      "    ftabSz: 4194308\r\n",
      "    offsLen: 4862201\r\n",
      "    offsSz: 19448804\r\n",
      "    lineSz: 64\r\n",
      "    sideSz: 64\r\n",
      "    sideBwtSz: 48\r\n",
      "    sideBwtLen: 192\r\n",
      "    numSides: 405184\r\n",
      "    numLines: 405184\r\n",
      "    ebwtTotLen: 25931776\r\n",
      "    ebwtTotSz: 25931776\r\n",
      "    color: 0\r\n",
      "    reverse: 0\r\n",
      "Total time for call to driver() for forward index: 00:00:35\r\n",
      "Reading reference sizes\r\n",
      "  Time reading reference sizes: 00:00:00\r\n",
      "Calculating joined length\r\n",
      "Writing header\r\n",
      "Reserving space for joined string\r\n",
      "Joining reference sequences\r\n",
      "  Time to join reference sequences: 00:00:01\r\n",
      "  Time to reverse reference sequence: 00:00:00\r\n",
      "bmax according to bmaxDivN setting: 19448802\r\n",
      "Using parameters --bmax 14586602 --dcv 1024\r\n",
      "  Doing ahead-of-time memory usage test\r\n",
      "  Passed!  Constructing with these parameters: --bmax 14586602 --dcv 1024\r\n",
      "Constructing suffix-array element generator\r\n",
      "Building DifferenceCoverSample\r\n",
      "  Building sPrime\r\n",
      "  Building sPrimeOrder\r\n",
      "  V-Sorting samples\r\n",
      "  V-Sorting samples time: 00:00:00\r\n",
      "  Allocating rank array\r\n",
      "  Ranking v-sort output\r\n",
      "  Ranking v-sort output time: 00:00:01\r\n",
      "  Invoking Larsson-Sadakane on ranks\r\n",
      "  Invoking Larsson-Sadakane on ranks time: 00:00:00\r\n",
      "  Sanity-checking and returning\r\n",
      "Building samples\r\n",
      "Reserving space for 12 sample suffixes\r\n",
      "Generating random suffixes\r\n",
      "QSorting 12 sample offsets, eliminating duplicates\r\n",
      "QSorting sample offsets, eliminating duplicates time: 00:00:00\r\n",
      "Multikey QSorting 12 samples\r\n",
      "  (Using difference cover)\r\n",
      "  Multikey QSorting samples time: 00:00:00\r\n",
      "Calculating bucket sizes\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:03\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Split 1, merged 8; iterating...\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:01\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Split 1, merged 0; iterating...\r\n",
      "  Binary sorting into buckets\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Binary sorting into buckets time: 00:00:03\r\n",
      "Splitting and merging\r\n",
      "  Splitting and merging time: 00:00:00\r\n",
      "Avg bucket size: 1.11136e+07 (target: 14586601)\r\n",
      "Converting suffix-array elements to index image\r\n",
      "Allocating ftab, absorbFtab\r\n",
      "Entering Ebwt loop\r\n",
      "Getting block 1 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:00\r\n",
      "  Sorting block of length 8569050\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 8569051\r\n",
      "Getting block 2 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 12590881\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 12590882\r\n",
      "Getting block 3 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 12262409\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 12262410\r\n",
      "Getting block 4 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 4970518\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:00\r\n",
      "Returning block of 4970519\r\n",
      "Getting block 5 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 14347395\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 14347396\r\n",
      "Getting block 6 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:01\r\n",
      "  Sorting block of length 12493610\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 12493611\r\n",
      "Getting block 7 of 7\r\n",
      "  Reserving size (14586602) for bucket\r\n",
      "  Calculating Z arrays\r\n",
      "  Calculating Z arrays time: 00:00:00\r\n",
      "  Entering block accumulator loop:\r\n",
      "  10%\r\n",
      "  20%\r\n",
      "  30%\r\n",
      "  40%\r\n",
      "  50%\r\n",
      "  60%\r\n",
      "  70%\r\n",
      "  80%\r\n",
      "  90%\r\n",
      "  100%\r\n",
      "  Block accumulator loop time: 00:00:00\r\n",
      "  Sorting block of length 12561341\r\n",
      "  (Using difference cover)\r\n",
      "  Sorting block time: 00:00:02\r\n",
      "Returning block of 12561342\r\n",
      "Exited Ebwt loop\r\n",
      "fchr[A]: 0\r\n",
      "fchr[C]: 21159933\r\n",
      "fchr[G]: 38887889\r\n",
      "fchr[T]: 56588229\r\n",
      "fchr[$]: 77795210\r\n",
      "Exiting Ebwt::buildToDisk()\r\n",
      "Returning from initFromVector\r\n",
      "Wrote 30126331 bytes to primary EBWT file: hCHR17.rev.1.bt2\r\n",
      "Wrote 19448808 bytes to secondary EBWT file: hCHR17.rev.2.bt2\r\n",
      "Re-opening _in1 and _in2 as input streams\r\n",
      "Returning from Ebwt constructor\r\n",
      "Headers:\r\n",
      "    len: 77795210\r\n",
      "    bwtLen: 77795211\r\n",
      "    sz: 19448803\r\n",
      "    bwtSz: 19448803\r\n",
      "    lineRate: 6\r\n",
      "    offRate: 4\r\n",
      "    offMask: 0xfffffff0\r\n",
      "    ftabChars: 10\r\n",
      "    eftabLen: 20\r\n",
      "    eftabSz: 80\r\n",
      "    ftabLen: 1048577\r\n",
      "    ftabSz: 4194308\r\n",
      "    offsLen: 4862201\r\n",
      "    offsSz: 19448804\r\n",
      "    lineSz: 64\r\n",
      "    sideSz: 64\r\n",
      "    sideBwtSz: 48\r\n",
      "    sideBwtLen: 192\r\n",
      "    numSides: 405184\r\n",
      "    numLines: 405184\r\n",
      "    ebwtTotLen: 25931776\r\n",
      "    ebwtTotSz: 25931776\r\n",
      "    color: 0\r\n",
      "    reverse: 1\r\n",
      "Total time for backward call to driver() for mirror index: 00:00:32\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-build chr17.fa hCHR17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34217500 reads; of these:\r\n",
      "  34217500 (100.00%) were unpaired; of these:\r\n",
      "    28870183 (84.37%) aligned 0 times\r\n",
      "    1829409 (5.35%) aligned exactly 1 time\r\n",
      "    3517908 (10.28%) aligned >1 times\r\n",
      "15.63% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x hCHR8 SRR771829_1.fastq -S ctrl_chr8.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34344609 reads; of these:\r\n",
      "  34344609 (100.00%) were unpaired; of these:\r\n",
      "    29007474 (84.46%) aligned 0 times\r\n",
      "    1816590 (5.29%) aligned exactly 1 time\r\n",
      "    3520545 (10.25%) aligned >1 times\r\n",
      "15.54% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x hCHR8 SRR771830_1.fastq -S UBN1_chr8.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34217500 reads; of these:\r\n",
      "  34217500 (100.00%) were unpaired; of these:\r\n",
      "    29770795 (87.00%) aligned 0 times\r\n",
      "    1202842 (3.52%) aligned exactly 1 time\r\n",
      "    3243863 (9.48%) aligned >1 times\r\n",
      "13.00% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x hCHR17 SRR771829_1.fastq -S ctrl_chr17.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34344609 reads; of these:\r\n",
      "  34344609 (100.00%) were unpaired; of these:\r\n",
      "    29862933 (86.95%) aligned 0 times\r\n",
      "    1196512 (3.48%) aligned exactly 1 time\r\n",
      "    3285164 (9.57%) aligned >1 times\r\n",
      "13.05% overall alignment rate\r\n"
     ]
    }
   ],
   "source": [
    "bowtie2-align -x hCHR17 SRR771830_1.fastq -S UBN1_chr17.sam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b UBN1_chr8.sam > UBN1_chr8.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b ctrl_chr8.sam > ctrl_chr8.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b UBN1_chr17.sam > UBN1_chr17.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools view -S -b ctrl_chr17.sam > ctrl_chr17.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 14 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o UBN1_chr8.sorted.bam UBN1_chr8.bam "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 14 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o ctrl_chr8.sorted.bam ctrl_chr8.bam "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 14 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o UBN1_chr17.sorted.bam UBN1_chr17.bam  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[bam_sort_core] merging from 14 files...\r\n"
     ]
    }
   ],
   "source": [
    "samtools sort -O bam -o ctrl_chr17.sorted.bam ctrl_chr17.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index UBN1_chr8.sorted.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index ctrl_chr8.sorted.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index UBN1_chr17.sorted.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": []
    }
   ],
   "source": [
    "samtools index ctrl_chr17.sorted.bam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ Thu, 29 Dec 2016 12:09:51: \r\n",
      "# Command line: callpeak -t UBN1_chr8.sorted.bam -c ctrl_chr8.sorted.bam -f BAM -g 146364022 -n UBN1_chr8_peak -q 0.005\r\n",
      "# ARGUMENTS LIST:\r\n",
      "# name = UBN1_chr8_peak\r\n",
      "# format = BAM\r\n",
      "# ChIP-seq file = ['UBN1_chr8.sorted.bam']\r\n",
      "# control file = ['ctrl_chr8.sorted.bam']\r\n",
      "# effective genome size = 1.46e+08\r\n",
      "# band width = 300\r\n",
      "# model fold = [5, 50]\r\n",
      "# qvalue cutoff = 5.00e-03\r\n",
      "# Larger dataset will be scaled towards smaller dataset.\r\n",
      "# Range for calculating regional lambda is: 1000 bps and 10000 bps\r\n",
      "# Broad region calling is off\r\n",
      " \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:09:51: #1 read tag files... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:09:51: #1 read treatment tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:09:56:  1000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:01:  2000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:06:  3000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:11:  4000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:16:  5000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:20:  6000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:23:  7000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:25:  8000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:28:  9000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:31:  10000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:34:  11000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:36:  12000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:39:  13000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:42:  14000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:44:  15000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:47:  16000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:50:  17000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:52:  18000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:55:  19000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:10:58:  20000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:01:  21000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:03:  22000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:06:  23000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:09:  24000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:11:  25000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:14:  26000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:17:  27000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:20:  28000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:22:  29000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:25:  30000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:28:  31000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:30:  32000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:33:  33000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:36:  34000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:37: #1.2 read input tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:42:  1000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:47:  2000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:52:  3000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:11:57:  4000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:02:  5000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:06:  6000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:09:  7000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:11:  8000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:14:  9000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:17:  10000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:20:  11000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:22:  12000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:25:  13000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:28:  14000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:31:  15000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:33:  16000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:36:  17000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:39:  18000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:41:  19000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:44:  20000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:46:  21000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:48:  22000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:50:  23000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:53:  24000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:56:  25000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:12:58:  26000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:01:  27000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:04:  28000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:07:  29000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:09:  30000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:12:  31000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:15:  32000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:18:  33000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21:  34000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 tag size is determined as 76 bps \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 tag size = 76 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1  total tags in treatment: 5337135 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 user defined the maximum tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1  tags after filtering in treatment: 4021145 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1  Redundant rate of treatment: 0.25 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1  total tags in control: 5347317 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 user defined the maximum tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1  tags after filtering in control: 4430392 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1  Redundant rate of control: 0.17 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #1 finished! \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #2 Build Peak Model... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:21: #2 looking for paired plus/minus strand peaks... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #2 number of paired peaks: 8681 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: start model_add_line... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: start X-correlation... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: end of X-cor \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #2 finished! \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #2 predicted fragment length is 75 bps \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #2 alternative fragment length(s) may be 75 bps \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #2.2 Generate R script for model : UBN1_chr8_peak_model.r \r\n",
      "WARNING @ Thu, 29 Dec 2016 12:13:22: #2 Since the d (75) calculated from paired-peaks are smaller than 2*tag length, it may be influenced by unknown sequencing problem! \r\n",
      "WARNING @ Thu, 29 Dec 2016 12:13:22: #2 You may need to consider one of the other alternative d(s): 75 \r\n",
      "WARNING @ Thu, 29 Dec 2016 12:13:22: #2 You can restart the process with --nomodel --extsize XXX with your choice or an arbitrary number. Nontheless, MACS will continute computing. \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #3 Call peaks... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:22: #3 Pre-compute pvalue-qvalue table... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:42: #3 Call peaks for each chromosome... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:52: #4 Write output xls file... UBN1_chr8_peak_peaks.xls \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:52: #4 Write peak in narrowPeak format file... UBN1_chr8_peak_peaks.narrowPeak \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:52: #4 Write summits bed file... UBN1_chr8_peak_summits.bed \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:52: Done! \r\n"
     ]
    }
   ],
   "source": [
    "macs2 callpeak -t  UBN1_chr8.sorted.bam -c ctrl_chr8.sorted.bam -f BAM -g 146364022 -n UBN1_chr8_peak -q 0.005"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO  @ Thu, 29 Dec 2016 12:13:53: \r\n",
      "# Command line: callpeak -t UBN1_chr17.sorted.bam -c ctrl_chr17.sorted.bam -f BAM -g 81195210 -n UBN1_chr17_peak -q 0.005\r\n",
      "# ARGUMENTS LIST:\r\n",
      "# name = UBN1_chr17_peak\r\n",
      "# format = BAM\r\n",
      "# ChIP-seq file = ['UBN1_chr17.sorted.bam']\r\n",
      "# control file = ['ctrl_chr17.sorted.bam']\r\n",
      "# effective genome size = 8.12e+07\r\n",
      "# band width = 300\r\n",
      "# model fold = [5, 50]\r\n",
      "# qvalue cutoff = 5.00e-03\r\n",
      "# Larger dataset will be scaled towards smaller dataset.\r\n",
      "# Range for calculating regional lambda is: 1000 bps and 10000 bps\r\n",
      "# Broad region calling is off\r\n",
      " \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:53: #1 read tag files... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:53: #1 read treatment tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:13:58:  1000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:02:  2000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:06:  3000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:11:  4000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:14:  5000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:16:  6000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:18:  7000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:20:  8000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:22:  9000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:24:  10000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:27:  11000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:29:  12000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:31:  13000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:33:  14000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:35:  15000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:37:  16000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:40:  17000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:42:  18000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:44:  19000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:46:  20000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:48:  21000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:51:  22000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:53:  23000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:56:  24000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:14:59:  25000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:01:  26000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:03:  27000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:06:  28000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:08:  29000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:10:  30000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:12:  31000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:14:  32000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:16:  33000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:19:  34000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:19: #1.2 read input tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:24:  1000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:28:  2000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:33:  3000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:37:  4000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:40:  5000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:42:  6000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:44:  7000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:46:  8000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:49:  9000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:51:  10000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:53:  11000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:55:  12000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:57:  13000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:15:59:  14000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:02:  15000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:04:  16000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:06:  17000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:08:  18000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:10:  19000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:12:  20000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:14:  21000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:17:  22000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:19:  23000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:21:  24000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:23:  25000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:25:  26000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:27:  27000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:30:  28000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:32:  29000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:34:  30000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:36:  31000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:38:  32000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:41:  33000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43:  34000000 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 tag size is determined as 76 bps \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 tag size = 76 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1  total tags in treatment: 4481676 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 user defined the maximum tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1  tags after filtering in treatment: 3116911 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1  Redundant rate of treatment: 0.30 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1  total tags in control: 4446705 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 user defined the maximum tags... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s) \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1  tags after filtering in control: 3261108 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1  Redundant rate of control: 0.27 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #1 finished! \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #2 Build Peak Model... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:43: #2 looking for paired plus/minus strand peaks... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #2 number of paired peaks: 2900 \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: start model_add_line... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: start X-correlation... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: end of X-cor \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #2 finished! \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #2 predicted fragment length is 74 bps \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #2 alternative fragment length(s) may be 74 bps \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #2.2 Generate R script for model : UBN1_chr17_peak_model.r \r\n",
      "WARNING @ Thu, 29 Dec 2016 12:16:44: #2 Since the d (74) calculated from paired-peaks are smaller than 2*tag length, it may be influenced by unknown sequencing problem! \r\n",
      "WARNING @ Thu, 29 Dec 2016 12:16:44: #2 You may need to consider one of the other alternative d(s): 74 \r\n",
      "WARNING @ Thu, 29 Dec 2016 12:16:44: #2 You can restart the process with --nomodel --extsize XXX with your choice or an arbitrary number. Nontheless, MACS will continute computing. \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #3 Call peaks... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:44: #3 Pre-compute pvalue-qvalue table... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:16:54: #3 Call peaks for each chromosome... \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:17:00: #4 Write output xls file... UBN1_chr17_peak_peaks.xls \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:17:00: #4 Write peak in narrowPeak format file... UBN1_chr17_peak_peaks.narrowPeak \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:17:00: #4 Write summits bed file... UBN1_chr17_peak_summits.bed \r\n",
      "INFO  @ Thu, 29 Dec 2016 12:17:00: Done! \r\n"
     ]
    }
   ],
   "source": [
    "macs2 callpeak -t  UBN1_chr17.sorted.bam -c ctrl_chr17.sorted.bam -f BAM -g 81195210 -n UBN1_chr17_peak -q 0.005"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "477 UBN1_chr8_peak_summits.bed\r\n"
     ]
    }
   ],
   "source": [
    "wc -l UBN1_chr8_peak_summits.bed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "422 UBN1_chr17_peak_summits.bed\r\n"
     ]
    }
   ],
   "source": [
    "wc -l UBN1_chr17_peak_summits.bed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chr8\t58409\t58672\tUBN1_chr8_peak_peak_1\t102\t.\t4.59992\t15.06512\t10.22873\t128\r\n",
      "chr8\t58818\t59022\tUBN1_chr8_peak_peak_2\t60\t.\t3.91586\t9.69238\t6.08608\t80\r\n",
      "chr8\t59128\t59243\tUBN1_chr8_peak_peak_3\t34\t.\t3.09003\t6.26836\t3.45703\t36\r\n",
      "chr8\t59328\t59719\tUBN1_chr8_peak_peak_4\t151\t.\t5.56832\t21.21552\t15.15063\t168\r\n",
      "chr8\t61522\t61603\tUBN1_chr8_peak_peak_5\t71\t.\t4.00562\t11.05327\t7.11912\t13\r\n",
      "chr8\t189257\t189344\tUBN1_chr8_peak_peak_6\t41\t.\t3.61132\t7.11514\t4.10654\t22\r\n",
      "chr8\t1701585\t1701660\tUBN1_chr8_peak_peak_7\t159\t.\t4.03754\t22.13795\t15.91221\t52\r\n",
      "chr8\t2389591\t2389672\tUBN1_chr8_peak_peak_8\t60\t.\t3.49016\t9.65678\t6.05386\t39\r\n",
      "chr8\t2894796\t2894871\tUBN1_chr8_peak_peak_9\t37\t.\t2.29734\t6.69459\t3.76925\t28\r\n",
      "chr8\t3057923\t3058002\tUBN1_chr8_peak_peak_10\t60\t.\t2.29663\t9.66614\t6.06248\t49\r\n"
     ]
    }
   ],
   "source": [
    "head UBN1_chr8_peak_peaks.narrowPeak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chr17\t90744\t90820\tUBN1_chr17_peak_peak_1\t110\t.\t3.79883\t15.65959\t11.08068\t43\r\n",
      "chr17\t596184\t596266\tUBN1_chr17_peak_peak_2\t48\t.\t2.19725\t8.00785\t4.89715\t44\r\n",
      "chr17\t820518\t820597\tUBN1_chr17_peak_peak_3\t91\t.\t3.88337\t13.36932\t9.11599\t45\r\n",
      "chr17\t877443\t877548\tUBN1_chr17_peak_peak_4\t38\t.\t2.50331\t6.63675\t3.86530\t33\r\n",
      "chr17\t895189\t895309\tUBN1_chr17_peak_peak_5\t30\t.\t2.08813\t5.57713\t3.05613\t40\r\n",
      "chr17\t1136428\t1136535\tUBN1_chr17_peak_peak_6\t99\t.\t4.90000\t14.31866\t9.90909\t53\r\n",
      "chr17\t1721134\t1721234\tUBN1_chr17_peak_peak_7\t41\t.\t2.16915\t7.06916\t4.19587\t89\r\n",
      "chr17\t2033417\t2033496\tUBN1_chr17_peak_peak_8\t81\t.\t3.35191\t12.09486\t8.10435\t49\r\n",
      "chr17\t2318846\t2318921\tUBN1_chr17_peak_peak_9\t37\t.\t2.39374\t6.55089\t3.79333\t24\r\n",
      "chr17\t2440228\t2440375\tUBN1_chr17_peak_peak_10\t31\t.\t2.77577\t5.75511\t3.18190\t143\r\n"
     ]
    }
   ],
   "source": [
    "head UBN1_chr17_peak_peaks.narrowPeak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Bash",
   "language": "bash",
   "name": "bash"
  },
  "language_info": {
   "codemirror_mode": "shell",
   "file_extension": ".sh",
   "mimetype": "text/x-sh",
   "name": "bash"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
