Skip to content

Instantly share code, notes, and snippets.

View gkarthik's full-sized avatar
👽
I'm an imposter

Karthik gkarthik

👽
I'm an imposter
View GitHub Profile
import bjorn_support as bs
import mutations as bm
import pandas as pd
# FASTA must include reference NC_045512.2 (e.g. use cat to add the reference)
fasta_filepath = '2021-02-08_release.fa'
# specify name for output alignment
msa_filepath = 'msa.fa'
# run alignment (uses MAFFT but can be changed from bjorn_support.py)
import numpy as np
nentity = 100
nhidden = 20
nrelations = 10
entity_embedding = np.random.uniform(-10, 10, (nentity, nhidden))
relation_embedding = np.random.uniform(-1, 1, (nrelations, nhidden))
# For every iteration
@gkarthik
gkarthik / decimal_to_year.py
Last active January 20, 2020 23:08
decimal year to datetime
from datetime import datetime ,timedelta
import sys
given_year = float(sys.argv[1])
base = datetime(int(given_year),1,1)
year_rem = given_year - int(given_year)
calc_date = (base + timedelta(seconds = (base.replace(year = base.year+1) - base).total_seconds() * year_rem ))
print(calc_date.strftime("%d %b %Y"))
@gkarthik
gkarthik / create_samples.sh
Last active December 18, 2019 08:20
Create samples.tsv
# Naming scheme -> <samplename>_R1.fastq.gz and <samplename>_R2.fastq.gz
echo -e "forward\treverse\tsample\tsample_library" > samples.tsv
find /path/to/folder -name "*.fastq.gz" | sort | xargs -n 2 bash -c 'name=$(basename $0 | cut -f 1 -d _);echo -e "$0\t$1\t${name}\t${name}_L1"' >> samples.tsv
@gkarthik
gkarthik / vcf_to_df.py
Created October 21, 2019 23:02
Parse VCF to dataframe using pyvcf (including format).
import vcf
import os
import pandas as pd
import matplotlib.pyplot as plt
def create_vcf_df(file_name):
data = []
csq_fields = ["impact", "aa.pos", "aa.mut", "nuc.pos", "codon.change"]
vcf_reader = vcf.Reader(open("../data/"+file_name))
for rec in vcf_reader:
const { Observable, Subject, BehaviorSubject, throwError, forkJoin, of, from, EMPTY } = require('./node_modules/rxjs');
const { map, catchError, tap, mergeMap, reduce, finalize, expand } = require("./node_modules/rxjs/operators");
const { ajax } = require('rxjs/ajax');
const {XMLHttpRequest} = require("xmlhttprequest");
function fetchAllGeneric(endpoint, qParams) {
return fetchOne(endpoint, qParams).pipe(
expand((data) => {
return data.next ? fetchOne(endpoint, data.next) : EMPTY;
}),
@gkarthik
gkarthik / render_tree_usa.py
Created September 24, 2019 20:02
Render ML tree
from Bio import Phylo
import datetime
from decimal import Decimal
import numpy as np
import pandas as pd
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
@gkarthik
gkarthik / elasticsearch-restclient
Created June 29, 2019 23:09 — forked from mx4492/elasticsearch-restclient
Using Emacs Restclient Mode to explore the Elasticsearch REST API
# Using Emacs Restclient Mode to explore the Elasticsearch REST API
# http://www.elasticsearch.org/guide/en/elasticsearch/reference/
:es = http://127.0.0.1:9200
# Cluster Health
GET :es/_cat/health?v
# List of nodes
@gkarthik
gkarthik / error.log
Last active February 8, 2019 06:51
BEASTv1.8.4 Error
# BEAST v1.8.4
# Generated Thu Feb 07 22:51:42 PST 2019 [seed=1549608699682]
# -beagle_gpu downsampled_ca.xml
state Posterior Prior Likelihood downsampled_ca_7.rootHeight downsampled_ca_6.rootHeight downsampled_ca_5.rootHeight downsampled_ca_3.rootHeight downsampled_ca_1.rootHeight shared.ucld.mean location.clock.rate
0 -813839.4208 -30233.6058 -783605.8150 186.311 188.566 386.793 485.184 86.8928 1.00000 1.00000 -
Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 353
at dr.evomodel.tree.TreeModel.getNode(Unknown Source)
at dr.app.beagle.evomodel.treelikelihood.BeagleTreeLikelihood.handleModelChangedEvent(Unknown Source)
at dr.inference.model.AbstractModel.modelChangedEvent(Unknown Source)
at dr.inference.model.Model$ListenerHelper.fireModelChanged(Unknown Source)
bases = "tcag"
codons = [a + b + c for a in bases for b in bases for c in bases]
amino_acids = 'FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG'
codon_table = dict(zip(codons, amino_acids))
# To get amino acid
codon_table['atg']