Skip to content

Instantly share code, notes, and snippets.

View IdoBar's full-sized avatar

Ido Bar IdoBar

View GitHub Profile
@IdoBar
IdoBar / bash_strict_mode.md
Created August 18, 2022 23:37 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@IdoBar
IdoBar / cn.mops.R
Last active July 5, 2022 23:47 — forked from danielecook/cn.mops.R
Call cnvs using cn.mops #cluster
#!/usr/bin/env Rscript
#PBS -V
# This script will call copy number variants using cn.mops
# usage: Rscript cn.mops.R --help
library(optparse)
option_list = list(
make_option(c("-i", "--input_dir"), type="character", default=NULL,

Bash best practices and style-guide

Just simple methods to keep the code clean.

Inspired by progrium/bashstyle and Kfir Lavi post.

Quick big rules

  • All code goes in a function
  • Always double quote variables
stat_smooth_func <- function(mapping = NULL, data = NULL,
geom = "smooth", position = "identity",
...,
method = "auto",
formula = y ~ x,
# show_formula = TRUE,
se = TRUE,
n = 80,
span = 0.75,
fullrange = FALSE,
@IdoBar
IdoBar / qstat
Last active January 10, 2021 16:09
A modified qstat wrapper to work with nextflow on QRIS Awoonga
#!/bin/bash
# put this file in $HOME/bin and make it executable
# make sure that this file is being called by default, I did this by adding `alias "qstat=~/bin/qstat"` to my ~/.bashrc
# Servers
#awoonga="@awongmgmr1.storage:16001 @awonmgr2.storage:16001"
#flashlite="@flm1.ipoib:16001 @flashmgr2.ipoib:16001"
#tinaroo="@tinmgmr1.ib0:16001 @tinmgr2.ib0:16001"
awoonga="@awonmgr2"
flashlite="@flashmgr2"
@IdoBar
IdoBar / blast_tax.md
Last active August 20, 2020 02:28
Use taxonomy and/or accession ids to restrict and distribute BLAST searches in an HPC cluster

Introduction

The following code snippets demonstrate an approach to substantially speed-up BLAST searches of large query files (whole transcriptomes/genomes) that are performed against the NCBI nr/nt/refseq databases by running small jobs annotating subsets of the input sequences against subsets of the databases.
The method is based on "divide and conquer" approaches [1–2] that split the search query and the database to multiple small jobs that require modest resources and time which can utilise high priority queues and are therefore ideal for an HPC setting. The exact number of jobs to be submitted is dependant on the specifics of the HPC cluster, primarily number of available nodes, queues limits and system loads and therefore need to be experimented for optimal results.

Requirements

The suggested script is tailored to run on the QRIS Awoonga HPC cluster, using [Conda environment](https://docs.conda.io/en/latest

@IdoBar
IdoBar / Zotero_make_species_great_again.py
Last active September 8, 2021 01:41
Italicize species names in Zotero titles
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 16:34:57 2020
@author: Ido Bar
"""
@IdoBar
IdoBar / Italicize_species_Zotero.js
Last active January 26, 2020 12:02
Find species names (based on provided array of genus names) and add html tags for italics font
// See these instruction to enable js scripting in Zotero:
// https://forums.zotero.org/discussion/comment/324734/#Comment_324734
var fieldName = "title";
var plantsPathogens = ["Cryptobranchus", "Fusarium", "Mycosphaerella", "Pochonia", "Pogona", "Nannizziopsis", "Armillaria", "Parastagonospora", "Pseudoperonospora", "Phytophthora", "Heterobasidion", "Cochliobolus", "Rhynchosporium", "Aspergillus", "Ascochyta", "Sclerotinia", "Botrytis", "Cicer", "Lens","Oryza", "Eucalyptus", "Arabidopsis", "Vigna", "Phaseolus", "Vicia"];
var aquaticSpecies = ["Oreochromis", "Dicentrarchus", "Pagrus", "Gonostoma","Tursiops", "Gadus", "Danio", "Acanthosentis", "Oryzias", "Seriola", "Cyprinus", "Euthynnus", "Solea", "Nibea", "Thunnus thynnus","Argyrosomus", "Thunnus", "Misgurnus", "Oncorhynchus", "Epinephelus", "Rachycentron", "Clarias", "Tetraodon", "Proterocara", "Latimeria", "Oithona", "Sarda", "Glaucosoma", "Scomberomorus", "Allium", "Aulopus", "Plecoglossus", "Anguilla", "Hoplias", "Poecilia", "Sardinops", "Cyprinus", "A
@IdoBar
IdoBar / fasta2agp.pl
Last active June 18, 2019 09:33
Fasta2APG
#!/bin/env perl
### david.studholme@tsl.ac.uk
### Generates contigs (in FastA) and scaffolding information (in AGP) from Velvet 'contigs.fa' supercontigs file
### Use entirely at you own risk!! There may be bugs!
### modified by chienchi@lanl.gov 2010/09/13
### add flags -i -size -o
@IdoBar
IdoBar / setup_nectar_teaching_server.md
Last active March 7, 2024 14:32
Setting up a NECTAR Cloud multi-user teaching server using conda

Setting up a cloud-based multi-user teaching server using conda

nectarcloud

Setup steps

  1. Apply for an allocation at NECTAR-RDS
  2. Setup 2 key-pairs (one will be for 'root-designated' login and the other for 'general-user' login), download the private keys to a secure location. If you're planning to use KiTTY or PuTTY to login to the server from Windows, you'll need to convert the .pem key file to a .ppk, as explained here. You can (and should) password-protect this key (can be done in PuTTYgen when converting the key from the default .pem format to a PuTTY-supported .ppk).
  3. Setup a customised security group to allow remote access (open port 22 for ssh logins and any addi