Skip to content

Instantly share code, notes, and snippets.

@Hoohm
Hoohm / scripts.gs
Created October 26, 2021 07:16
Code to manae a small spreadsheet form/database function. Explanation at https://www.youtube.com/watch?v=v2X-fArILPA&t=307s
// Clear form
function ClearCell(){
var ss = SpreadsheetApp.getActiveSpreadsheet()
var formS = ss.getSheetByName("Form"); // Sheet name
var rangesToClear = ["B3","B6","B8","B10","D6","D8","D10"]; // List of cells to clear
for (var i=0; i<rangesToClear.length; i++){
formS.getRange(rangesToClear[i]).clearContent();
}
}
@Hoohm
Hoohm / convert_10x_v3.py
Created December 15, 2019 16:37
Map a filtered 10x V3 RNA cell bacode whitelist to it's corresponding ADT whitelist.
import csv
filtered_set = set()
with open('filtered_RNA_V3.txt','r') as fitlered_whitelist:
csv_reader = csv.reader(fitlered_whitelist, delimiter=',')
for cell_barcode in csv_reader:
filtered_set.add(cell_barcode[0].strip('-1').strip())
@Hoohm
Hoohm / generate_fuzzy_regex_barcode.py
Created August 10, 2018 15:32
Python script that generates a fuzzy regex for capturing barcodes based on a given string pattern
import string
import regex
import numpy as np
test = 'AGCTAGCTGANNNNNAGCTANNNNNAGCTAGCTAGXXXXXXXXXX'
def generate_regex(barcode_template, positions, number_mismatches):
final_regex = '(?:'
position = 0
@Hoohm
Hoohm / gist:972ad0148876bec90d87
Last active July 14, 2023 14:45
Create a unique identifier for a file
def create_file_id(file_path, block_size=256):
'''
Function that takes a file and returns the first 10 characters of a hash of
10 times block size in the middle of the file
Input: File path as string
Output: Hash of 10 blocks of 128 bits of size as string plus file size as string
'''
file_size = os.path.getsize(file_path)
start_index = int(file_size / 2)
with open(file_path, 'r') as f: