sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
1fbcc2d21b9ad101199266ea3a61af840c2570c8652f37e2d53e44a198618776
Python
663
30
class SearchResults: def __init__(self): self.Keywords = [] self.Relationships = [] self.KeywordRelations = [] self.DirectRelationshipAnalogues = [] def GetNeuroLexUris(self): result = [] result.extend(self.Keywords.GetKeywordAndSubregionUris()) fo...
5cedf56f66b886c4f77090af4b8500bc15be4b47de61bdb7e6decc2649523276
Python
663
27
__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 def Style(sm_style: Optional[str] = "sticks") -> None: """ Change the representation style of the 'sm' ...
139cdddd9a3c5a2d1dc20de1f287707c20091f91aa659156b32aac06dd79ccd2
Python
665
20
__author__ = "Johannes Köster" __copyright__ = "Copyright 2018, Johannes Köster" __email__ = "johannes.koester@protonmail.com" __license__ = "MIT" from snakemake.shell import shell extra = snakemake.params.get("extra", "") java_opts = snakemake.params.get("java_opts", "") filters = [ "--filter-name {} --filter-e...
52f2729a027e0462c1fc8e947f98834b9f2a28067fe99c5efad797d2cf6c4005
Python
665
25
setup = """ from hyppo.ksample import KSample from sklearn.datasets import make_blobs n_samples = 1000 X1, y1 = make_blobs(n_samples=n_samples, n_features=3, centers=10) X2, y2 = make_blobs(n_samples=n_samples, n_features=3, centers=9) def broadcast_dcorr(data1, data2): ksamp = KSample("Dcorr", bias=False) s...
f5eace4fdcac6e6cbcb9be75308b6f7008881928ad7df2d7e8452f6e75392086
Python
665
14
# 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...
454dd63ad81e7ddde949b8c3874ec2bf3e44ebb4ef71adefe8d23f769c2b32f9
Python
666
7
from scicite.dataset_readers.citation_data_reader_aclarc import AclarcDatasetReader from scicite.dataset_readers.citation_data_reader_aclarc_aux import AclSectionTitleDatasetReader, AclCiteWorthinessDatasetReader from scicite.dataset_readers.citation_data_reader_scicite import SciciteDatasetReader from scicite.dataset_...
67a45b11b712da4477f597cbc2a4e492f26c7f9f7fdd54efa15bf306ab514d2c
Python
666
24
# Copyright (c) Open-MMLab. All rights reserved. import yaml try: from yaml import CLoader as Loader, CDumper as Dumper except ImportError: from yaml import Loader, Dumper from .base import BaseFileHandler # isort:skip class YamlHandler(BaseFileHandler): def load_from_fileobj(self, file, **kwargs): ...
8e290a84f99aceb507d97ec3ee3cd7aa52b1d083c7ad7ffa08cfa09d4023bff3
Python
666
30
__author__ = "Patrik Smeds" __copyright__ = "Copyright 2019, Patrik Smeds" __email__ = "patrik.smeds@gmail.com" __license__ = "MIT" from snakemake.shell import shell shell.executable("bash") log = snakemake.log_fmt_shell(stdout=False, stderr=True) extra_params = snakemake.params.get("extra", "") input_a = snakema...
12a1367d1079d6e0c26b270a39badc77f50433a9a5c45956865531c12b4e8178
Python
667
24
import socket import logging logging.basicConfig() logging.getLogger().setLevel(logging.CRITICAL) from gratin.training.callbacks import LatentSpaceSaver, Plotter from gratin.standard import train_model, load_model, plot_demo, get_predictions if __name__ == "__main__": if "jbmasson" in socket.gethostname(): ...
501a0abb2c11857b1f60067061862c30f0dcc6c63c254863facd1e84fddbdf91
Python
667
19
import os from subprocess import check_output __author__ = "Sebastiano Ferraris UCL" __licence__ = "MIT" __repository__ = "https://github.com/SebastianoF/bruker2nifti" __all__ = ["_cores", "_getters", "_metadata", "_utils", "converter"] # here = os.path.abspath(os.path.dirname(__file__)) # git_dir = os.path.dirname(...
f747da196f113d7bb914fbe73276c092a9542218e230d6d6411ffdd8bbed1e54
Python
667
14
# 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...
78ab690b2b54b8a46ebcf8a6e5e6fb4a04eb5eacf9746a4f91efece782743403
Python
668
18
import os.path as op import pandas as pd mriqc_dir = "/home/data/abcd/abcd-hispanic-via/dset/derivatives/mriqc-0.16.1" runs_to_exclude_qcfc_df = pd.read_csv(op.join(mriqc_dir, "runs_to_exclude_qcfc.tsv"), sep="\t") runs_to_exclude_qcfc = runs_to_exclude_qcfc_df["bids_name"].tolist() runs_to_exclude_FD_df = pd.read_c...
c2e6c98c36940fd3cb6312748ff9f207f42bf792b8825c6220de992c14fc7ab9
Python
668
25
import logging import unittest from oaklib.implementations.sqldb.sqlite_utils import sqlite_bulk_load import sqlite3 from tests import INPUT_DIR, OUTPUT_DIR TSV = INPUT_DIR / 'foo.tsv' DB = OUTPUT_DIR / 'test.db' TBL_NAME = 'my_tbl' class TestSqliteUtils(unittest.TestCase): def test_bulkload(self): if ...
4ccd16789a0358a1b52e678ff9356ce448146c106842f8384ec6efea1f16389b
Python
670
15
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from .coco import COCODataset from .concat_dataset import ConcatDataset """ For now, Pascal VOC and COCO Dataset are be supported by 2 dataload mode | Mode | Special_Deal | Post Branch | Annotation | 0 | False ...
ee43737ef496a3bd678c699e89f765a6abeb116b5f236e6bad0320fcaf5d4061
Python
670
25
""" Code adopted from pix2pixHD: https://github.com/NVIDIA/pix2pixHD/blob/master/data/image_folder.py """ import os IMG_EXTENSIONS = [ '.jpg', '.JPG', '.jpeg', '.JPEG', '.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP', '.tiff' ] def is_image_file(filename): return any(filename.endswith(extension) for exten...
b8f1d275c26d5fcb8605e5d6a1c71285cfae4ce816bbcb7dd918d5bc5969a325
Python
673
22
import community as community_louvain import matplotlib.cm as cm import matplotlib.pyplot as plt import networkx as nx # load the karate club graph G = nx.karate_club_graph() #first compute the best partition partition = community_louvain.best_partition(G) # compute the best partition partition = community_louvain.b...
85c6d2c799afadceb0d534c664aeb43727ffafc71f7d1547770a8ac3e6cd4730
Python
675
31
__author__ = "Patrik Smeds" __copyright__ = "Copyright 2018, Patrik Smeds" __email__ = "patrik.smeds@gmail.com" __license__ = "MIT" from snakemake.shell import shell extra = snakemake.params.get("extra", "") log = snakemake.log_fmt_shell(stdout=True, stderr=True) input = " ".join(snakemake.input.vcf) # if one sam...
cffac708b06e09a31225138f961ce5415d6079103a22acd2d5a62700703cb92b
Python
675
21
import setuptools from setuptools import find_packages with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="coreg-selector", version="1.0.0", author="Niek de Klein", author_email="niekdeklein@gmail.com", description="Small package to select data from a brain c...
3cf4d95122d3c322873bb1f4592c137c1543e1347677f3144dec02ef443eb9f6
Python
676
24
import math import numpy as np def get_basis_dual(a1, a2): ''' For the lattice :param a1, a2: basis vectors :return: dual basis vectors; https://en.wikipedia.org/wiki/Reciprocal_lattice ''' R = np.array([[0, 1], [-1, 0]]) # rotation by 90deg b1 = 2 * np.pi * (R @ a2) / (a1 @ (R @ a2)) ...
8e3dc62b9559d1609267562f28dc469d45b9d6c82fa45c231f64da6e56a90781
Python
676
32
import numpy as np from augmend import Augmend, Elastic from spotipy.model import Config, SpotNetData, SpotNet from spotipy.utils import points_to_prob if __name__ == '__main__': config = Config(axes = "YXC", n_channel_in=1) model = SpotNet(config, name = None, basedir = None) N = 200 P...
2ca6a8418b41156cd4df2046f8c1f067b1bad12bebfd472e465e287c54ee0f42
Python
677
26
""" Script to run the allennlp model """ import logging import sys from pathlib import Path import os sys.path.append(str(Path().absolute())) # from allennlp.commands import main from scicite.training.commands import main logging.basicConfig(format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', ...
01c5a4ed3cf9bcd0206c49ab2b1c2e29238325a587022a636f23e319db8e3f44
Python
678
31
import os import sys from pathlib import Path from setuptools import find_packages, setup sys.path.insert(1, os.path.join(sys.path[0], "..")) with open("requirements.txt") as f: required = f.read().splitlines() os.chdir(Path(__file__).parent.absolute()) setup( name="cgtasknet", version="0.0.1", pack...
5d5ece1e65ff0fc8538c5942ab9a7ed5a6b1653f4facac4a88172ceceaed031f
Python
679
22
import numpy as np def ntf_local(param,freq): gei = param[0] gii = param[1] tau_e = param[2] tau_i = param[3] w = 2 * np.pi * freq gee = 1 Fe = np.divide(1 / tau_e ** 2, (1j * w + 1 / tau_e) ** 2) Fi = np.divide(1 / tau_i ** 2, (1j * w + 1 / tau_i) ** 2) Hed = (1 + (F...
8023e29f5e48534b7771f19e904438f4b53c72a55b3b0807066b7e25903af4ce
Python
679
26
''' Solve a system of a moving sphere and a no-slip wall ''' import mesh import FBEM folder = 'data/sphere_plane' # Sphere parameters sphere_position = (0, 0, 5) radius = 1 velocity = (2, 0, 0) angular = (0, 0, 3) sphere_grid = 4 # Mesh consisting on 4x4 nodes # Plane parameters plane_position = (0,0,0) plane_radius...
dc3f052278993c0b1be7accb3c5999e307bcace772aad5eaaaf6fe13baf49dc8
Python
679
24
from PeptideBuilder import Geometry import PeptideBuilder import Bio.PDB def generate_peptide_alpha(sequence, filepath): alpha_phi = -60 alpha_psi_im1 = -40 # create a geometry for initialization of structure geo = Geometry.geometry(sequence[0]) geo.phi = alpha_phi geo.psi_im1 = alpha_psi_im...
fcc521eb696c21aadd3aed08dbaf8221cea75c6be869f393aa46716f794779d5
Python
679
20
"""Snakemake wrapper for GATK4 Mutect2""" __author__ = "Thibault Dayris" __copyright__ = "Copyright 2019, Dayris Thibault" __email__ = "thibault.dayris@gustaveroussy.fr" __license__ = "MIT" from snakemake.shell import shell from snakemake.utils import makedirs log = snakemake.log_fmt_shell(stdout=True, stderr=True) ...
7bb181e35fdef865094e4900da364d1dd1d5137809cfd86c8fa9d1fbd94e5101
Python
681
18
import torch import numpy as np import glob from gssc.train.DataManage import SeqDataSet from os.path import join ### basic example of how to make a Sequential Dataset. There wrap around a list ### of the more fundamental PSG DataSets, allowing one to grab a random PSG ### out of the entire dataset for training # we ...
91251ec9548a5db1303834b8a9532dc06a3c8e0de387d81159eeee0ce49c2ee3
Python
682
14
# Copyright 2020 Google Research. All Rights Reserved. # # 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...
aad38c04fa00ac51293783ca0a441a9e089bd07ffa893b801b5aeb67db8d3f89
Python
682
29
"""Deep learning and Reinforcement learning library for Researchers and Engineers""" from __future__ import absolute_import try: install_instr = "Please make sure you install a recent enough version of TensorFlow." import tensorflow except ImportError: raise ImportError("__init__.py : Could not import Tens...
f507c730accb630f31c3170cc56e6472ebbc38fdd6e1462eff508c20c76858f8
Python
682
36
''' Angle vs. calcium concentration ''' from pylab import * width, height = 2, 2 K_electromotor = 1.4e-6 #2.4e-6 # in uM n_electromotor_coupling = 2 theta_min = 13. theta_max = 90. fig = figure('Angle', (width,height)) ax = fig.add_subplot(111) x = 1e-7*exp(linspace(0,6,100)) theta = theta_min + 2*(theta_max-thet...
2ac78ac435ff3b9f82aa27cb8df6a240606d7309f10898d6a94d62241547fc29
Python
683
28
from typing import Any import oaklib.datamodels.oxo as oxo from linkml_runtime.loaders import json_loader def fix_json_payload(obj: Any) -> None: """ changes payload in place - self --> link_to_self :param obj: :return: """ if isinstance(obj, dict): for k, v in obj.items(): ...
c00b9d982066a64de2947364b8a4e2b7192cb739c9ae8bf15feef01bdb730be5
Python
683
23
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ from pdf2image import convert_from_path from pdf2image.exceptions import ( PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError ) PatientNumber = 311; #Insert patient number images = convert_from_path('Patient' + str(PatientNum...
6f0bb29dfe8ac2bf0c2c9beafbbf0935c48d8b7a8d4cc7bcadcf5b2e44100934
Python
684
16
import tensorflow as tf S = lambda x, y: tf.reduce_sum(x * y, axis=-1, keepdims=True) A = lambda x, k=-1: tf.expand_dims(x, axis=k) def cdist_tf_batch(A, B): na = tf.reduce_sum(tf.square(A), axis=-1, keepdims=True) nb = tf.transpose(tf.reduce_sum(tf.square(B), axis=-1, keepdims=True), [0, 2, 1]) return tf...
f2358ce099c25f1a33aee863e5bf7ae48f8d3184c6b13ef1ff6d405298c6eb3c
Python
684
19
import sys if sys.version_info[:2] >= (3, 8): # TODO: Import directly (no need for conditional) when `python_requires = >= 3.8` from importlib.metadata import PackageNotFoundError, version # pragma: no cover else: from importlib_metadata import PackageNotFoundError, version # pragma: no cover# try: ...
6a886e43bdfd7c9d0875690bdfcb620963868ff243ffabdbbbe070daef79c656
Python
685
20
from setuptools import setup, find_packages with open("README.md", "r") as fh: long_description = fh.read() setup( name='Catactor', version='0.1.2', description="scATAC-seq analysis using meta-analytic marker genes", long_description=long_description, long_description_content_type="text/markdo...
086ec7874f3c4cab57d51c3e84b970f6688abf1a84dacf1544a2fca28f0be462
Python
686
33
# Unit tests for sima/normcut.py # Tests follow conventions for NumPy/SciPy avialble at # https://github.com/numpy/numpy/blob/master/doc/TESTS.rst.txt # use assert_() and related functions over the built in assert to ensure tests # run properly, regaurdless of how python is started. from numpy.testing import ( ass...
7fc102ba67a233e1486a11f0bed8b99adf4ba5ba214a75f23730d9d7246a7e96
Python
686
31
from typing import Any from linkml_runtime.loaders import json_loader import oaklib.datamodels.oxo as oxo def fix_json_payload(obj: Any) -> None: """ changes payload in place - self --> link_to_self :param obj: :return: """ if isinstance(obj, dict): for _, v in obj.items(): ...
c82ab1a5526e63d01c61800b36f8872681961e4479e771d4bab4338a63d6c86e
Python
686
20
from scipy.stats import combine_pvalues, ks_2samp def degree_test(A1, A2, method="ks"): in_degrees1 = A1.sum(axis=0) out_degrees1 = A1.sum(axis=1) in_degrees2 = A2.sum(axis=0) out_degrees2 = A2.sum(axis=1) # # this is dumb in the sense that p-values aren't independent # in_stat, in_pvalue = ...
39fb1fff65b818bf934467efbb26f9047651ad19ac5bd8fbb27fdb67d6b63fdb
Python
688
24
import torch.nn.functional as F import torch def nll_loss(output, target): return F.nll_loss(output, target) def ce_loss(output, target): return F.cross_entropy(output, target) def ce_loss_weighted(output, target): weighted_loss = torch.tensor([0.34, 0.66]) return F.cross_entropy(output, target, wei...
e510cbab04ee808a13b2683213a42c06bc84a7a44c2dbfedc146d6d3ef54e6c6
Python
688
15
# 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...
e951a06cc11b7f6bfac9ee93b8bf7147891684106d249d32043be63271dc1dd5
Python
689
25
# Copyright (c) Open-MMLab. All rights reserved. from abc import ABCMeta, abstractmethod class BaseFileHandler(metaclass=ABCMeta): @abstractmethod def load_from_fileobj(self, file, **kwargs): pass @abstractmethod def dump_to_fileobj(self, obj, file, **kwargs): pass @abstractmeth...
0f77cf42ed9fd19d7bb3ab46a9ef644c2ca4d37498010da5fec72aa0e83bb08e
Python
690
23
""" Utilities used for annotation and lexmatch processes. """ from pathlib import Path from typing import List, Union def get_exclusion_token_list(exclude_tokens: Union[str, Path]) -> List[str]: """ Return a list of token to be excluded from NER analysis. :param exclude_tokens: Either a file path or the...
ccf85a7c0accd7b24b6c48e24fd5589d3c4a69fb683ae8509bba8b3cd011b19a
Python
690
25
import argparse import glob def main(): parser = argparse.ArgumentParser() parser.add_argument('input', help='') parser.add_argument('output', help='') args = parser.parse_args() ref = [] for f in glob.glob(args.input + '/**/*.ref', recursive=True): with open(f) as fin: ref...
9acfeec89bf2df8a416a6f663c193843ca45b5c40dcad02d40bd2a2264e0cac3
Python
692
29
import unittest import h5py from deeprank_gnn.tools.BioWrappers import get_bio_model, get_depth_res, get_depth_contact_res, get_hse class TestBioWrappers(unittest.TestCase): def setUp(self): self.pdb = 'tests/data/pdb/1ATN/1ATN_1w.pdb' def test_hse(self): model = get_bio_model(self.pdb) ...
8ce08aacde429d2ae25b81ac2d4b5e037a3f801ecd88a6fdbeec320748138575
Python
693
32
import subprocess from argparse import ArgumentParser import os from glob import glob from warnings import filterwarnings filterwarnings("ignore") my_parser = ArgumentParser(description="Run analysis on a group of images") my_parser.add_argument( "Path", metavar="path", type=str, help="the path to ...
0b0ec868ed9dc3dc2c1a80c38610f3fa445fa75034be21095cb2e00ec62c92cc
Python
696
24
import unittest from oaklib import get_adapter from oaklib.interfaces.association_provider_interface import ( AssociationProviderInterface, ) # TODO: use mock tests class TestAmiGO(unittest.TestCase): """ Tests :ref:`AmiGOImplementation` """ def setUp(self) -> None: self.adapter = get_ad...
98cd7e84ea3505a60aff21abeb1253c8f931b45bbdd3511328d5ab9a70d83996
Python
696
26
#!/usr/bin/env python import os from setuptools import find_packages, setup def read(fname): with open(os.path.join(os.path.dirname(__file__), fname)) as f: return f.read() setup( name='ranger', version='0.1.dev0', packages=find_packages( exclude=['tests', '*.tests', '*.tests.*', 't...
a5bcb5bc52a05c8c993c0a1ea180ec0ff396584b8c819cb49cff982899fa6cbc
Python
696
25
import torch import cv2 from PIL import Image import torch.utils.data import numpy as np class Dataset(torch.utils.data.Dataset): def __init__(self, imList, labelList, transform=None): self.imList = imList self.labelList = labelList self.transform = transform def __len__(self): ...
c76f9483047ee63b1b7601de767d7074b7dea28a664c71031cc9bbc17bdeed8d
Python
697
19
"""Parser for GAF association formats""" from dataclasses import dataclass, field from oaklib.parsers.parser_base import ColumnReference from oaklib.parsers.xaf_association_parser import XafAssociationParser @dataclass class HpoaG2PAssociationParser(XafAssociationParser): """Parsers for Hpoa G2P format.""" ...
e88dc2de5730011c4c37b8e08350d32189506cdb583312d9c069ea962e8b5989
Python
697
31
# add my own enviromment to the registry, and thus make it available for gym.make() import logging from gym.envs.registration import register logger = logging.getLogger(__name__) register( id='FdtdEnv-v0', entry_point='DRL.envs:FdtdEnv', max_episode_steps=300, reward_threshold=150, ) '...
eb0b79645161e88664594a3f9edfbd0f6cd0916ab65d99b78b2ccdce48e2cf00
Python
697
34
import sys import gzip if len(sys.argv) < 5: print("Usage: chr sta sto out") else: chr = int(sys.argv[1]) sta = int(sys.argv[2]) sto = int(sys.argv[3]) outp = sys.argv[4] fh = gzip.open('./SNPQCLog.txt.gz','rt') fho = gzip.open(outp,'wt') ctr = 0 written = 0 for line in fh: line = line.strip() if ctr ...
02369d214e6bed4ed6566ab4b6974709946d7d6aede8824e93feb991e8c2eac5
Python
698
21
import mesh.plot.vedo_viewer as plot3D path = 'data/sphere_wall' # Plot with random colors for each object m = plot3D.MeshViewer(path, group='.') plotter = m.show(axes=1) plotter.close() # important to close plotter afterwards! # Plot with pre-defined colors names = ['sphere', 'plane'] colors = [None, 'grey'] # Non...
b87af7542f656569d4641f0294b0720f9f1bb9cb669e36253ccc775956e890b7
Python
698
25
import cv2 import numpy as np from cenfind.core.detectors import extract_cilia def test_extract_cilia_detects_elongated_blob(make_field): data = np.zeros((2, 300, 300), dtype="uint16") cv2.ellipse(data[1], (150, 150), (60, 10), 30, 0, 360, 4000, -1) field = make_field(data=data) cilia = extract_cili...
bdd28a6e662edb2f1146cce02432853bfe3ca5253d8c5ef170178fa2a7650911
Python
699
34
__author__ = "Jan Forster" __copyright__ = "Copyright 2020, Jan Forster" __email__ = "j.forster@dkfz.de" __license__ = "MIT" from snakemake.shell import shell ## Extract arguments header = snakemake.input.get("header", "") if header: header_cmd = "-h " + header else: header_cmd = "" samples = snakemake.inpu...
2c7fe699c8a28563f445ec85b9f8ab6d631254b9b87a724a3ae637a9a0c04ae5
Python
700
19
#!/usr/bin/env python # Copyright 2015 David Snyder # Apache 2.0. # # This script prints out lines of the form: # <score> <target-type>. # Its output is meant to be used as input to the binary # compute-eer. The Broadcast News utterances have either # "music" or "speech" in the utterance name, and so we # can simply ...
da2cc9347f1cb0e9336c0ab5df1fe11f1a9b8584f256d776a86300eae14e4a99
Python
701
25
import torch import torch.nn as nn class separation_loss(nn.Module): """ Separation constraint """ def __init__(self, n_kpts=8, weight=0.01): super(separation_loss, self).__init__() self.weight = weight self.K = n_kpts def forward(self, input): input_1 = t...
4d014c530545c497afdca6712926e90bac88c24a50c0b08d63daa137e490fcd5
Python
702
14
"""Fail unless a built wheel carries the three models and the 138 example tests, and no junk.""" import sys import zipfile names = zipfile.ZipFile(sys.argv[1]).namelist() models = sorted(n for n in names if n.startswith('pyoxynet/models/') and n.endswith('.tflite')) examples = [n for n in names if '/data_test/' in n a...
7aaf64b4afd8ed7a71d900268dfb195d508d3f38952139c1433b82b7d23faa79
Python
703
31
# libraries import numpy as np from bio_embeddings.embed import ProtTransT5BFDEmbedder import pandas as pd embedder = ProtTransT5BFDEmbedder() ds = pd.read_csv('Dataset.csv') sequences_Example = list(ds["Sequence"]) num_seq = len(sequences_Example) i = 0 length = 1000 while i < num_seq: print("Doing", i, num_seq)...
ced5e67672a6e1be51fffa37ac77acdb8426a87a416fdd917d6984b134ff645e
Python
703
20
import torch import torch.nn as nn import torch.nn.functional as F # adopted from https://github.com/pytorch/pytorch/issues/8985#issuecomment-405080775 class ConditionalBatchNorm1d(nn.Module): def __init__(self, num_features, condition_dim): super().__init__() self.num_features = num_features ...
6c3113b179aac7e580516d8ab3c011043b72a3aeb86df064546019fbea36636c
Python
704
33
import sys import torch import matplotlib.pyplot as plt from sklearn.manifold import TSNE from graphxai.datasets import ShapeGGen try: nclusters = int(sys.argv[1]) except: print('usage: python3 test_clusters.py <n_clusters_per_class>') exit() SG = ShapeGGen( model_layers = 3, make_explanations=Fa...
d903e28bd5f0c824650b98bde2a40177918c644dd33496832e8364c6cc30c931
Python
704
16
# 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...
0cbddc516691e48a4eb53f5b9a0f0b2f0287d29f009ba715aed0cee311d101cd
Python
705
28
import os from polychrom.polymerutils import load, save class LegacyReporter(object): def __init__(self, folder): """ """ if not os.path.exists(folder): os.mkdir(folder) if len(os.listdir(folder)) != 0: raise RuntimeError(f"folder {folder} is not empty") se...
53a6217f26e53425a7b1066b86c87f808b44b733b5b05a10a5140bb969688233
Python
708
21
""" Setup file for palm-tools. Use setup.cfg to configure your project. This file was generated with PyScaffold 4.1.3. PyScaffold helps you to put up the scaffold of your new Python project. Learn more under: https://pyscaffold.org/ """ from setuptools import setup if __name__ == "__main__": t...
c41f897f5935808519113111c5d97f31c6c855d3ac86bd2006b5b311d1c73974
Python
708
19
"""Parser for PomBase PHAF association formats""" from dataclasses import dataclass, field from oaklib.parsers.parser_base import ColumnReference from oaklib.parsers.xaf_association_parser import XafAssociationParser @dataclass class PhafAssociationParser(XafAssociationParser): """Parsers for PHAF format.""" ...
da7129a92e64184618e09fc3b632b977af76bab6980614157432e94699953221
Python
708
42
import sys import gzip if len(sys.argv) < 4: ctr = 0 for arg in sys.argv: print("{}\t{}".format(ctr,arg)) ctr = ctr + 1 print("Usage: input.txt.gz output.txt.gz filter.txt") exit() input=sys.argv[1] output=sys.argv[2] filter=sys.argv[3] print("Input "+input) print("Output "+output) print("Filter "+filter)...
f0b71cccdb12623a0a8607fe582617be91b4b65a26c83b529c4f29a8f116d7fd
Python
708
20
from mip.min_w import MIN_W from mip.max_correct import MAX_CORRECT from mip.min_hinge import MIN_HINGE from mip.sat_margin import SAT_MARGIN from mip.max_m import MAX_M def get_nn(loss, data, architecture, bound, reg, fair): if loss == "min_w": return MIN_W(data, architecture, bound, reg, fair) elif loss == ...
48f73b58e745eb07b759c02892f2e59997d3268f0aaa5b6cece43581ee4e009b
Python
709
25
"""Snakemake wrapper for picard CollectHSMetrics.""" __author__ = "Julian de Ruiter" __copyright__ = "Copyright 2017, Julian de Ruiter" __email__ = "julianderuiter@gmail.com" __license__ = "MIT" from snakemake.shell import shell inputs = " ".join("INPUT={}".format(in_) for in_ in snakemake.input) extra = snakemake...
62d56eee5d97596bcc069fd26bda6099a05f1f23f11259b28e0f24091807486c
Python
709
20
# Copyright (c) Open-MMLab. All rights reserved. from .registry import MODULE_WRAPPERS def is_module_wrapper(module): """Check if a module is a module wrapper. The following 3 modules in MMCV (and their subclasses) are regarded as module wrappers: DataParallel, DistributedDataParallel, MMDistributedD...
8b949284e3dc9500e74bc049b16ce5b8c66cd1df7e5d8f0edb189a559226ad0a
Python
709
16
# 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...
c3fd72ec20c6c04cf008fd482f35ffebcb0d712401ecac7fa3f814786591ef58
Python
709
20
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Variational Animal Motion Embedding 0.1 Toolbox © K. Luxem & P. Bauer, Department of Cellular Neuroscience Leibniz Institute for Neurobiology, Magdeburg, Germany https://github.com/LINCellularNeuroscience/VAME Licensed under GNU General Public License v3.0 """ import ...
55a6d0335354432fd8d56e094a08bc2100cda65b3220116114e1955203bf0ec3
Python
710
27
''' Manages the configuration file ''' import os import yaml __all__ = ['data_folders', 'config', 'python_binary'] def load_configuration(): with open(os.path.expanduser('~/.paramecium_model_fitting.yaml'), 'r') as fp: config = yaml.safe_load(fp) return config def data_folders(year=None): if year...
8b87063f21764df7ac8365d4cc81ef0d8a1fb5f8d528023c36479e46b1d911d7
Python
710
23
import numpy.testing as npt import AFQ.data.fetch as afd from AFQ.utils.conversion import matlab_tractography, matlab_mori_groups import os.path as op DATA_PATH = op.join(op.abspath(op.dirname(__file__)), "../../tests/data") def test_matlab_tractography(): sft = matlab_tractography( op.join(DATA_PATH, ...
858883e71f9b38863975704dba5b20205a70d0d4a8458cbf587a9ab78dc8c2c6
Python
711
21
import numpy as np from numba import jit, prange @jit(nopython=True, parallel=True) def bootstrap_ci(data, n_boots=1000): '''data = M x N matrix, where M is the number of trials, N is the number of observations Returns: mus: n_boots x N matrix''' mus = np.zeros((n_boots, data.shape[1])) n_tria...
86ed52e3ccc6448f10b5ad31d806ee78a1f4818687ff9bd88cbc95babd5260f2
Python
711
18
"""Shared between the AV socket worker and the torchrun rank loop.""" from __future__ import annotations from ..common.ranks import READY_FILE, SHUTDOWN_FILE # noqa: F401 - re-exported for callers CAMERA_KEYS: dict[str, str] = { "camera:front:wide:120fov": "front_wide", "camera:cross:left:120fov": "cross_le...
80f7495b35217ad12e3f6cc1ab3fdfd33d738fa884f3898ff3e768e03610b634
Python
712
16
import yaml from oaklib import get_adapter from oaklib.interfaces.semsim_interface import SemanticSimilarityInterface from oaklib.utilities.subsets.subset_validator import SubsetValidationConfig, validate_subset from tests import EXAMPLE_ONTOLOGY_DB, INPUT_DIR def test_validate_subset(): adapter: SemanticSimilar...
9c91fdf842a8f29b77f82f68422cbad3d5d44b2f56a19608825bcbe35cd654f3
Python
713
34
import torch import matplotlib.pyplot as plt from tqdm import tqdm def get_edge_index(fname): L = [] with open(fname, 'r') as f: for l in f: line = [float(g) for g in l.split()] L.append(line) #L.append() edge_index = torch.tensor(L).transpose(0,1) return edge_...
a8dd56c0251416b0ded980aaa252b62ee2e85c0cc0a6ac5dfb30ba54f6c40619
Python
713
17
# 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...
6f463283c57c8a8b4793414723ebfccac84daa8c96d70a28c596eb9317d9d396
Python
714
32
import os import sys from datetime import datetime from importlib.metadata import version sys.path.insert(0, os.path.abspath(os.path.join('..', '..'))) project = 'CenFind' author = 'Leo Burgy' copyright = f'{datetime.now().year}, {author}' version = version("cenfind") release = version extensions = [ 'sphinx.ext...
87cd31b95af280ec7162b650c254253e891cc2c7f5bc0735a43ba5c46734a5a2
Python
714
19
# This recipe turns on deterministic collisions, so that a synchronous # simulation with crashes in it repeats exactly from one run to the next. # The setting applies when the map loads, so reload it keeping the settings. settings = world.get_settings() settings.synchronous_mode = True settings.fixed_delta_seconds = 0...
6f215ff28eef0563f44e9e8a5e10a411514927a6e58187915a77b777e8c0bb00
Python
715
27
import mesh.plot.flowfield as ff import matplotlib.pyplot as plt import matplotlib as mpl folder = 'data/cilia_plane2' flowfield = ff.extract_flowfield(folder) projection = 'yz' x1range = -15, 15 x2range = -1, 10 grid_color = 30 grid_arrows = 10 offset = 0 # Normalize velocity_max = 0.1 # vectors_max[0] norm = mp...
09a9185dfa1b19fecae788bbd3bf73cf03edde4219d5a94b38177e8b7cb26632
Python
717
23
from typing import Any, List, Optional from zencfg import ConfigBase from config.distributed import DistributedConfig from config.models import ModelConfig, FNO_Small2d from config.opt import OptimizationConfig, PatchingConfig from config.wandb import WandbConfig class Data(ConfigBase): train_resolution: int = 1...
4e6a9231fd47af3011889a21c81d26dc8ef7597fee728ee93519a5607698c176
Python
717
17
from drugex.data.corpus.vocabulary import VocSmiles from drugex.data.datasets import SmilesDataSet from drugex.training.models import SequenceRNN from drugex.training.monitors import FileMonitor from ..settings import * def main(): data_sets = [SmilesDataSet(f'{OUTPUT_FILE}_{split}.tsv', rewrite=False) for split i...
5e51cea6388fec780b3b11fe952a2cb89c8c39517505856152c2452ed43a7b80
Python
718
16
# 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...
9fb3518e054a38d1865efbdf89285a306ce3510a9ee28502715bb34e7c3a109f
Python
718
17
import numpy as np class SampleStandardizer(object): # this transformation object is very simple. At creation, a mean and # standard deviation are specified. When a sample is passed through, the # image portion of the sample is normalized so that the intensity values # are capped to the given range, t...
1e8f0a8b39f964754798088e776fad15d4b1823b2037aa13954cb851ccf04103
Python
721
37
# Unit tests for sima/oPCA.py # Tests follow conventions for NumPy/SciPy avialble at # https://github.com/numpy/numpy/blob/master/doc/TESTS.rst.txt # use assert_() and related functions over the built in assert to ensure tests # run properly, regaurdless of how python is started. from numpy.testing import ( assert...
d44f724bad66abb0be7a273aba69d87b80e46013372c3292aa487a199929aa0f
Python
722
26
import torch def correct_predictions(model, data, data_mask = None, get_mask = False): ''' Get all indices of nodes that were correctly predicted by model ''' model.eval() with torch.no_grad(): out = model(data.x, data.edge_index) pred = out.softmax(dim=1).argmax(dim=1) # Use th...
2d399c75b2ccbf9170f57802daf6870d342d778b28270bcd2f14e9e8be497417
Python
723
24
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> import ast FLOAT_PATTERN = "^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$" POS_FLOAT_PATTERN = "^[+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$" INT_PATTERN = "^-?\d+$" # matches float as well as NaN: FLOAT_NAN_PATTERN = "^([Nn][Aa][Nn]$)|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9...
2260afddc3a1833d90074eff0ad66ab2c80ed6816966cc96a17226cf68a0be08
Python
724
31
import unittest import h5py from deeprank_gnn.Graph import Graph class TestGraph(unittest.TestCase): def setUp(self): self.graph = Graph() self.graph.h52nx('tests/hdf5/1ATN_residue.hdf5', '1ATN_1w') self.graph.pdb = 'tests/data/pdb/1ATN/1ATN_1w.pdb' self.ref = 'tests/data/pdb/1A...
d2322686ba90126c4065d404778c928f9bc0a3e6a9c4b20a9dea63ea1240f25a
Python
725
25
#!/usr/bin/env python # encoding=utf-8 # Copyright 2018 AIShell-Foundation(Authors:Jiayu DU, Xingyu NA, Bengu WU, Hao ZHENG) # 2018 Beijing Shell Shell Tech. Co. Ltd. (Author: Hui BU) # Apache 2.0 from __future__ import print_function import sys import jieba reload(sys) sys.setdefaultencoding('utf-8') if le...
f9372d48c462bee24e69c39dfc4004e12925e950c02591e09dca2cead1b34dae
Python
725
21
from tensorflow.keras import backend as K def recall_m(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) recall = true_positives / (possible_positives + K.epsilon()) return recall def precision_m(y_true, y_pred):...
dc6e708f25f03f4fe4e8adb8efde5a78bdb868c85cb9f6ff45e39abdd9b78c99
Python
726
33
import numpy as np # Kyte Doolittle scale kd_scale = {} kd_scale["ILE"] = 4.5 kd_scale["VAL"] = 4.2 kd_scale["LEU"] = 3.8 kd_scale["PHE"] = 2.8 kd_scale["CYS"] = 2.5 kd_scale["MET"] = 1.9 kd_scale["ALA"] = 1.8 kd_scale["GLY"] = -0.4 kd_scale["THR"] = -0.7 kd_scale["SER"] = -0.8 kd_scale["TRP"] = -0.9 kd_scale["TYR"] =...
72250c0a92b348c13326985b2c768d2b8d1dee15302bcbe57993e80ee0098bc5
Python
727
21
from .basic_params import BasicParams class TestParams(BasicParams): """ This class is a son class of BasicParams. This class includes parameters for testing and parameters inherited from the father class. """ def initialize(self, parser): parser = BasicParams.initialize(self, parser) ...
bae63d1e68ad370f10f2b07b8137ce08e5059f34db95e95e2c307f5954f39c6e
Python
727
30
#!/usr/bin/env python from __future__ import print_function import subprocess import sys from distutils.command.install import install as DistutilsInstall from distutils.core import setup try: import tensorflow except ImportError: print("Please install tensorflow 0.12.0 or later") sys.exit() class MyIn...
f92e31cb529a80cf97c72dd12059bb838f9354d5d5bfde64d9cdea27e4371efb
Python
729
34
from backend.startup import ensure_torch #needs to be called before the first 'import torch' ensure_torch() #needed for upstream from base.backend import * from . import root_detection as processing import PIL.Image import numpy as np def write_as_png(path,x): x = np.asarray(x).astype('float32') x = x*255...
a02c2aa5c206da36035d2cc5a1ea088a670946c19af887c2317d395aabcf58b2
Python
730
28
import logging import numpy as np import torch import math from torch import nn, Tensor import torch.nn.functional as F class regressoionHead(nn.Module): def __init__(self, d_embedding: int): super().__init__() self.layer1 = nn.Linear(d_embedding, 512) self.layer2 = nn.Linear(512, 256) ...
58538a98a305964d5c5b69e357d4d59d43ca1ac54a2ec9b360ab234b7429bd23
Python
731
39
if __name__ == '__main__': # ------------------ # Libraries # ------------------ # Generic libraries import pandas as pd import numpy as np # Own from ls2d.utils import format_workbench from ls2d.utils import format_pipeline from ls2d.utils import format_demographics # ...
a6926d37478dd93e777563e7529cd674e72963deb3bf573441fccd06e44e77c9
Python
731
25
"""Snakemake wrapper for samtools fixmate""" __author__ = "Thibault Dayris" __copyright__ = "Copyright 2019, Dayris Thibault" __email__ = "thibault.dayris@gustaveroussy.fr" __license__ = "MIT" import os.path as op from snakemake.shell import shell from snakemake.utils import makedirs log = snakemake.log_fmt_shell(s...
ebdfc0519732c224012355e2f7854d2d26ded0a68f1749dae588eb6e0fd66414
Python
732
32
"""Snakemake wrapper for verifybamid2.""" __author__ = "Delvin So" __copyright__ = "Copyright 2020, Delvin So" __email__ = "delvin.so@sickkids.ca" __license__ = "MIT" import os from snakemake.shell import shell log = snakemake.log_fmt_shell(stdout=False, stderr=True) out_dir = snakemake.params.get("out_dir") extra =...
0c850cb20615c062e7fab76a9509de40cfe0be6093fb9e4d37704c452d458a5a
Python
735
25
#%% from pymaid_creds import url, name, password, token import pymaid rm = pymaid.CatmaidInstance(url, token, name, password) import numpy as np import pandas as pd import connectome_tools.process_matrix as pm pairs = pm.Promat.get_pairs() # %% # identify brain neurons in pair-list; brain neurons not in pair-list #...
aa1f831b0584167981992a94c25f0e5ccb732525e3ed46649d43a3282ba9b1ef
Python
735
16
# 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...