This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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''' |