Skip to content

Instantly share code, notes, and snippets.

View vestalisvirginis's full-sized avatar

Virginie Grosboillot vestalisvirginis

View GitHub Profile
@vestalisvirginis
vestalisvirginis / asset.py
Last active November 8, 2023 17:44
add image to Dagster as asset metadata
# For metadata
buffer = BytesIO()
_gd_diagram.write(buffer, "png")
image_data = base64.b64encode(buffer.getvalue())
# Asset metadata
context.add_output_metadata(
metadata={
"text_metadata": "A synteny diagram had been created.",
"num_sqcs": len(_records),
@vestalisvirginis
vestalisvirginis / random_algorithm.py
Created September 3, 2019 16:52
Randomized Motif Search
import numpy as np
from functional import seq
from collections import deque, defaultdict
import time
def RandomNumberGenerator(dna, k):
#return an array (0,t) of random integers, than can be used as starting point for selecting random k-mer along dna strings
return np.random.randint(0, DnaToMatrix(dna).shape[1]+1-k, size = (DnaToMatrix(dna).shape[0], 1))
def DnaToMatrix(dna):
@vestalisvirginis
vestalisvirginis / dna_functions.py
Last active September 1, 2019 11:13
dna manipulation functions
from itertools import product
from functional import seq
def all_kmers(k):
'''return list of all dna carthesien products of length k'''
all = list(product('ACGT', repeat=k))
return seq(all).map(lambda x: ''.join(x)).to_list()
def kmer_per_segment(dna_segment, k):
'''return all the dna substrings of length k of the different dna strings in dna list'''