Skip to content

Instantly share code, notes, and snippets.

View Abusagit's full-sized avatar
🎯

Fedor Velikonivtsev Abusagit

🎯
View GitHub Profile
@Abusagit
Abusagit / construct_homogeneous_graph_from_MFG_blocks.py
Last active November 25, 2023 12:28
At the time of creating this gist, any node sampling routine in DGL v. 1.1.2 creates message flow graphs which trigger `CUDA: an illegal memory access was encountered` in message passing. This code helps to neglect this error by constructing identical subgraph with the same nodes features for every given depth of message flow graphs. Also it add…
import dgl
from typing import Any
from copy import deepcopy
def construct_subgraph_from_blocks(blocks: list[Any],
batch_size:int,
node_attributes_to_copy: list[str],
) -> dgl.DGLGraph:
"""
Constructs a copy of a Message flow graphs (MFG), defined as a list of MFGs.
@Abusagit
Abusagit / normalize_rows.py
Created September 16, 2022 21:55 — forked from f0nzie/normalize_rows.py
Normalize rows of a matrix by dividing rows by the normal of the matrix
def normalizeRows(x):
"""
Implement a function that normalizes each row of the matrix x (to have unit length).
Argument:
x -- A numpy matrix of shape (n, m)
Returns:
x -- The normalized (by row) numpy matrix. You are allowed to modify x.
"""
@Abusagit
Abusagit / get_mutated_genes.py
Last active October 12, 2021 18:23
Can be used from command line, takes 2 arguments - $1 - .vcf file path, $2 - .gff annotation file path and returns genes with variation with respect to reference genome.
#!usr/bin/python
# -*- coding: utf-8 -*-
#
#@created: 09.10.2021
#@author: Fyodor Velikonivtsev
#@contact: mirotvorez00@gmail.com
import bisect
import io
@Abusagit
Abusagit / read_vcf.py
Created June 4, 2021 15:46 — forked from dceoy/read_vcf.py
[Python] Read VCF (variant call format) as pandas.DataFrame
#!/usr/bin/env python
import io
import os
import pandas as pd
def read_vcf(path):
with open(path, 'r') as f:
lines = [l for l in f if not l.startswith('##')]
@Abusagit
Abusagit / gist:f91eb954667b9657ca8c4a207dc4c690
Created April 4, 2021 14:11 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
def turbo_bmh(string, pattern):
"""
Bad character heuristic, good suffix heuristic, turbo-shift heuristic implemented on Python
"""
def _suffices_preprocessing(suffix):
suffix[m - 1] = m
g = m - 1
for i in range(m - 2, -1, -1):
if i > g and suffix[i + m - f - 1] < i - g: