sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
797b68ab6d97536913182f286767afd21e04c1b5313198fa1c91993082d2753b | Python | 874 | 41 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import io
from imlib.dtype import *
from PIL import Image
def imencode(image, format='PNG', quality=95):
"""Encode an [-1.0, 1.0] into byte str.
Args:
format: 'PNG' or 'JPEG'.
qualit... |
a7b84e79601d27708059d567c862545a0159869192c14048355666ce5d70dd16 | Python | 874 | 33 | from setuptools import setup
import string
import os.path as op
import glob
from setuptools_scm import get_version
def local_version(version):
"""
Patch in a version that can be uploaded to test PyPI
"""
scm_version = get_version()
if "dev" in scm_version:
gh_in_int = []
for char i... |
c36815f7a0135156d12f94d25ece225b0125fd570f610fa580133d7a21248fa9 | Python | 874 | 28 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
"""Write text files"""
from .._utils import ui
def txt(iterator, fmt='%s', delim='\n', dest=None):
"""
Write any object that supports iteration to a text file.
Parameters
----------
iterator : iterator
Object that iterates over valu... |
d8a5f3b60781d0c231d5df5634432a9eb0c4e379c1acc3a4b5d68cad79a73ff5 | Python | 875 | 36 | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
sources = ['src/roi_pooling.c']
headers = ['src/roi_pooling.h']
extra_objects = []
defines = []
with_cuda = False
this_file = os.path.dirname(os.path.realpath(__file__))
print(this_file)
if torch.cuda.is_availa... |
1ea377958b03b73de52a52247b620e9536204fc5f57ac4ea8d5a75cba062cf7f | Python | 876 | 45 | import argparse
import pandas
import os
import numpy as np
import matplotlib.pyplot as plt
import functools
from collections import Counter
import math
import random
from sklearn.preprocessing import scale
S1_ROW = 5
S0_ROW = 6
PRED_ROW = 3
OUT_ROW = 2
def brier(S, input_):
s = 0.0
for i, e in enumerate(input... |
a4d3bf35c883e680512a3621a6983898e610c99751170d2b072371037346b209 | Python | 877 | 33 | '''
Input/output utilities
'''
from brian2 import *
__all__ = ['dictionary_units_to_str', 'dictionary_str_to_number', 'units_to_str']
def units_to_str(x):
'''
Converts x with units to strings for saving.
'''
if isinstance(x, str) or is_dimensionless(x):
return x
else:
return str(fl... |
da00dcadf2ec7c0d5d3f45cb7a268de2ac5860a6a94a8378e5580d2de6dc17c1 | Python | 877 | 28 | from functools import partial
import matplotlib.pyplot as plt
from pycpd import jrmpc_rigid
import numpy as np
import time
def visualize(iteration, error, X, Y, ax):
plt.cla()
ax.scatter(X[:,0] , X[:,1], color='red', label='Target')
ax.scatter(Y[:,0] , Y[:,1], color='blue', label='Source')
plt.text(0... |
1c0671cbdf4c2b138b915e41b99163e03fe28c0503409fd689ca14181b1fb2fd | Python | 880 | 18 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
2389f1978a70c668b5f03d7af58c756aa60ca2c5998dba332de4fedc724bb6f3 | Python | 880 | 31 | __author__ = "Aarthi Mohan"
__copyright__ = "Copyright 2021, Aarthi Mohan"
__email__ = "aarthi.mohan@sickkids.ca"
__license__ = "MIT"
import os, pandas as pd
from snakemake.shell import shell
benchmark = pd.read_table(snakemake.input.benchmark, dtype=str).set_index(["pipeline"], drop=False)
pipeline = snakemake.par... |
456438baf769c83e895865b968a368960ad99e839a6b25ee67985d3a5245f7a4 | Python | 881 | 36 | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
#this_file = os.path.dirname(__file__)
sources = ['src/roi_crop.c']
headers = ['src/roi_crop.h']
defines = []
with_cuda = False
if torch.cuda.is_available():
print('Including CUDA code.')
sources += ['sr... |
79b8059e5feef121d52c28ca4b26e839393f47ac3e4dd420d39ef4f6df232728 | Python | 881 | 38 | from dataclasses import dataclass
from typing import Optional
from oaklib.implementations.sparql.abstract_sparql_implementation import AbstractSparqlImplementation
from oaklib.interfaces.mapping_provider_interface import MappingProviderInterface
from oaklib.interfaces.obograph_interface import OboGraphInterface
from o... |
83c435bf547c7b9250d43ba7b52acf6dfb4358c769e3d5b80c1f7e62ff917073 | Python | 881 | 28 | from sklearn.ensemble import RandomForestRegressor
import numpy as np
from numpy import linalg
import pickle
from base import BaseModel
import typing
import os
class RFModel(BaseModel):
@classmethod
def name(cls):
return "random_forest"
def _train(self, train_features: np.ndarray, train_labels: ... |
9f392d49a60dd45aabf4ed02ad9733f2a417555bac23685f161e8426c58cdda8 | Python | 881 | 30 |
# This recipe shows in every script provided in PythonAPI/Examples
# and it is used to parse the client creation arguments when running the script.
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'--host',
metavar='H',
default='127.0.0.1',
... |
ddfa484b2287c30a8a5acf6bd7652098944a8a4332ad04f4427b520958fa7233 | Python | 881 | 20 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
6983baf433548a231d4fde81dc98ee1f8f33af20f49f238ecea18922545ab938 | Python | 884 | 33 | import networkx as nx
import matplotlib.pyplot as plt
from graphxai.datasets.ba_houses import BAHouses
def label_rule(self):
def get_label(node_idx):
return (self.G.nodes[node_idx]['shape'] > 0)
return get_label
bah = BAHouses(
num_hops=2,
n=100,
m=1,
num_houses=10,
shape_insert_s... |
11ae6ab16f14d8d91023cd0181568cc1fa106350ede6a37fc7d4591912bc7ccd | Python | 885 | 31 | from dataclasses import dataclass
from typing import Optional
from oaklib.implementations.sparql.abstract_sparql_implementation import (
AbstractSparqlImplementation,
)
from oaklib.interfaces.mapping_provider_interface import MappingProviderInterface
from oaklib.interfaces.obograph_interface import OboGraphInterfa... |
4d3c4789170bf31a1b65f751c2a42f5247e26e4943d613db24d21a4f99559467 | Python | 885 | 31 | # Remastering old graphs because they had some problems
# Not to worry too much, I was a genius and had saved the data for the graphs and since I do not have to plot them, I can reuse them
# %%
# Imports
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme(context='notebook', style=... |
ce3bb6f2d323a96b4203018f61915e2ea19acee22a58588cc04983c98a10ff5f | Python | 885 | 27 |
import sys
import numpy as np
import n5_metadata_utils as n5mu
#
# Read in the RS-FISH output (in voxel space) and output the points in microns
#
if __name__ == '__main__':
input_voxels = sys.argv[1]
output_microns = sys.argv[2]
n5_path = sys.argv[3]
extraction_subpath = sys... |
018abcfc3be8404b9b66ef73d45af70e4dc28c5c9b2348730d3e6379c40b2ca6 | Python | 887 | 28 | from __future__ import absolute_import, division, print_function, unicode_literals
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:skip
import env_tests.env as env_... |
57e774fc6e0c3d40bb9d0ede3dacdf86e6450932306cbb6c68c738a1fa71cc5e | Python | 887 | 18 | import drugex
import os
import nvgpu
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
INPUT_FILE = os.path.join(DATA_DIR, 'chembl_30_1000.smi' if 'INPUT_FILE' not in os.environ else os.environ['INPUT_FILE'])
assert os.path.exists(INPUT_FILE)
OUT_DIR=os.path.join(os.path.dirname(__file__), 'output')
os.makedi... |
8e41fcf9a7fa73c3bd493684a67bd855b3fb729532d4dc42526ce68e2790b3ac | Python | 887 | 27 | import unittest
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.utils.introspection import package_schemaview
from oaklib.datamodels import text_annotator
from tests import output_path, NUCLEUS
class TestTextAnnotatorDatamodel(unittest.TestCase):
def test_create(self):
"""
Tes... |
a898e5418ef181dda43ef197e566b2d5d86cd6e77f67e460b7240d1b8456ed32 | Python | 889 | 33 | # Remastering old graphs because they had some problems
# Not to worry too much, I was a genius and had saved the data for the graphs and since I do not have to plot them, I can reuse them
# %%
# Imports
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme(context='notebook', style=... |
693e706d31ec756f88a4ae031ca33106789e0ded1af539c83ed4da517bb3089d | Python | 890 | 43 | import gzip
import sys
## writes out lifted positions for original list of SNPs
infile = sys.argv[1] # Lifted BED file
infile2 = sys.argv[2] # SNPs.txt.gz to be updated
outfile = sys.argv[3] # outfile prefix
fh = open(infile,'r')
liftedmap = {}
# parse lifted bed file
for line in fh:
line = line.rstrip()
elems ... |
e8f397030f485601cb0a4838d585455ca2e79fb45a2414c60b0ba30fb5de8b0a | Python | 890 | 28 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 9 09:05:20 2021
@author: pearlsaldanha
"""
import os
os.chdir("/Users/admin")
from TRACER import *
atlas = AtlasLoader(atlas_folder='/Users/admin/TRACER/waxholm_atlas', atlas_version ='v4')
presurgery = ProbesInsertion(atlas, probe_folder ='/Use... |
72b175ad848a6b3667d1f90068900b75addd3060d163332438f9384c494e5c05 | Python | 891 | 1 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 9 09:05:20 2021
@author: pearlsaldanha
"""
import os
os.chdir("/Users/admin")
from TRACER import *
atlas = AtlasLoader(atlas_folder='/Users/admin/TRACER/waxholm_atlas', atlas_version ='v4')
presurgery = ProbesInsertion(atlas, probe_folder ='/Use... |
b044b3ce2a7e50491ad79eee5c15d2093d12c5172c54c985f4116a375ecbad81 | Python | 891 | 41 |
import sys
import numpy as np
import ndsvae as ndsv
def perturb_connectome(w, eps, seed=42):
np.random.seed(seed)
wr = np.random.normal(0, 1, size=w.shape)
wpert = np.maximum(w + eps*wr, 0.)
wpert /= np.max(wpert)
return wpert
def modify_dataset(input_file, output_file, img_dir, variant):
... |
76188d486aebc392e84affbd4b1c716e59b3ac6f1df7f375c173e5b2562a8b69 | Python | 892 | 20 | # Copyright (c) Open-MMLab. All rights reserved.
from .checkpoint import CheckpointHook
from .closure import ClosureHook
from .hook import HOOKS, Hook
from .iter_timer import IterTimerHook
from .logger import (LoggerHook, MlflowLoggerHook, PaviLoggerHook,
TensorboardLoggerHook, TextLoggerHook, Wand... |
edf41a590deee5b68c6e5345ec1f8b3f6ef1105ec8bfb6e78778e8c1666f1cc6 | Python | 892 | 21 | # Copyright (c) 2016, Konstantinos Kamnitsas
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the BSD license. See the accompanying LICENSE file
# or read the terms at https://opensource.org/licenses/BSD-3-Clause.
##################################... |
3d3f563b49fefce6a39a29e8b7a5aa6b2f41a9cf52dab2a67c6a417b3f07d616 | Python | 893 | 36 | #!/usr/bin/env python
import time
import torch
from engine.logger import get_logger
logger = get_logger()
def compute_speed(model, input_size, device, iteration):
torch.cuda.set_device(device)
torch.backends.cudnn.benchmark = True
model.eval()
model = model.cuda()
input = torch.randn(*input_... |
7a57bcad3a9682298910245fc5ea16c8e29f7e601c816bc48a2ad159e7d46348 | Python | 893 | 25 | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 7 10:20:44 2022
@author: Charitha Omprakash, LIN Magdeburg, charitha.omprakash@lin-magdeburg.de
This file converts a multi-animal DLC CSV to several single animal DLC files.
Those can be used as input to run VAME.
"""
import pandas, numpy as pd, np
import o... |
9e618972f185f0dc78e3a08cd2fe61716ed3bc75e59a164aaa69ef0792acb47c | Python | 893 | 38 | '''
Omega (spinning speed) vs. calcium concentration
'''
from pylab import *
width, height = 2, 2
K_electromotor = 1.4e-6 #2.4e-6 # in uM
n_electromotor_coupling = 2
omega_min = 1.
omega_max = 4.
fig = figure('Angle', (width,height))
ax = fig.add_subplot(111)
x = 1e-7*exp(linspace(0,6,100))
#electromotor_coupling... |
33797d7ecc3f3198e919505469268c572730778acee3b028b15b1517dcc8d933 | Python | 896 | 20 | import numpy as np
def select_nice_nodes(mg):
mg = mg[mg.nodes["paper_clustered_neurons"] | mg.nodes["accessory_neurons"]]
mg = mg[mg.nodes["hemisphere"].isin(["L", "R"])]
mg.to_largest_connected_component(verbose=False)
out_degrees = np.count_nonzero(mg.sum.adj, axis=0)
in_degrees = np.count_nonz... |
282673bc9d4bd7a37ad3ce7b1834ef9985b59f9cfb177e0c26efcc163e44c577 | Python | 897 | 31 | # %%
import pandas as pd
import networkx as nx
meta_loc = "maggot_models/data/raw/exported-traced-adjacencies-v1.1/traced-neurons.csv"
adj_loc = "maggot_models/data/raw/exported-traced-adjacencies-v1.1/traced-total-connections.csv"
meta = pd.read_csv(meta_loc, index_col=0)
g = nx.read_weighted_edgelist(
adj_loc, d... |
ac9b72239f3a75d14523a644bbfa55e5deb8c0d6d50832947e0743ad6ce723d8 | Python | 897 | 22 | from sim_geometry import *
import carpet.physics.kuramoto as physics
# Physics
period = 31.25 # [ms] period of cilia beat
freq = 2 * np.pi / period # [rad/ms] angular frequency
sin_str = 0.0016 * freq # coupling strength
# Load frequencies
period = 2 * np.pi / freq
t_max = 2 * period # for the solver
c... |
c52c3f9b520fe74549d89f65c636e79622c8e6524da30052eca48ee7d9dbd732 | Python | 898 | 27 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import tensorflow as tf
def load_checkpoint(ckpt_dir_or_file, session, var_list=None):
"""Load checkpoint.
Note:
This function add some useless ops to the graph. It is better
... |
1e9c2e7336e962bd43aea80705cc8e2021f37d7af0ab8195add834ee8bc7493d | Python | 899 | 13 | """Labelled grid: grid.py OUT.webp COLS name1.png:Label1 name2.png:Label2 ... [--tw 640]"""
import sys
from PIL import Image, ImageDraw, ImageFont
out, cols = sys.argv[1], int(sys.argv[2]); items = [a.split(":", 1) for a in sys.argv[3:] if not a.startswith("--")]
tw = 640; th = 360; pad = 8
F = ImageFont.truetype("/usr... |
9649eef53e307b90a6037b2cbfc22f3feb8994f9b540f85276877853f1e0b77e | Python | 899 | 23 | import os
import h5py
import numpy as np
def save_predictions(output_path, output_filename, col_name, dataset, compression=None):
if not os.path.isdir(output_path):
os.makedirs(output_path)
output_filepath = os.path.join(output_path, output_filename)
# convert float64 to float32 to save space
... |
863c67dbb8d971658e03949a04f2ff45b117979584b8e032055e1fbdf543a0d7 | Python | 902 | 23 | from easydict import EasyDict
from configs.experiments import task1_augmented_config
from copy import deepcopy
class_weights = {"approach": [1, 20],
"disengaged": [1, 50],
"groom": [1, 5],
"intromission": [1, 3],
"mount_attempt": [1, 100],
... |
ed8c9577b703d279ddcd296f57119b475a183d7eccf97a62dca13e9ac9f3db34 | Python | 902 | 38 | from __future__ import print_function
import os
import torch
from torch.utils.ffi import create_extension
sources = ['src/roi_align.c']
headers = ['src/roi_align.h']
extra_objects = []
#sources = []
#headers = []
defines = []
with_cuda = False
this_file = os.path.dirname(os.path.realpath(__file__))
print(this_file)
... |
861a7b648ba9d09777dd22161a92111088424bb2bb9f419310ef5ffa9ebfaa1f | Python | 903 | 23 | import numpy as np
import shutil
import os
pdb_database_dir = "/home/gainza/freyr/patches/masif/data/masif_ligand/data_preparation/00b-pdbs_assembly"
confirmed_computed_dir = "/home/gainza/freyr/patches/masif/data/masif_ligand/data_preparation/04a-precomputation_12A/precomputation/"
training_set = np.load('train_pd... |
bcecbc6ceaeb2326da4a92125dc3b6f59bd2f2ed214c23a519ae82d3c3f3c4ec | Python | 904 | 37 | """ split fasta file with multiple sequences into multiple fasta files with 1 sequence each"""
import os
import sys
# check arguments
if len(sys.argv) < 2:
print("\n---->>You need to specify where the big fasta file is")
exit()
# catch big fasta
fasta = open(sys.argv[1], "r").readlines()
# create new direct... |
cb635e707adda3d9cef513fbd8206f99461091cd4f979f5286c738cd6d8ba2ed | Python | 905 | 27 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import warnings
import grpc
GRPC_GENERATED_VERSION = "1.71.2"
GRPC_VERSION = grpc.__version__
_version_not_supported = False
try:
from grpc._utilities import first_v... |
2ef8309db689ab691ab3e760f28554802f000d84839e8ae0224e559ee7687cd1 | Python | 906 | 32 | """
Set of standardized tests for the clustering function of RACCOON
F. Comitani @2020-2022
"""
import os
import pandas as pd
import raccoon
def knn_test(data, ori_data, reftab, refpath, gpu=False):
""" k-NN classification test, euclidean grid.
Args:
data (pandas dataframe, matrix): input... |
31d2efa68e7288f2876996ff22395d22c2f8f280e7b680b935da411112e385e5 | Python | 906 | 26 | import unittest
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.utils.introspection import package_schemaview
from oaklib.datamodels import text_annotator
from tests import NUCLEUS, output_path
class TestTextAnnotatorDatamodel(unittest.TestCase):
def test_create(self):
"""
Tes... |
36b12949bd1000375f794e8761082999c7ab4d0d860b08a98ce7f484400d7dbb | Python | 906 | 23 | # 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... |
8bbc3c0c5a20caf0ad5f86e41666453bcc2831dfff3d7a02b84f2236f14bb296 | Python | 906 | 23 | # 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... |
11e6ae1b309b651314cd59889992ece8e2e6047f5a70fcb097c026eb52b532c8 | Python | 907 | 41 | from pathlib import Path
import pytest
from ppqm import chembridge, mndo, tasks
pytest.skip("Broken interface to MNDO", allow_module_level=True)
def _get_options(scr: Path) -> dict:
_options = {"scr": scr}
return _options
def test_optimize_water(tmp_path: Path) -> None:
mndo_options = _get_options(tm... |
d6f18e7539ad58ff1d2832c9873ff44c61d0b234f945ba4b08c398e0e19741c2 | Python | 907 | 20 | from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset
from .cityscapes import CityscapesDataset
from .coco import CocoDataset
from .custom import CustomDataset
from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset,
RepeatDataset)
from .deepfashion import D... |
65d8eb02bf3820fbec573f771c131225f0b6533b228203667e70d63c585290f2 | Python | 908 | 32 | """
environment
Created by: Martin Sicho
On: 06.06.22, 16:51
"""
import pandas as pd
from rdkit import Chem
from drugex.training.interfaces import Environment
from drugex.training.scorers.smiles import SmilesChecker
class DrugExEnvironment(Environment):
"""
Original implementation of the environment scoring... |
6aff4f72b31a36d02837a3c06fc405bfd0f3664b6b1796ad00a684b895d269e2 | Python | 909 | 29 | import logging
import unittest
from oaklib.datamodels.association import Association
from oaklib.parsers import G2T
from oaklib.parsers.association_parser_factory import get_association_parser
from tests import INPUT_DIR
INPUT_TSV = INPUT_DIR / "test-pairwise-associations.tsv"
class PairwiseAssociationParserTest(un... |
b46f38ed868c5c295c0c9d7b487d99bde621d78c43ba087cd0cd503ccb4ba560 | Python | 909 | 30 | import common
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
calls = pd.read_table(snakemake.input[0], header=[0, 1])
samples = [name for name in calls.columns.levels[0] if name != "VARIANT"]
sample_info = calls.loc[:, samples].stack([0, 1]).unstack().reset_index(1, drop=F... |
8a23c31d11b1289ffbbd0f91097c31c549480868ecbd902264029802c2f647e2 | Python | 911 | 30 | import numpy as np
import pandas as pd
import dask.array as da
from dask_image.ndfilters import convolve
def smooth_average(x, w):
r = (da.arange(w) - w / 2) / (w / 6)
gaussian = da.exp(-0.5 * r**2)
gaussian /= da.sum(gaussian)
return convolve(x, gaussian, "reflect").compute()
def mean_intensity_cen... |
ae44bd396d4da25fdc0ac0b4fa10f4d31a33191a9783915d2409bf203324eb1f | Python | 911 | 45 | __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 abc import ABCMeta, abstractmethod
class Topology(metaclass=ABCMeta):
"""
Abstract base class for top... |
c94cc19b1bf9f59af21a2770080f27c38c66d4c3b4d34444967b71697cc87913 | Python | 911 | 33 | __author__ = "Dennis Kao"
__copyright__ = "Copyright 2020, Dennis Kao"
__email__ = "dennis.kao@sickkids.ca"
__license__ = "BSD"
from snakemake.shell import shell
from os import path, popen
import shutil
import tempfile
shell.executable("bash")
outdb = snakemake.output.db
incalls = snakemake.input[0]
family=snakema... |
04710c91d0ec9f3c9ff1f172fd40d875a3d91fb2e2e0fcab8b4a06a5128dfc77 | Python | 912 | 34 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 14 13:36:26 2020
@author: jacopop
"""
# Store the transformed image features
class save_transform(object):
def __init__(self, tracker, coord, image, nolines):
self.Slice = tracker
self.Transform_points = coord
... |
2ab91e4a5e281c02800655328ebe094ce484eb6fc56da9d26417f309ef4ce419 | Python | 912 | 30 | import numpy as np
def get_x(paras):
x= []
lg10= np.log(10)
x.append(np.log(paras["orns_pns_ini"]["g"])/lg10)
x.append(np.log(paras["orns_lns_ini"]["g"])/lg10)
x.append(np.log(paras["pns_lns_ini"]["g"])/lg10)
x.append(np.log(paras["lns_pns_g"])/lg10)
x.append(np.log(paras["lns_lns_g"])/lg1... |
429fa29325e3b9e63e4a250ee026af613a73781ecdeed5a5a5150ecad3095bf8 | Python | 913 | 21 | from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
from oaklib.interfaces.mapping_provider_interface import MappingProviderInterface
from oaklib.interfaces.obograph_interface import OboGraphInterface
from oaklib.interfaces.ontology_interface import OntologyInterface
from oaklib.interfaces.rel... |
17770fe78ce8a1cbc1b43fe2788d716bf097521409918e9578f552a59f67b428 | Python | 914 | 32 | import networkx as nx
import matplotlib.pyplot as plt
from graphxai.datasets.ba_houses import BAHousesRandomGaussFeatures
def label_rule(self):
def get_label(node_idx):
return (self.G.nodes[node_idx]['shape'] > 0)
return get_label
bah = BAHousesRandomGaussFeatures(
num_hops=1,
n=50,
m=1,
... |
a60f06deafe416bef316617e286a73abfc108e7f9f76e9af838c488a44321080 | Python | 914 | 33 | import os
from pathlib import Path
from typing import Union
from dotenv import load_dotenv
def unify_path(path: Union[Path, str]) -> Path:
"""
Tries to bring some consistency to paths:
- Resolve home directories (~ → /home/username).
- Make paths absolute.
:param path: The original path.
... |
ff059f099fe34f96b1ebb965e30cfc82a377db39935cebad1424e585490215a2 | Python | 914 | 36 | """Step 2: Surface Extraction."""
from pathlib import Path
from osl_dynamics.meeg import parallel, rhino
# ----------------------------------------------------------------------------
input_dir = Path("BIDS")
output_dir = Path("derivatives")
log_dir = Path("logs/2_surfaces")
subjects = ["sub-01", "sub-02", "sub-03",... |
7b915af8d61e84ced5b22420ccb2fe7b5f8fa3846350596fb2ee9a61fd73f1b0 | Python | 916 | 21 | # 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... |
3aff01292b69e70fa2dee96748e086574390f1e7b80aa5d8083df43ff96fc4f8 | Python | 917 | 22 | # 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... |
fb60b4fffde8aef63edc49a155b821898d0b934655c34d55d4a13ba997d4301d | Python | 917 | 37 | from ftplib import FTP
import pandas as pd
import numpy as np
df_eff = pd.read_csv('diff_efficiency_neur.csv')
donors = df_eff.donor_id
ftpdir = 'ftp.sra.ebi.ac.uk'
ftp = FTP(ftpdir)
ftp.login()
def check_files(filelist, preq, strlist):
filelist = [f for f in filelist if preq in f]
filelist = [f for f in f... |
84a4b31186f9edc2abd755b78831bd9f7626f33fefba28433683720b563d1d5d | Python | 918 | 26 | """
TensorLayer provides rich layer implementations trailed for
various benchmarks and domain-specific problems. In addition, we also
support transparent access to native TensorFlow parameters.
For example, we provide not only layers for local response normalization, but also
layers that allow user to apply ``tf.nn.lrn... |
258030648061561c7dfa70f3f742f32ff2df57384e204b6e5efff80a8457048b | Python | 919 | 34 | '''
Analyzes particle density vs. time in PIV movies.
Selects those with high initial density.
'''
import pandas as pd
from brian2 import *
from scipy.optimize import curve_fit
from os.path import join
from fitting import *
from file_management import *
import yaml
import os
from file_management.file_utils import up_di... |
07ca86d89bad0794415a60914629d5e67714e3aeefede9029a6df74bf3397333 | Python | 921 | 20 | __author__ = "Johannes Köster"
__copyright__ = "Copyright 2016, Johannes Köster"
__email__ = "koester@jimmy.harvard.edu"
__license__ = "MIT"
from snakemake.shell import shell
remove_dups = snakemake.params.markDuplicates
remove_dups_flag = remove_dups.split("=")[1]
if remove_dups_flag == "false":
# mark duplica... |
d17b654cd20618cf570486e580f9ddcff09050c82ddfad4b1d49ec48383ad8b3 | Python | 923 | 25 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2017 Philipp Schlegel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of... |
d6e819fa6ebb2b9238493765b96f6f91a62d9d82a3d2910a006696a8ec2d3dbf | Python | 923 | 36 | from rdkit import Chem
from drugex.molecules.converters.interfaces import ConversionException, MolConverter
from drugex.molecules.mol import DrExMol
class SmilesToDrEx(MolConverter):
def __call__(self, smiles):
mol = None
try:
mol = Chem.MolFromSmiles(smiles)
except Exception... |
74ca13097f66e268bb0237bfba883faacf29ea32f57d1a75844dfb467540db74 | Python | 924 | 25 | '''
TODO: Test
'''
from sim_geometry import *
import carpet.physics.kuramoto_numba as physics
# Physics
period = 31.25 # [ms] period of cilia beat
freq = 2 * np.pi / period # [rad/ms] angular frequency
freq_vec = freq * np.ones(N)
sin_str = 0.0016 * freq # coupling strength
# Load frequencies
period = 2... |
ba16e95cef6411c7e86480c4da0c77d429949afcc1f765566417499ca8ed308c | Python | 924 | 39 | def set_up_full_recording(h,OU=True):
l=0
v_vecD4 = h.Vector()
v_vecD4.record(h.soma(l)._ref_v)
IhD4 = h.Vector()
IhD4.record(h.soma(l)._ref_ih_Ih)
INaD4 = h.Vector()
INaD4.record(h.soma(l)._ref_ina_Nasoma)
IKaD4 = h.Vector()
IKaD4.record(h.soma(l)._ref_ik_Ika)
... |
160d4a121527b45253083ea0def1bdb5f4b9de8b02a579e130be0eb8e3ea9374 | Python | 925 | 32 | import networkx as nx
import matplotlib.pyplot as plt
from graphxai.datasets.ba_houses import BAHousesRandomOneHotFeatures
# def label_rule(self):
# def get_label(node_idx):
# return (self.G.nodes[node_idx]['shape'] > 0)
# return get_label
bah = BAHousesRandomOneHotFeatures(
num_hops=1,
n=50,... |
1f67df2c9b13d1183a160fefa413b6aa9a6134a3c39feabf1c3f5da94b0470b4 | Python | 925 | 29 | from functools import partial
import matplotlib.pyplot as plt
from pycpd import rigid_registration
import numpy as np
import time
def visualize(iteration, error, X, Y, ax):
plt.cla()
ax.scatter(X[:,0] , X[:,1], color='red', label='Target')
ax.scatter(Y[:,0] , Y[:,1], color='blue', label='Source')
plt... |
440d5e3f8187ee0710b47db1800517005e30162b2edd2920c397e547ebfd2fe1 | Python | 925 | 30 | import logging
import unittest
from oaklib.datamodels.association import Association
from oaklib.parsers import PHAF
from oaklib.parsers.association_parser_factory import get_association_parser
from tests import INPUT_DIR
PHAF_INPUT = INPUT_DIR / "test.phaf.tsv"
class PhafAssociationParserTest(unittest.TestCase):
... |
561fa32235cfa8667b736bb6f1191f1f267c1a9d528198c2aa60d8d3c6763b14 | Python | 926 | 35 | """
Skeleton handling
Label conventions:
{1: 'axon',
2: 'basal dendrite',
3: 'apical dendrite',
4: 'ambiguous dendrite',
5: 'ambiguous',
0: 'soma'}
"""
import numpy as np
from meshparty import skeleton_io
SKELDIR = "../data/smoothed_skeletons_v185"
COMPLABELDIR = "../data/smoothed_skeletons_v185"
def read_neur... |
6551409875ac4687bf05f9448b3db2a90d5ac92cd09b052a4040e14fbfa01504 | Python | 926 | 27 | import os
import configparser
SEARCH_CONF_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../config/search_config.ini")
def get_config():
conf = configparser.ConfigParser()
conf.read(SEARCH_CONF_PATH)
if "SOLR_HOST" in os.environ:
conf['Search']["solr_host"] = os.getenv('SOLR_H... |
8eeb4962a15428e8c0d3bbc57a4cca49a5489b8ba3e737b5e31449b87a46abfa | Python | 926 | 49 | import torch
import time
from tensorly import tenalg
tenalg.set_backend("einsum")
from neuralop import get_model
# Read the configuration
from zencfg import make_config_from_cli
import sys
sys.path.insert(0, "../")
from config.test_config import TestConfig
config = make_config_from_cli(TestConfig)
print(config)
... |
031d620c8a13e941b97707b086c896e004301d3743838f4d040c7acb9c1be84a | Python | 927 | 25 | import torch.nn as nn
import numpy as np
import torch
class SpecificNorm(nn.Module):
def __init__(self, epsilon=1e-8):
"""
@notice: avoid in-place ops.
https://discuss.pytorch.org/t/encounter-the-runtimeerror-one-of-the-variables-needed-for-gradient-computation-has-been-modified-by-a... |
7ac8e24fc9fa13056bd68ac2966e9cd8e5b0b21561a4b34c277b5db005a4ef43 | Python | 927 | 22 | # 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... |
fb9c9e39f4fb2cadabb94111140ee39513eb3028fa29c1d1bf802dba18d7426c | Python | 928 | 29 | from functools import partial
import matplotlib.pyplot as plt
from pycpd import affine_registration
import numpy as np
import time
def visualize(iteration, error, X, Y, ax):
plt.cla()
ax.scatter(X[:,0] , X[:,1], color='red', label='Target')
ax.scatter(Y[:,0] , Y[:,1], color='blue', label='Source')
pl... |
d991346c06ad5d7c95a821650ea033e9f4ca11a1b64e0007d4179bd062e85aa5 | Python | 930 | 29 | import networkx as nx
def verify_motifs(G: nx.Graph, motif_subgraph: nx.Graph):
'''
Verifies that all motifs within a graph are "good" motifs
i.e. they were planted by the building algorithm
Args:
G (nx.Graph): Networkx graph on which to search.
motif_subgraph (nx.Graph): Motif to ... |
100e533a9aac905a524f794bbe00d406c6dfcb7a03810adca9f14b6b29ce678c | Python | 931 | 33 | __author__ = "David Laehnemann, Victoria Sack"
__copyright__ = "Copyright 2018, David Laehnemann, Victoria Sack"
__email__ = "david.laehnemann@hhu.de"
__license__ = "MIT"
import os
from snakemake.shell import shell
prefix = os.path.splitext(snakemake.output[0])[0]
# Samtools takes additional threads through its opt... |
54c6a152ccfe2c8333d43688d9d18623cce41fa5564e8f10f9a4e7bfa973211c | Python | 935 | 43 | __author__ = "Patrik Smeds"
__copyright__ = "Copyright 2019, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com.com"
__license__ = "MIT"
import os
from snakemake.shell import shell
input_known = snakemake.input.known
extra = snakemake.params.get("extra", "")
bed = snakemake.input.get("bed", None)
if bed is not None... |
7b49c37282b1eb0768959c769c6c42b006405d7eaf40559cc55b86f412f7844f | Python | 935 | 32 | """
tests.py
Created by: Martin Sicho
On: 22.04.22, 13:40
"""
from unittest import TestCase
from drugex.molecules.converters.standardizers import DefaultStandardizer
from drugex.molecules.mol import DrExMol
from drugex.molecules.suppliers import StandardizedSupplier, ListSupplier
class TestStandardizer(TestCase):
... |
a863f0e2741bfca9769ca1453b9ced2b9801758c5cb410710dd54e6627f74bfd | Python | 935 | 23 | """
This module provides the classes and methods for prediction handlers,
which generally are used for logging and saving outputs from models.
"""
from .handler import PredictionsHandler
from .handler import write_to_hdf5_file
from .handler import write_to_tsv_file
from .absolute_diff_score_handler import AbsDiffScoreH... |
f17a537a96415f48c6fccf44b2cc621add6c68626bcf1f6335dfc40a764b6d12 | Python | 936 | 29 | from functools import partial
import matplotlib.pyplot as plt
from pycpd import deformable_registration
import numpy as np
import time
def visualize(iteration, error, X, Y, ax):
plt.cla()
ax.scatter(X[:,0] , X[:,1], color='red', label='Target')
ax.scatter(Y[:,0] , Y[:,1], color='blue', label='Source')
... |
3f3b632ff411942e0a51a0e78be247b0bc51b72a53ffe66240c1bfa5e16c8d1f | Python | 938 | 27 | from setuptools import setup
def readme():
with open('README.rst') as f:
return f.read()
setup(name='pycpd',
version='1.0.5',
description='Pure Numpy Implementation of the Coherent Point Drift Algorithm',
long_description=readme(),
url='https://github.com/siavashk/pycpd',
cla... |
a2e335b4250137200ac4734494d70a9a06fc7968855efda31c7c3cd56327be57 | Python | 938 | 36 | import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="benchnirs",
version="1.7.1",
author="Johann Benerradi",
author_email="johann.benerradi@gmail.com",
description="Benchmarking framework for machine learning with fNIRS",
long_descriptio... |
a67501c7b615a23fddf3dadf8971303094a1e6a638e56b8aeba34e2e01162be9 | Python | 938 | 30 | import sys
import pdbfile as p
file = sys.argv[1]
mol_num = sys.argv[2]
mol_size = sys.argv[3]
idx_shift = (int(mol_num)-1)*int(mol_size)
x_shift = sys.argv[4]
y_shift = sys.argv[5]
z_shift = sys.argv[6]
delta = 0
def str_add (str1,str2):
return str(round(float(str1)+float(str2),2))
with open(file,'r') as f... |
a37e01c20513cfb4ce4d2393693750e4e0f2f25890cf1ab23c2fb8b1d0f46df2 | Python | 939 | 35 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import Any, Dict
from Bio import SeqIO
class Fasta:
def get(self, fasta_fpn: str) -> Dict[int, str]:
"""
R... |
30b0360a10a8f4fb81f3722a653ffa3af1135df61052ad936f57582f0e26224f | Python | 940 | 35 | import torch.nn as nn
import torch.nn.functional as F
class Deconv(nn.Module):
def __init__(self, input_channel, output_channel, kernel_size=3, padding=0):
super().__init__()
self.conv = nn.Conv2d(
input_channel,
output_channel,
kernel_size=kernel_size,
... |
f86e8e0062ed31a3061c20d9379668a176a78dde5ee04a3f984342a1a0046913 | Python | 941 | 48 |
import sys
import gzip
input = sys.argv[1]
output = sys.argv[2]
fh = gzip.open(input, 'rt')
fho = gzip.open(output,'wt')
fho.write(fh.readline())
ids = {}
eqtls = set()
print("Parsing: "+input)
print("Output: "+output)
written = 0
ctr = 0
for line in fh:
elems = line.strip().split("\t")
rsid = elems[0]
a1 = el... |
804acaab419d887e31b3c6c5694aa3f736e7e97e3e87d2fde266655fdfb1517d | Python | 942 | 34 | import os
import sys
from SBI.structure import PDB
from default_config.masif_opts import masif_opts
ligands = ["ADP", "COA", "FAD", "HEM", "NAD", "NAP", "SAM"]
if not os.path.exists(masif_opts["ligand"]["assembly_dir"]):
os.mkdir(masif_opts["ligand"]["assembly_dir"])
def assemble(pdb_id):
# Reads and builds... |
b2a38ba7df01267047a738eaf7bfbaa0e4cc3b9e8240fe401c626aca3318458b | Python | 942 | 43 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import numpy as np
from numpy.testing import assert_array_equal
from eelbrain import datasets, plot
from eelbrain._wxgui.testing import hide_plots
@hide_plots
def test_map2d():
"Test plot.SensorMap2d"
ds = datasets.get_uts(utsnd=True)
p = plot.Sens... |
fddd6be790c5b94dd4d7344719f8c4ae235ef8985ea74b95324f00704543c456 | Python | 942 | 32 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from maskrcnn_benchmark.structures.image_list import to_image_list
class BatchCollator(object):
"""
From a list of samples from the dataset,
returns the batched images and targets.
This should be passed to the DataLoader
"""
... |
7e8037e268524b9cd2fe80081116ae995dcd9b729b123e8db658e1b9f038e059 | Python | 943 | 36 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Simple dataset class that wraps a list of path names
"""
from PIL import Image
from maskrcnn_benchmark.structures.bounding_box import BoxList
class ListDataset(object):
def __init__(self, image_lists, transforms=None):
self.imag... |
9eab4451a16530b505f618d0a45f125edb347cb5140360a29f3d7c09c7e2e3f6 | Python | 944 | 23 | from sim_geometry import *
import carpet.physics.kuramoto as physics
# Physics
period0 = 31.25 # [ms] period of cilia beat
freq0 = 2 * np.pi / period0 # [rad/ms] angular frequency
sin_str = 0.0016 * freq0 # coupling strength
# Load frequencies
freq = np.load('freq.npy') # vector!
period = 2 * np.pi / fre... |
39142dc61166e358ca55bee415daaeb1469f3a62953e3ad569b3a00674e03679 | Python | 946 | 35 | import hashlib
import os
def get_file_checksum(path):
"""
Computes the MD5 hash of file contents
:param path: path to the file
:return: Hash value e.g. 391306c88b6f957a9d97a435bfc82e0d. If path doesn't exists, returns None.
"""
if os.path.exists(path):
with open(path, 'rb') as file:
... |
c0b010630c48119c979362a1e44ece2969b25f773ad9720db083bf3366b0271a | Python | 946 | 24 | # Parse GTEx fastq files to make molgenis-compute samplesheet
import sys
import os.path
import glob
# This simply uses all the fq files, not a smaplesheet. Better to rewrite to use a samplesheet
print('Not implemeted yet')
exit()
# sys.argv[1] should be directory with the batches that contain fastq files
if len(sys.a... |
73b33c281c78f9eca1457d39427acf21d1a149b56c7ce2db68df6b2bbfd384e8 | Python | 947 | 29 | """MNI152 brain masks and surfaces.
- MNI152_T1_1mm_brain.nii.gz
- MNI152_T1_2mm_brain.nii.gz
- MNI152_T1_5mm_brain.nii.gz
- MNI152_T1_8mm_brain.nii.gz
These files are downloaded on first use, see
:py:mod:`osl_dynamics.files._fetch`.
The masks define the MNI voxel grid :func:`osl_dynamics.meeg.source_recon.apply_lcm... |
817f293d5cbdc565fedfd5ddb43a65ef7cf4c280f83c8413ee2f85a5ea9c1b7b | Python | 947 | 32 | __author__ = "Patrik Smeds"
__copyright__ = "Copyright 2016, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com"
__license__ = "MIT"
from os import path
from snakemake.shell import shell
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
# Check inputs/arguments.
if len(snakemake.input) == 0:
raise ValueEr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.