Skip to content

Instantly share code, notes, and snippets.

View silvtal's full-sized avatar

Silvia Talavera Marcos silvtal

View GitHub Profile
@silvtal
silvtal / merge_otus.py
Created May 30, 2023 11:30
sometimes qiime input (for pick_otus.py) is too heavy of a file. Therefore you need to split it and obtain several output OTU files. But you can't just paste together the outputs again, since it would mean repeated OTU IDs. So... Use this script.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 28 17:14:18 2022
@author: silvia
@description: sometimes qiime input (for pick_otus.py) is too heavy of a file.
Therefore you need to split it and obtain several output OTU files. But you can't
just paste together the outputs again, since it would mean repeated OTU IDs. So...
@silvtal
silvtal / merge.sh
Created May 30, 2023 09:46
Move all folders inside a parent folder into a new parent folder. If there alre conflicts, only move those folders that are bigger than the existing ones.
source_folder="old_results_2023-04-13"
destination_folder="new_results_2023-05-30"
for file in "$source_folder"/*; do
filename=$(basename "$file")
destination_file="$destination_folder/$filename"
if [[ -e "$destination_file" ]]; then
source_size=$(stat -c%s "$file")
destination_size=$(stat -c%s "$destination_file")
@silvtal
silvtal / splitter.sh
Last active March 16, 2022 16:46
Splits a fixedStep .wig file at its headers
#!/bin/bash
## BASED ON : https://www.baeldung.com/linux/split-file-at-line-numbers
INPUT_FILE="out/experimental_reads.wig" # The input file
LINE_NUMBERS=( $(cat $INPUT_FILE | grep -n "g" | cut -f 1 -d":" | tr '\n' ' ') ) # The given line numbers (array)
START=1 # The offset to calculate lines
IDX=1 # The index used in the name of generated files: file1, file2 ...
for i in "${LINE_NUMBERS[@]}"
do
# Extract the lines using the head and tail commands
@silvtal
silvtal / fix2var.c
Last active March 16, 2022 16:51
C script to convert from fixedStep to variableStep wiggle format
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc,char** argv)
{
int span=1;
int start=0;
int step=0;
char line[BUFSIZ];