Skip to content

Instantly share code, notes, and snippets.

@ionox0
ionox0 / reverse_clip.py
Last active July 22, 2019 18:35
Add UMIs from read names back into reads themselves, with support bases
# Script to reverse engineer UMI-tagged fastqs from Marianas UMI-processed fastqs
# ---
import sys
import gzip
from itertools import izip
# Usage: python reverse_clip.py <read 1 paired fastq with umis in read headers>
# We start with R1 and R2 that have been clipped with Marianas, and UMIs have been placed in the read name.
@ionox0
ionox0 / quickstart.md
Last active May 2, 2019 19:48
Running the ACCESS snps_and_indels.cwl workflow

Commands to run ACCESS snps and indels pipeline

Note: the version here pipeline_VariantCalling will be subject to change

1. Activate the virtual environment

Note that if you are working off of your own clone of the project, you must create your own virtual environment and install the pipeline there (see steps 1-4 in the readme).

source /home/johnsoni/virtualenvs/pipeline_VariantCalling/bin/activate
source /home/johnsoni/pipeline_VariantCalling/ACCESS-Pipeline/python_tools/pipeline_kickoff/workspace_init.sh
#!/bin/bash
# Version 2 from Dilmi
export PATH=/home/pererad1/java8/jdk1.8.0_144/bin:$PATH
input_bam=$1
output_folder=$2
# Change these:
fgbio_jar=/ifs/work/bergerm1/pererad1/fgbio-0.5.0-SNAPSHOT.jar
scratch_dir=/ifs/work/bergerm1/Innovation/sandbox/ian/scratch/
#!python
import csv
import sys
csv.field_size_limit(sys.maxsize)
# Input file:
@ionox0
ionox0 / df_compare.py
Created January 15, 2019 02:11
Find the intersecting and unique rows of two Pandas DataFrames
def compare_dfs(df_a, df_b, merge_cols):
"""
Returns intersection, its complement, only in df_a, only in df_b
:param merge_cols: Columns to use for merging the two DataFrames
"""
df_a = df_a.copy()
df_b = df_b.copy()
DUM_A = 'DUMMY_COL_A'
@ionox0
ionox0 / pdf_replace.py
Created January 6, 2019 18:26
Simple python script to find and replace text within a PDF
import re
import sys
import zlib
# Module to find and replace text in PDF files
#
# Usage:
# python pdf_replace.py <input_filename> <text_to_find> <text_to_replace> <output_filename>
#
# @author Ionox0
@ionox0
ionox0 / Bam_Compare
Created October 5, 2018 18:22
Indel Realignment comparison
# Compare first 11 fields of bam files
diff <(samtools view 5500-FC-FGFR2-spike-in/Sample_ML-fgfr2-015-pl-T02_/ML-fgfr2-015-pl-T02_IGO_05500_FC_16_S16_001_cl_aln_srt_MD_IR_FX_BR.bam | cut -f1-11 ) <(samtools view repeat-run/5500-FC-FGFR2-spike-in/Sample_ML-fgfr2-015-pl-T02_/ML-fgfr2-015-pl-T02_IGO_05500_FC_16_S16_001_cl_aln_srt_MD_IR_FX_BR.bam | cut -f1-11 ) > ~/ML-fgfr2-015-pl-T02_IGO_05500_FC_16_S16_001_cl_aln_srt_MD_IR_FX_BR-complete_diff-original_vs_repeat-run
# Compare IR reads (grep for "YO:" tag)
diff <(samtools view 5500-FC-FGFR2-spike-in/Sample_ML-fgfr2-015-pl-T02_/ML-fgfr2-015-pl-T02_IGO_05500_FC_16_S16_001_cl_aln_srt_MD_IR_FX_BR.bam | grep "YO:") <(samtools view repeat-run/5500-FC-FGFR2-spike-in/Sample_ML-fgfr2-015-pl-T02_/ML-fgfr2-015-pl-T02_IGO_05500_FC_16_S16_001_cl_aln_srt_MD_IR_FX_BR.bam | grep "YO:") > ~/ML-fgfr2-015-pl-T02_IGO_05500_FC_16_S16_001_cl_aln_srt_MD_IR_FX_BR-indel_realign_diff-original_vs_repeat-run
@ionox0
ionox0 / cycle_for_survival.js
Last active December 29, 2017 17:04
Auto populate list for sending donation requests email
var emails = ['[email protected]']
var $ = jQuery;
var one = $('#msg_cat_wizard_add_contacts')[0]
var four = $('#email-wizard-add-contact-email')[0];
async function doit(email) {
one.click();
four.value = email;
import itertools
import pandas as pd
barcode_labels = pd.read_excel('IDT_DM-96 barcode-for hiseq.xlsx')
sample_1_list = barcode_labels['Index_Name'].str.slice(0, 6)
sample_2_list = barcode_labels['Index_Name'].str.slice(6, 11)
sample_name_combs = itertools.product(sample_1_list, sample_2_list)
sample_name_combs_list = list(sample_name_combs)
sample_name_combs_df = pd.DataFrame(sample_name_combs_list)
sample_name_combs_df['merged'] = sample_name_combs_df.iloc[:,0] + sample_name_combs_df.iloc[:,1]
@ionox0
ionox0 / slu.m
Created September 14, 2017 15:26
Strang
function [L,U,P] = slu(A)
[n,n] = size(A); tol = 1.e-6;
P = eye(n);
L = eye(n);
for k = 1 : n
if abs(A(k,k)) < tol
r = k + 1;
while A(r, k) < tol
r = r + 1;
end