sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
40bb933d14729c2a02d1fe39f7daeae0cb71ffc0150b3ef47a33e91510b5b23f | Python | 1,254 | 53 | from contextlib import contextmanager
import logging
class Defaults:
def __init__(self, **kwargs):
self.values = kwargs.copy()
@contextmanager
def update(self, **kwargs):
"""in order to control global parameters (like number of cores available)
without having to pass it through ev... |
346d0b77b9fbfa2cfe24852e5ca79d8f3bd6e5d227aa8edbae25e00fb5b7793e | Python | 1,255 | 32 | """ Full assembly of the parts to form the complete network """
import torch.nn as nn
import torch.nn.functional as F
def double_conv_bn_relu(in_channels: int,
out_channels: int,
kernel_size: int = 3,
padding: int = 1):
conv1 = nn.Conv2d(in_... |
be89fb19c331c4f51c36c96a583a247802114a7452b923d8fe234932095c3126 | Python | 1,255 | 41 | from collections import defaultdict
from pathlib import Path
import labelbox
from dotenv import dotenv_values
from tqdm import tqdm
config = dotenv_values('.env')
dst = Path('/data1/centrioles/')
dst.mkdir(exist_ok=True)
def main():
lb = labelbox.Client(api_key=config['LABELBOX_API_KEY'])
project = lb.get_p... |
fdba34c2194b18bb6d3934bdff878dd311214443f564976ad06bca3ef9a4a232 | Python | 1,255 | 41 | """
This is the script used to create the BED files with gencode protein-coding
genes. Posted here for reproducibility.
TODO: add documentation, switch to docopt.
"""
import os
import sys
if __name__ == "__main__":
filename = sys.argv[1]
output_dir = sys.argv[2]
os.makedirs(output_dir, exist_ok=True)
... |
2c231bb7ccb895a1d323b20cbcef594be0dbbd748d19b7b706002244bb312412 | Python | 1,256 | 37 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# df = pd.read_csv('runtime_sizes/12-12/sizes.csv', index_col=0)
# for i in range(df.shape[0]):
# plt.plot(df.columns, np.log(df.iloc[i,:]), label = f'Num Hops = {df.index[i]}')
# #plt.title('Runtime Analysis of 1-2 Bounded Subgraph Generatio... |
d8773e99b0a357b5ddd455356cec8d2d38ea57ef5f894bea9f89fe31e07ac95b | Python | 1,256 | 29 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
259c78c8bb8324e4a0a768cc958c7e0577649eec86631eeb059c3a258d59635b | Python | 1,257 | 43 | from dataclasses import dataclass
from oaklib.datamodels.obograph import Graph
from oaklib.transformers.ontology_transformer import OntologyTransformer
@dataclass
class GraphTransformer(OntologyTransformer):
"""
An ontology transformer that operates on a graph
"""
remove_dangling_edges: bool = False... |
34e7504cf7bf05921ce3bc4590efee16041d64655f914e0dfec6094bcbb8a3cf | Python | 1,257 | 46 | '''
Chain of oscillators with (optional) periodic boundary conditions (ring).
'''
import numpy as np
import carpet
import carpet.lattice.ring1d as lattice
## Parameters
# Geometry
N = 16
a = 18 # [um] lattice spacing
## Initialize
# Geometry
e1 = np.array([1,0]) # direction of the chain (for Kuramoto model - does n... |
83225e6deb5a2855a5ab64f629e9019a070d700cd200f0a7c60305f35bf75cff | Python | 1,257 | 61 | """Plot results.
"""
#%% Run ID and output directories
import os
from sys import argv
# We get the run ID from the command line arguments
if len(argv) != 2:
print("Please pass a run id, e.g. python 5_plot_results.py 1")
exit()
id = int(argv[1])
# Check results directory exists
results_dir = f"results/run{i... |
e9713666ef3143ad60e9c8194ee66340b97b5fb5e0d6353eeef3c189c61fd0b6 | Python | 1,257 | 29 | #!/usr/bin/env python3
import pandas as pd
import sys
from os.path import basename, splitext, join
#Usage: python3 add_hpo_terms_to_wes.py <phenotips_hpo_terms> <wes.report.csv> <outdir>
HPO_DF = pd.read_csv(sys.argv[1], comment='#', skip_blank_lines=True,\
sep="\t", encoding="ISO-8859-1", engine='python').drop(co... |
12df22fe6684cb7a1bb676ebec49e5cef0578379b77ac27b1b1689f1bd3ecf31 | Python | 1,258 | 34 | import os
import shutil
from dash_extensions.enrich import Output, Input, State, callback
from dash.exceptions import PreventUpdate
def register_quit_callbacks():
@callback(
Output('RV-clear-main-graph-button', 'n_clicks'),
Input({'type': 'process-button', 'modal': 'RV-quit'}, 'n_clicks'),
... |
bdffbe57ef0d85cd1a46d7f0ae401fd6b3e3591bbba09ca9fe553d59b650f419 | Python | 1,258 | 33 | import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import numpy as np
class gamma_change(nn.Module):
def __init__(self, apply_norm=True):
super(gamma_change, self).__init__()
self.pool = nn.AdaptiveAvgPool2d(64)
self.linear = nn.Sequential(nn.Linear(64*64*... |
f2f839defbd328a56d693733de132cdf6580740126bf6bdb1fb74d99beda7dbd | Python | 1,259 | 46 | import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
tasks = [
"RomoTask1",
"RomoTask2",
"DMTask1",
"DMTask2",
"CtxDMTask1",
"CtxDMTask2",
"GoTask1",
"GoTask2",
"GoRtTask1",
"GoRtTask2",
"GoDlTask1",
"GoDlTask2",
]
# cmap = sns.cm.magma
def main():... |
c500f54e0a04877eb82cc26492471b7cb4c52ac6d5a34b714bfc3d05a8480e7b | Python | 1,260 | 54 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import List
from tmkit.id.Mapping import Mapping as idmap
def pdb2uniprot(
id: str,
ref_fpn: str = "",
) -> str:
"... |
1d15f7fe27af147c33d3fc894839ba75cda585a0785d1e848ee1148bf1f03b2c | Python | 1,261 | 40 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import os
from .._utils import ui
def load_feather(file_path=None, columns=None):
"""Load a Dataset from a feather format file (experimental).
Parameters
----------
file_path : None | str
Path to a feather file. If None (default), a sy... |
3ca5acc8c85cdaee8c2a47e3ee90e8f947caabe46aa3257475670ca1bcc6837e | Python | 1,261 | 37 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
69391e804afb070ddb6c37bbba5372baff8b8b8ddc086463db18ed5535d8870b | Python | 1,261 | 41 | #%%
# identify users to acknowledge in paper for any tracing at all
import pandas as pd
import numpy as np
date = '2022-03-08'
# load contribution data, saved manually from CATMAID
nodes = pd.read_csv(f'data/users/nodes_contributed_{date}.csv')
post = pd.read_csv(f'data/users/post_contributed_{date}.csv')
pre = pd.r... |
eca79185f71d9502719b0bfc353ffdba6fcc34646fbc10872bf6928be8c8ef63 | Python | 1,262 | 46 | from abc import ABC
from typing import List, Iterable
from oaklib.datamodels.search import SearchConfiguration
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
from oaklib.types import CURIE
class SearchInterface(BasicOntologyInterface, ABC):
"""
An Ontology Interface that suppor... |
72cc8edb8558a20bb69453344cff0702279fcdedc3f61c06769e4d875df8b169 | Python | 1,266 | 37 | import torch
import numpy as np
# adapted from https://github.com/shelhamer/fcn.berkeleyvision.org/blob/master/score.py
class iouEval(object):
def __init__(self, nClasses):
self.nClasses = nClasses
self.reset()
def reset(self):
self.hist = np.zeros((self.nClasses, self.nClasses))
... |
b620e10b7ba20f40b5d72a10a75e05ebdde3cb3f52990bf4a82635bb2c507f18 | Python | 1,267 | 45 | import argparse
import torch
from torchvision import transforms
from retinanet import csv_eval, model
from retinanet.dataloader import CSVDataset, Resizer, Normalizer
assert torch.__version__.split('.')[0] == '1'
print('CUDA available: {}'.format(torch.cuda.is_available()))
def main(args=None):
csv_annota... |
f7a1c723d1b84ec32ed388d349a8d9452ea482b114301b22919e6dd0cdb4c405 | Python | 1,267 | 45 | import os
import torch
from M2TR.datasets.dataset import DeepFakeDataset
from M2TR.utils.registries import DATASET_REGISTRY
from .utils import get_image_from_path
'''
DATASET:
DATASET_NAME: CelebDF
ROOT_DIR: /some_where/celeb-df-v2
TRAIN_INFO_TXT: '/some_where/celeb-df-v2/splits/train.txt'
VAL_INFO_TXT: '/s... |
59319ff3ed8f981252fd1b5da7e27e9592af623b18b1f1d206abe59ac8d4e8d3 | Python | 1,268 | 28 | import os
from feature import create_train_dataset
model_dir = 'example/model'
target_dir = 'example/label'
alphafold_prediction_path = 'example/alphafold_prediction'
output_feature_model_path = 'outputs/train/feature_model'
output_feature_target_path = 'outputs/train/feature_target'
if not os.path.isdir(output_fea... |
3574805ff665582da5526e3064c5e54b52bb294cf1e955f81c21fc550af3469f | Python | 1,270 | 51 | """
Functions for managing and accessing API keys
See `<https://github.com/ActiveState/appdirs>`_
"""
import logging
import os
from pathlib import Path
from appdirs import user_config_dir
from oaklib.datamodels.vocabulary import APP_NAME
APIKEY_SUFFIX = 'apikey.txt'
def get_apikey_path(system: str) -> Path:
"""... |
2b536e0c02ea209a3863f5fad8694d4edf54e2ba37d6946f484b22d6de3bcfa8 | Python | 1,272 | 42 | from src import PQNModel
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import gridspec
if __name__ == "__main__":
# set a PQN cell
# you can use RSexci, RSinhi, FS, LTS, IB, EB, PB, or Class2 mode
cell0=PQNModel(mode='RSexci')
# length of simulation [s]
tmax=2
# set the ... |
2e2be86a7a68bcb2e471a3c1d1b2d7170bb17a4677eb7537c6d20f6d4e45b913 | Python | 1,272 | 34 | #!/usr/bin/env python3
# Copyright 2017 Babak Rekabdar
# 2017 Hossein Hadian
# 2017 Chun Chieh Chang
# 2017 Ashish Arora
# Apache 2.0
# This script prepares lexicon for BPE. It gets the set of all words that occur in data/train/text.
# Since this lexicon is based ... |
3a5450b4b36a984e759bf058e15f2fe2ff2bbf73e7df0e70da7f6ec1896a628c | Python | 1,272 | 45 | from pathlib import Path
import pandas as pd
from matplotlib import pyplot as plt
from cenfind.constants import protein_positions
pd.options.display.max_columns = 50
ROOT_DIR = Path("../../../")
def main():
path_data = ROOT_DIR / "out/performances_20221006_130126.csv"
data = pd.read_csv(path_data)
dat... |
8c7cced4a1c956b69598aec61cb3a2d74b2948beac552adc89cf274cf85e5f0a | Python | 1,272 | 38 | """
This module implements an abstract base class for datasets. Other datasets can be created from this base class.
"""
import torch.utils.data as data
from abc import ABC, abstractmethod
class BasicDataset(data.Dataset, ABC):
"""
This class is an abstract base class for datasets.
To create a subclass, yo... |
0cb35d332324e966404875d771c8802fe6aa49dbf1bc2730ca44808d47a2f201 | Python | 1,273 | 30 | '''
'''
import numpy as np
from sim_geometry import *
import carpet.physics.friction_pairwise as physics
## Parameters
# Physics
set_name = 'machemer_4' # which hydrodynamic coefficients to use
order_g11 = (4,0)
order_g12 = (4,4)
# Physics
period = 31.25 # [ms] period of cilia beat
freq = 2 * np.pi / per... |
91b89eeca3d19e90366764fccc2749d79192fd154fdd965ece524e9bc9f4d754 | Python | 1,273 | 38 | from torch import nn
from maskrcnn_benchmark import layers
from maskrcnn_benchmark.modeling import registry
@registry.ROI_KEYPOINT_PREDICTOR.register("KeypointRCNNPredictor")
class KeypointRCNNPredictor(nn.Module):
def __init__(self, cfg, in_channels):
super(KeypointRCNNPredictor, self).__init__()
... |
64506c57d054643cd450977d1230f83bff3bd2a99c40f6514d0a608e2d3112fe | Python | 1,274 | 36 | import argparse
import statistics
parser = argparse.ArgumentParser(description='Subset covariate table on samples, then remove rows that have no variance')
parser.add_argument('covar_table',help='table with covariates')
parser.add_argument('sample_list',help='file with list of samples to keep')
parser.add_argument('o... |
0f0f893142d3d605fcad5904fdc4da38f23c6e9b453d7e3c99087eaf6d938a83 | Python | 1,275 | 42 | import logging
from dataclasses import dataclass, field
from typing import Iterable, List, Type
from oaklib import BasicOntologyInterface
from oaklib.datamodels.validation_datamodel import ValidationResult
from oaklib.utilities.validation.definition_ontology_rule import (
DefinitionOntologyRule,
)
from oaklib.util... |
c1f1c06410ce6ae7e0d3451149247c15b428b3b43d2a26add4121f8bd22d0ab8 | Python | 1,275 | 40 | import AIS_legality
import os
# common wrapperper
# overwrite
# multiple executions with lazy return
# df inputs
import pandas as pd
import import_AIS
def wrapper( the_func, arg = None, overwrite = False, nrows = None, multicolumn = False ):
def wrapper_helper( x, overwrite=False):
filename = th... |
e9f840991020241b662a19f3e6423a0660705a2c8dd0dcfab64fdcd8ca027b06 | Python | 1,275 | 45 | # -*- coding: utf-8 -*-
"""
@author: Satoshi Hara
"""
import sys
sys.path.append('../')
import numpy as np
from AlternateLinearModel import AlternateLogisticLasso
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
# get news20 data (computer)
categories = ['c... |
9b666d7a789f37a3204cb28ecf8fc11b331c177e23fbf6792311bd280076676f | Python | 1,276 | 48 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
from typing import List, Tuple
from tmkit.topology.pdbtm.Segment import Segment
class TMH:
def __init__(self, xml_fp: str, prot_name: str, seq_chain: str) -> None:
... |
ac27848f2528be666c62e95ec4776094f88a835883052e2aca29b7f2ea9d3620 | Python | 1,276 | 36 | import pytest
import numpy as np
from numpy.testing import assert_almost_equal, assert_array_almost_equal
from pycpd import rigid_registration
def test_2D():
theta = np.pi / 6.0
R = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]])
t = np.array([0.5, 1.0])
Y = np.loadtxt('dat... |
f5fbffa7ceb09a4a1a681b98e815fde2ffef450865e958cdc72573f89658b911 | Python | 1,276 | 43 | import numpy as np
from scipy import linalg as lin
from FBEM import triangleArea
def get_triangle_area(tria, coords):
xy1, xy2, xy3 = [coords[id] for id in tria]
return triangleArea(xy1, xy2, xy3)
def get_cosine(v1, v2):
return np.dot(v1, v2) / (lin.norm(v1) * lin.norm(v2))
def is_angle_satisfied(coo... |
c043db5ad1346557e3e631525d0a856dfc1501a362adb7daeab0b9c6f5f5b5a6 | Python | 1,277 | 50 | import re
import pickle
from charpragcap.utils.image_and_text_utils import split_dataset,index_to_char,devectorize_caption
from nltk.corpus import stopwords
id_to_caption = pickle.load(open("charpragcap/resources/id_to_caption",'rb'))
train,val,test = split_dataset(id_to_caption)
print(len(test))
def cap_to_words(ca... |
2ba916dcc7467ce344e5d8603b3b59c7448d47681d4e09bc87420442dba50b05 | Python | 1,278 | 29 | import sys
sys.path.append("/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/")
import connectome_tools.process_skeletons as proskel
'''
paths = ['axon_dendrite_data/splittable_skeletons_right2.csv',
'axon_dendrite_data/splittable_connectors_right2.csv',
'axon_dendrite_data/splittable_connec... |
6616f7b04c766d5a3c9591df49cc4e4fe4a6e5309fc542623743684fa0100f33 | Python | 1,278 | 45 | import os
import numpy as np
import scanpy as sc
from sklearn.model_selection import KFold
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--datadir',type=str, default='default')
parser.add_argument('--size_threshold', type=int, default=1000)
args = parser.parse_args()
datadir = args.datad... |
d3a6752c61eb4bca7190d60c57dfdf02551395a348ecbda1419740dbf18a8de5 | Python | 1,278 | 42 | """ A script to plot validation metrics produced by the model.
"""
from collections import namedtuple
import numpy as np
import pandas as pd
import plotly.graph_objects as go
_STEPS_PER_ITERATION = 5000
TraceSettings = namedtuple("TraceSettings", ["y", "name", "color"])
def plot_metrics(filename):
df = pd.read... |
2bd2ac975d2bb08f382f95f968c77b836d843dccfd8dc1f8d332f0f532ae27e8 | Python | 1,279 | 40 | import torch
from norse.torch.functional.lif_adex_refrac import (
LIFAdExRefracParameters,
LIFAdExRefracState,
)
from cgtasknet.net.lifadexrefrac import SNNlifadexrefrac
def test_init_lif_refrac():
input_s, hidden_s, output_s = 100, 100, 100
SNNlifadexrefrac(input_s, hidden_s, output_s)
def test_se... |
8870d54edb1e9de0ce852f6ead65af9e99fb34dc49a3d167e6e98b6077d3d2c9 | Python | 1,279 | 49 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import Optional
from tmkit.seqnetrr.ComputLib import ComputLib
class Param:
"""
A class representing a parameter.
... |
6b19441ef5159cec82e7a319c0e04ec7a1323e2fccd4eea01bf48460df3a8d8a | Python | 1,281 | 43 | import serial
from PyQt5.QtCore import QThread, pyqtSignal
# ----------------------------------------------------------------------------
class ArduinoThread(QThread):
""" Define an Arduino object to be able to listen to the serial port and
keep feeding the main program. Also used to send message to the Ardui... |
163db19ea9625511627fb7be11e778340d562fe30e9fe41e90892342da456114 | Python | 1,282 | 47 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import Dict
# from Bio.PDB.Polypeptide import three_to_one
from tmkit.base import PDB as bpdb
class PDB(bpdb.ID):
def __i... |
b8de4156869b6c0eb61812fa81821f6a12cc42a2c6c3cb88c1070057a419121f | Python | 1,282 | 40 | import logging
from pathlib import Path
from typing import Optional
class ATLogger():
"""Extentension of logging to easily log for both back and front end
in one line."""
def __init__(self, name: str):
self.name = name
self._logger = logging.getLogger(name)
self._config = {}
... |
922799c6b27ee3f21a40b6b6bba8125e085500fb56fe1ba736131a52033bd990 | Python | 1,283 | 29 | """
Defines paths to various directories and files specific to the running mode (locally or on a cluster).
Should be modified by users according to their particular needs.
"""
import os
NMSAT_HOME = os.environ.get("NMSAT_HOME")
# exit if environment variable is not set
if NMSAT_HOME is None:
raise EnvironmentErr... |
a2b7966ee9c9378e343e2e848b56036238f6a049db900b2c1f09ccef8ab51170 | Python | 1,283 | 54 | #!/usr/bin/env python
# Copyright 2018 Johns Hopkins University (Author: Aswin Shanmugam Subramanian)
# Apache 2.0
# Works with both python2 and python3
import numpy as np
import soundfile as sf
import time
import os, errno
from tqdm import tqdm
import argparse
from nara_wpe.wpe import wpe
from nara_wpe.utils import ... |
364d496c251a620e2cd21c330b93f2f0dc3bbe82afbf0faa389c2facc56036af | Python | 1,284 | 33 | import logging
from dataclasses import dataclass
from typing import Iterable
from linkml_runtime.dumpers import json_dumper
from oaklib.converters.obo_graph_to_fhir_converter import OboGraphToFHIRConverter
from oaklib.datamodels.obograph import GraphDocument
from oaklib.interfaces.obograph_interface import OboGraphIn... |
67f1f255416ca30ca1bd7b1d220ae56199d71cd9826b61914ae8f17de849d858 | Python | 1,284 | 44 | import unittest
import numpy as np
from deeprank_gnn.tools.pssm_3dcons_to_deeprank import pssm_3dcons_to_deeprank
from deeprank_gnn.tools.hdf5_to_csv import hdf5_to_csv
from deeprank_gnn.tools.CustomizeGraph import add_target
from deeprank_gnn.tools.embedding import manifold_embedding
class TestTools(unittest.TestCas... |
72f1eb2163222b7634a3e7fb7ecfc78393e6376a42971d30dac05593c8df60a8 | Python | 1,284 | 34 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
7762e8e59538c00351efbf84c9424f7cd00ccf663d26e777ed931943d171319f | Python | 1,285 | 32 | # Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
eae4e5fd21467179ee0a0a4f052fa7bef4a140c69d2aa4d5f1900434de09570d | Python | 1,285 | 55 | import pandas as pd
import torch, torchvision
import torch.nn as nn
from torchvision import transforms
from PIL import Image
from torch.utils.data import Dataset
from ctran import ctranspath
mean = (0.485, 0.456, 0.406)
std = (0.229, 0.224, 0.225)
trnsfrms_val = transforms.Compose(
[
transforms.Resize(224... |
480dfe37bc1efa92d6cae4abbe4853227426b777925048d58e96624b2e05dcbd | Python | 1,286 | 74 | import sys
from importlib import metadata as importlib_metadata
from . import (
cath,
collate,
edge,
feature,
fetch,
mapping,
msa,
mut,
ppi,
qc,
rrc,
seq,
topo,
vs,
)
__all__ = [
"cath",
"edge",
"seq",
"qc",
"msa",
"mapping",
"collate... |
48facf343e7f52a3db5da9e9ce80095c01e1c8c2a51373784d66b1ac8a075c69 | Python | 1,286 | 43 | from dataclasses import dataclass
from typing import Any
import pyhornedowl
import rdflib
from pyhornedowl.model import AnnotatedComponent
from oaklib.io.streaming_writer import StreamingWriter
@dataclass
class StreamingAxiomWriter(StreamingWriter):
"""
A writer that emits one axiom at a time in one stream
... |
889d79730628e41bb17b70565924546f99814bd2574ff04d69bf5340d8e02ecc | Python | 1,287 | 26 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
ee7f92c7a70f40b8fe4de5ae1f7794a0c46b0b52395c1fa72ac181a3d6ad0eda | Python | 1,287 | 59 | """cxmetadata -- cxsystem metadata information viewer
Usage:
cxmetadata (-h | --help)
cxmetadata META_FILE_PATH
Shows information about an array_run metadata file
Arguments:
META_FILE_PATH Path to array run metadata file
Options:
-h --help Show this screen
"""
import argparse
im... |
a51d6f9d6b018fcbac4f683483f223e95241acff14574c90d1f48b2e6877bfe6 | Python | 1,288 | 50 | '''
'''
import numpy as np
import carpet
import carpet.lattice.triangular as lattice
## Parameters
# Geometry
nx = 16
ny = 16 # even number
N = nx * ny
a = 18 # [um] lattice spacing
## Initialize
# Geometry
connections = [a * np.array([np.cos(psi), np.sin(psi)]) # First neighbours
for psi in np.li... |
be5bbd1bd08e72ed7f3f8e5061a5ad05233225b8f437ff3a58d5a6ada48de32c | Python | 1,288 | 54 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
import os
from tmkit.util.Kit import urlliby
def tmkit_data(
sv_fpn: str,
url: str = "https://sandbox.zenodo.org/record/1219139/fi... |
68637d6a8bc142e89f5ea622c77b7539581b9811d98eb2afcb929e8e844efb5f | Python | 1,291 | 42 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from tmkit.seqnetrr.ComputLib import ComputLib
class Pair:
def __init__(self, sequence, window_size, window_m_ids):
"""
... |
cba0f9729a8c297cede41449333ac113361f87b002c6eff634fcf0dee9ec44ad | Python | 1,291 | 70 | #!/bin/python
import argparse
import glob
import os
import re
import time
import itertools
import multiprocessing
from pandas import DataFrame, read_csv
import gc
from pathlib import Path
import logging
import yaml
from array_tomography_lib import ChannelFile, colocalisation, ColocalisationResult, segment
CACHE_... |
d626fc11f7053e00552403276e6e87c70a2eafef4e5ba4da8bdb5b765a14f4ab | Python | 1,291 | 49 | import os
import contextlib
from spotipy.model import Config
import albumentations as alb
with open(os.devnull, "w") as f, contextlib.redirect_stdout(f):
config_unet = Config(
n_channel_in=1,
backbone="unet",
mode="bce",
unet_n_depth=3,
unet_pool=4,
unet_n_filter_bas... |
5ca4cd9a0d5a59e793e5cfadfa36692cbca331cc004fa5495f7f4beaf9896f46 | Python | 1,292 | 34 | # -----------------------------------------------------------------------------
# Copyright (c) 2013-2019, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this ... |
7e2c8fd929f88a7d0c69c683638b7b41b6f19afd725b53bca32895f14d0fe2d3 | Python | 1,292 | 49 | import os
import timeit
import mne
from eelbrain import datasets, save
mne.set_log_level('warning')
fname = 'temp.pickled'
if not os.path.exists(fname):
ds = datasets.get_mne_sample(-0.1, 0.2, src='ico', sub="modality == 'A'")
source = ds['src'].source
y = ds['src'][0].x
save.pickle((y, source), fnam... |
b9ec3d220d30b82b2fa83f137761ef0ce8f83d261e00d1ba4c9a635505c88b06 | Python | 1,292 | 33 | # Some samples from BrainGVEx had 0 counts after quantification, have to redo. This should be a one-time-thing so just using hard-coded paths
import os
import synapseclient
import synapseutils
import argparse
import getpass
user = input("Synapse username:")
password = getpass.getpass('Synapse password:')
syn = synap... |
5c35256a960cc5cf96de4876eff4156aee68f0698e26eb354ac033f6d7018b20 | Python | 1,293 | 24 | import hashlib
def test_blob_upload_dedup_and_download(server):
data = b"hello cosmos" * 1000
bid = hashlib.sha256(data).hexdigest()
r = server.client.put(f"/v1/blobs/{bid}", content=data, headers={"Content-Type": "video/mp4", "X-Filename": "a.mp4"})
assert r.status_code == 201 and r.json() == {"id": ... |
a69e1117ef874c647054eceee9cf70092f00924631d18364e8938b610c18266d | Python | 1,293 | 55 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Module for useful functions related to multi-threading.
Created on Fri Dec 14 16:53:08 2018
@author: nicolas
"""
from multiprocessing import Process, Manager
def run_parallel(*fns):
"""
Run the called functions in parallel (use lambda keyword if needed).
... |
fe4268b26795e05e7e723bcb336beb914bae62e544c0d8ff84bbdeead8345ca2 | Python | 1,293 | 42 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from tmkit.seqnetrr.ComputLib import ComputLib
class Single:
def __init__(self, sequence, window_size, window_m_ids):
"""
... |
8e53d1205d5b4a508295763605374a846a9b9bb42496501c8720bdb6b68a3bf4 | Python | 1,294 | 40 | # basic imports
import numpy as np
import matplotlib.pyplot as plt
import pickle
def plot_replays(replays: list, file_name: str):
'''
This function plots replays (the first twelve).
Parameters
----------
replays : A containing the generated replays.
file_name : ... |
03dbef3ab2aab4334eb31c14dd18e8bbe701af682abd48c9f22626d9a9575279 | Python | 1,295 | 33 | import logging
from dataclasses import dataclass, field
from typing import Any, Dict, Iterable, Iterator, List, Tuple, Union
from urllib.parse import quote
import requests
from oaklib.datamodels.text_annotator import TextAnnotation
from oaklib.implementations import BioportalImplementation
from oaklib.interfaces.basic... |
06bd8fc2792ca9b44a06b341526a3bd893f327a65a30fb644361322d9f72c1a2 | Python | 1,295 | 39 | from __future__ import annotations
from palm_tools.data_structure.trackset import TrackSet
from .ts_post_processing import PostProcessingStep
from .post_processing_params import EmptyPostProcessingParameters
from typing import TYPE_CHECKING, List
import numpy as np
from sklearn.neighbors import KernelDensity
import pa... |
7898d77bfefbb2a1bf58c889d8fb7528688642878a035f2b254cc49d3d0baba2 | Python | 1,297 | 55 | #%%
import os
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from IPython import get_ipython # just to decieve flake8
import src.utils as utils
get_ipython().run_line_magic("autoreload", "2")
get_ipython().run_line_magic("matplotlib", "inline")... |
c041cdae240d603452d98de5311efca191cc11db37f865c18c237653eff202b2 | Python | 1,297 | 42 | import math
import torch
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
class GraphConvolution(Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
"""
def __init__(self, in_features, out_features, bias=True):
super(GraphConvolution... |
5584aaf215db7b35c7c10790d56ae244fbaa94c52c6356127ee0c330ec55d8d1 | Python | 1,298 | 34 | import torch
from collections import defaultdict
import numpy as np
class BernCorrupter:
def __init__(self, data, n_ent, n_rel):
self.bern_prob = self.get_bern_prob(data, n_ent, n_rel)
self.n_ent = n_ent
def corrupt(self, head, tail, rela):
prob = self.bern_prob[rela]
selectio... |
d70dac30bc5fcf240a2b0a570637b3411b1db3c91f3be688576295a441ef9cef | Python | 1,298 | 43 | import copy
import inspect
import torch
from ...utils import Registry, build_from_cfg
OPTIMIZERS = Registry('optimizer')
OPTIMIZER_BUILDERS = Registry('optimizer builder')
def register_torch_optimizers():
torch_optimizers = []
for module_name in dir(torch.optim):
if module_name.startswith('__'):
... |
ffac18446613588e05db186774a1ef04a03bd504a9b4a9a96bb3de16fd937b44 | Python | 1,298 | 46 | import torch
import numpy as np
from sklearn.metrics import f1_score
from ..data.datamodule import EMPTY_FIELD_VALUE
import torch.nn as nn
import torch
## Losses
def L2_loss(out, target, w):
# w : whether each sample has to be included
# for instance, OU don't have to be included in alpha,
# while LW don... |
b5c189d7dd1b7ce261222d76f4828ce0c8fa30c831fcb7d6f8d410696fb29920 | Python | 1,300 | 43 | from __future__ import annotations
import secrets
from .ts_post_processing import PostProcessingStep
from .post_processing_params import EmptyPostProcessingParameters
# from palm_tools.tif_tools.cell_mask import tag_localizations_per_cell, get_cell_mask
from typing import TYPE_CHECKING, List
import pandas as pd
import... |
0e8cdf0729b5b28205553bc00d9ff23ef6a8f64753f2d8f20aa13cb40d8fc9c7 | Python | 1,301 | 46 | import torch
import os
class Dictionary(object):
def __init__(self):
self.word2idx = {}
self.idx2word = {}
self.idx = 0
def add_word(self, word):
if not word in self.word2idx:
self.word2idx[word] = self.idx
self.idx2word[self.idx] = word
... |
1874beeb507b3f50eeb1506360c33f06384dc939188ec86f74e66a1cc84ccdc7 | Python | 1,301 | 52 | import numpy as np
import dipy.tracking.streamlinespeed as dps
def sl_curve(sl, n_points):
"""
Calculate the direction of the displacement between
each point along a streamline
Parameters
----------
sl : 2d array-like
Streamline to calcualte displacements for.
n_points : int
... |
1774ed6e63e70c41dffb74d702587cc74b0bb060267d1680c6b3746be977fe50 | Python | 1,302 | 43 |
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
def paramplot2(p1, p2, names=None):
nsub, nreg, m = p1.shape
assert p2.shape == (nsub, nreg, 2, 2)
if names is not None:
assert len(names) == m
fig = plt.figure(figsize=(6*m, 4*nsu... |
a9f72e613420928d4cf46e5621f71cefb0c46076e491947a4fb6e416eac3812a | Python | 1,302 | 45 | # -*- coding: utf-8 -*-
# Models of the data-driven dose calculator.
# COPYRIGHT: TU Delft, Netherlands. 2021.
import numpy as np
from tensorflow.keras import Sequential, layers, Model
from blocks import ConvEncoder, ConvDecoder, TransformerEncoder
def dota_energies(num_tokens, input_shape, projection_dim,
num_hea... |
061f8948fea0eccdae099e2c62a3df2cce61f378203cbbb886442e870dd670a9 | Python | 1,303 | 39 | import unittest
from oaklib import get_adapter
from oaklib.datamodels.vocabulary import IS_A, PART_OF
from oaklib.inference.relation_graph_reasoner import RelationGraphReasoner
from tests import CELL, IMBO, INPUT_DIR, NUCLEAR_MEMBRANE, NUCLEUS, ORGANELLE, VACUOLE
ONT = INPUT_DIR / "go-nucleus.obo"
ONT_OBO = INPUT_DIR... |
6941f13ea42f84f506531b27350ee8446bac89fe78b4b3e47dce1a6689b8f80c | Python | 1,303 | 50 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
import requests as r
from Bio import SeqIO
from io import StringIO
import pandas as pd
from tmkit.util.Writer import Writer
class Fasta:
... |
cc73d60b442eae17fbe85447c161c3a691f1021b9f5e68f33432e8fe30efa7fc | Python | 1,303 | 50 | """
Code to run Jupyter notebooks in /docs/source.
"""
import navis
from pathlib import Path
# If Jupyter is not installed, this will fail.
# We will belay the import error in case the
# user wants to run only the other parts of the
# test suite.
try:
import nbformat
from nbconvert.preprocessors import Execut... |
fc249066b49ae5796fa8f1bc57f3ceb00f07f9cbef76d6da09b0c53319ba9fe7 | Python | 1,305 | 27 | import torch
import torchvision
from .random_dataset import RandomDataset
def get_dataset(dataset, data_dir, transform, train=True, download=False, debug_subset_size=None):
if dataset == 'mnist':
dataset = torchvision.datasets.MNIST(data_dir, train=train, transform=transform, download=download)
elif ... |
1b72ec14e59eabdb52d287599bf1eb4efd870399b253bbe1125b3a33e388d4ca | Python | 1,306 | 58 | import sys
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
import pymaid
import pyoctree
from pymaid_creds import url, name, password, token
import numpy as np
import pandas as pd
import re
from itertools import chain
rm = pymaid.CatmaidInstance(url, token, name, password)
# breaking n... |
2134f22c2f9932cdd07756661a1351bea444ded65f9e75a744ddcd36f4980980 | Python | 1,306 | 45 | import sys
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
import pymaid
import pyoctree
from pymaid_creds import url, name, password, token
import numpy as np
import pandas as pd
import re
rm = pymaid.CatmaidInstance(url, token, name, password)
# save old skids/annotation corresponden... |
a34624697b72c1be82132cb1322bb267f60ceb2164c5da401f14f5a930d262eb | Python | 1,306 | 50 | import slideflow
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="slideflow",
version=slideflow.__version__,
author="James Dolezal",
author_email="james.dolezal@uchospitals.edu",
description="Deep learning tools for digital histology",
... |
be483ce1d194104c14e373309dcbcddbaee6ab8688d7447a2f9ad0da33ffc323 | Python | 1,308 | 43 | import numpy
import theano
import theano.tensor as T
import os
import urllib
import gzip
import cPickle as pickle
def mnist_generator(data, batch_size):
images, targets = data
images = images.astype(theano.config.floatX)
targets = targets.astype('int32')
def get_epoch():
rng_state = ... |
dc59645c5c247c5b0c91d163b0fea94657a2037167d590294ebdc63d8bf7f079 | Python | 1,308 | 37 | import subprocess
import multiprocessing
n_test_files = multiprocessing.cpu_count()
n_training_files = multiprocessing.cpu_count()
# Compares fingerprints between training and testing sets
for i in range(n_test_files):
print(i)
for j in range(n_training_files):
with open(
"similarity_resul... |
fb830eee438c112fc801905823784de031764d1971aefb4b2070981deba6867e | Python | 1,308 | 32 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
4b747b0e39135c61afdadb3b8a34065e62bd4112612dee57cbee2f73f9bb4072 | Python | 1,309 | 26 | from .base_roi_head import BaseRoIHead
from .bbox_heads import (BBoxHead, ConvFCBBoxHead, DoubleConvFCBBoxHead,
Shared2FCBBoxHead, Shared4Conv1FCBBoxHead)
from .cascade_roi_head import CascadeRoIHead
from .double_roi_head import DoubleHeadRoIHead
from .dynamic_roi_head import DynamicRoIHead
fro... |
52bc6dd7248c365b9d072a4739c39cfe675c4e1d87d46cdd89f960c38337b6e4 | Python | 1,310 | 49 | import logging
from abc import ABC
from typing import Dict, List, Tuple, Iterable
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
import sssom
from oaklib.types import CURIE
class MappingProviderInterface(BasicOntologyInterface, ABC):
"""
An ontology provider that provides SSSOM... |
7498e97be51756e1568d4ec488f2e3bce7d319a7cf2eeb812e4c0977529871bc | Python | 1,311 | 41 | #!/usr/bin/env python
"""
Script to add new vehicles to the vehicle factory and json file
"""
import unreal
import argparse
import json
argparser = argparse.ArgumentParser()
argparser.add_argument(
'-v', '--vehicle_blueprint_path',
metavar='V',
default='',
type=str,
help='Path to add to the vehicle... |
a32ecdf75c8a9cf013bf20d32c8e541c464f9b2df9f4b3c04b17c141ca717344 | Python | 1,311 | 47 | import networkx as nx
from graspologic.plot import networkplot
import seaborn as sns
from .bound import bound_points
def networkplot_simple(
A, node_data, palette=None, ax=None, group=False, edge_kws=None, compute_layout=True
):
if edge_kws is None:
edge_kws = dict(color="black")
if compute_layout... |
9dbdff959085a957490f1dfacf568bc6fd44d2a9aa66e965684caa16d940160d | Python | 1,312 | 45 | import logging
import re
from pathlib import Path
import mlflow
import torch.nn as nn
from pytorch_lightning.loggers import MLFlowLogger
logger = logging.getLogger(__name__)
def module_initialization(m: nn.Module, zero_batchnorm: bool = False):
"""Initialize modules using Kaiming."""
if isinstance(m, nn.Con... |
ff0ce27534f3c16034f202a9108f2fb133ca9e23213e98dd25d6c38a748729b5 | Python | 1,312 | 36 | import os
import yaml
def update_config(conf, new_conf):
for item in new_conf.keys():
if type(new_conf[item]) == dict and item in conf.keys():
conf[item] = update_config(conf[item], new_conf[item])
else:
conf[item] = new_conf[item]
return conf
class Config:
def __... |
415d97d524859c7a7062d7950b37a3d317c7f7fe8617551d6e235ec19dcd791b | Python | 1,313 | 32 | # Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
6031144f0d76d8903ce4b0c90b271ec89f4749d59da68402dc6264ac42d66187 | Python | 1,313 | 51 | """Metadata reader utilities"""
import errno
from pathlib import Path
CONFIG_NAMES = ['meta', 'conf', 'config', 'params', 'param', 'input']
def read_json(fd):
from json import load
return load(fd)
def read_yaml(fd):
from oyaml import safe_load
return safe_load(fd)
READERS = {'yml': read_yaml, 'ya... |
50631cce2a2e056f1c56d4a65b328144b33ea114b81799e99f302d4f401bec77 | Python | 1,314 | 65 | #%%
from src.data import load_june
from src.utils import meta_to_array
from graspy.utils import import_graph
import networkx as nx
graph = load_june("Gadn")
names = meta_to_array(graph, "Name")
names
classes = meta_to_array(graph, "Class")
classes
nodes = list(graph.nodes())
labels = dict(zip(nodes, names))
for i,... |
f74e657351cb7d2abc0af4cad8ddca3005775343091b4b5503adcf60fa47af79 | Python | 1,314 | 43 | from typing import Optional, Tuple
import norse.torch as snn
import torch
from norse.torch.functional.lsnn import LSNNParameters, LSNNState
from norse.torch.module.exp_filter import ExpFilter
from cgtasknet.net.save_states import save_states
default_tau_filter_inv = 223.1435511314
class SNNAlif(torch.nn.Module):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.