Skip to content

Instantly share code, notes, and snippets.

View Finesim97's full-sized avatar

Lukas Klein Finesim97

View GitHub Profile
@Finesim97
Finesim97 / examples.py
Last active April 29, 2022 17:44
Helpful stuff dealing with transactional (bought stuff) in pandas
from random import choices, choice
import pandas as pd
import numpy as np
nrows=1000
customers = ["John", "Mary", "Alex", "Smith"]
products = ["Beverage", "Meat", "Vegetable", "Fruit"]
example_data = pd.DataFrame({"customer_id":choices(customers, k=nrows), "article_id":choices(products, k=nrows)}).astype("category")
print(example_data.head())
@Finesim97
Finesim97 / readOfficeColors.R
Last active June 10, 2020 10:16
A R function to read the Microsoft Office color palettes
#!/usr/bin/env Rscript
#' Read a Microsoft Office color palette (DrawingML)
#'
#' After saving a custom scheme you can find these files \href{https://answers.microsoft.com/en-us/msoffice/forum/all/where-does-powerpoint-save-color-schemes-added-in/ea2ca2ec-e238-448b-860d-ff899d4e7afc}{here}:
#' \code{"%appdata%\Microsoft\Templates\Document Themes\Theme Colors"}
#'
#' @param file The path or content of the XML file
#' @return A named character vector with the hex values
#' @examples
@Finesim97
Finesim97 / Dockerfile_diamonderr.diff
Created March 4, 2020 14:22
Build a Docker image for metaerg including DIAMOND error reporting
39c39,40
< RUN cpanm Bio::Perl \
---
> RUN cpanm -f XML::DOM::XPath && \
> cpanm Bio::Perl \
68c69
< RUN wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.9.0+-x64-linux.tar.gz && \
---
> RUN wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.9.0/ncbi-blast-2.9.0+-x64-linux.tar.gz && \
100c101
@Finesim97
Finesim97 / Dockerfile.diff
Last active January 15, 2020 23:30
Dockerfile for an older metaerg version without certain bugs.
39c39,40
< RUN cpanm Bio::Perl \
---
> RUN cpanm -f XML::DOM::XPath && \
> cpanm Bio::Perl \
68c69
< RUN wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.9.0+-x64-linux.tar.gz && \
---
> RUN wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.9.0/ncbi-blast-2.9.0+-x64-linux.tar.gz && \
100c101
@Finesim97
Finesim97 / installCheckM.sh
Last active November 12, 2019 12:55
CheckM Install
#!/usr/bin/env bash
#
# Install
#
checkmdatdir="~/.checkmdata"
conda create -n chekmenv python=2.7 bioconda::checkm-genome -y
mkdir $checkmdatdir && wget -qO- https://data.ace.uq.edu.au/public/CheckM_databases/checkm_data_2015_01_16.tar.gz | tar xzf - -C $checkmdatdir
source activate chekmenv
checkm data setRoot $checkmdatdir
@Finesim97
Finesim97 / DynDNS_Update.sh
Last active September 6, 2019 06:58
Setup for dynamic DNS (RFC2136) with IPv6 support.
#!/usr/bin/env bash
set -e
# apt install dnsutils
#
# Update those values
#
server=ns.example.net # DNS server
zone=d.example.net # DNS Zone configured for updating
@Finesim97
Finesim97 / isGridJobRunning.sh
Created February 14, 2019 19:48
A small bash function, which checks, whether the given host runs a job in the grid. (hostname is just host on some systems!)
#!/usr/bin/env bash
# This function takes a hostname as an argument and returns
# 0 when the given host has at least 1 job running 0 if it has
# no job (or future).
function hasHostActiveJobs(){
hostname=$1
qhostout=$(qhost -j -xml -l hostname=$hostname) # Option seems to be called host on other systems
#echo $qhostout
filterstring="name='job_state'>r" # Just remove the r for any job
@Finesim97
Finesim97 / downloadNGSmethDB.sh
Last active February 11, 2019 20:31
Download a mod_dir page recursively with wget
#!/bin/bash
# Should work for every mod_dir page
# The regex ignores the sorted indices
# https://explainshell.com/explain?cmd=wget+--recursive+--reject-regex+%22%28.*%29%5C%3F%28.*%29%22+--no-parent+--mirror+--execute+robots%3Doff+--directory-prefix+%2Fnfs2%2Fshared%2Fngsmethdb%2F+--include-directories+%2FNGSmethDB_web%2Fdownloads%2Fhg19%2C%2FNGSmethDB_web%2Fdownloads%2Fhg38+https%3A%2F%2Fbioinfo2.ugr.es%2FNGSmethDB_web%2Fdownloads%2F
wget --recursive --reject-regex "(.*)\?(.*)" --no-parent --mirror --execute robots=off --directory-prefix /nfs2/shared/ngsmethdb/ --include-directories /NGSmethDB_web/downloads/hg19,/NGSmethDB_web/downloads/hg38 https://bioinfo2.ugr.es/NGSmethDB_web/downloads/