sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
4d8012658e9e3b7ce2de28dfa943c3e4e72dc6c80974e351441e8326679f13c6 | Python | 2,903 | 96 | from __future__ import print_function
import argparse
import matplotlib.pyplot as plt
import numpy as np
import os
import scipy
from windseer.plotting import plot_mpl_scatter_density, density_scatter
parser = argparse.ArgumentParser(description='Script to plot measurement campaigns benchmark results')
parser.add_ar... |
109a280a7db3bceb1d98243e3a7c4dfc54c519bcd88e3eaa60480d5e8294c6d7 | Python | 2,906 | 65 | #! /usr/bin/env python
from treeshrink.decompose_lib import decompose
from treeshrink.alignment import Alignment
from treeswift import *
import argparse
from os.path import basename, dirname, splitext,realpath,join,normpath,isdir,isfile,exists
from os import mkdir,getcwd,rmdir,listdir
parser = argparse.ArgumentParser... |
2a1317ca1bbefc70004ff71da6ae522035fbe93e4d31ad9165a109ee517a4d1a | Python | 2,908 | 82 | """Zero pad and crop data tensor."""
import math
from collections.abc import Sequence
from typing import Literal
import torch
from mrpro.utils.reshape import normalize_index, unsqueeze_left
def pad_or_crop(
data: torch.Tensor,
new_shape: Sequence[int] | torch.Size,
dim: Sequence[int] | None = None,
... |
c97d4f2891c0a016b0a20fef65c44887e00433d69946f7ae7ae83108520a7198 | Python | 2,908 | 82 | import vuba
import cv2
import numpy as np
from tensorflow import keras
import tensorflow as tf
import matplotlib.pyplot as plt
from tqdm import tqdm
from statsmodels.nonparametric.smoothers_lowess import lowess
import wget
from dev_resnet import DevResNet
# Parameters -------------------------------
# Event you have ... |
59a760fad6c12a0e4f683f6ef30410f6f9e69c2a073898b765f31e8462e1e293 | Python | 2,909 | 107 | """
Period benchmarks with non-tslibs dependencies. See
benchmarks.tslibs.period for benchmarks that rely only on tslibs.
"""
from pandas import (
DataFrame,
Period,
PeriodIndex,
Series,
date_range,
period_range,
)
from pandas.tseries.frequencies import to_offset
class PeriodIndexConstructo... |
d8cda8c8896dcd11a28f0b286da3d2430c9c6dadfca2e31b7e63be9a619136db | Python | 2,909 | 91 | import threading
import argparse
import logging
import collections
from itertools import cycle, islice
import numpy as np
import pandas as pd
logger = logging.getLogger(__name__)
class DataLoader(object):
""" Load and create a DataLoader object with user provided data"""
def __init__(self, args):
s... |
1104be629edecf7cbcfd297d3acf7855604bc9cfe2a47aaceb8579c07d92826c | Python | 2,911 | 102 | import numpy as np
def get_grid_mat(epi_params, os_factor, keep_oversampling):
"""
Generate a matrix for gridding reconstruction.
Parameters:
-----------
epi_params : (dict)
Dictionary containing EPI sequence parameters.
os_factor : (float)
Oversampling factor f... |
267b2d39fcc31a5dfb027f60868b441ad74b21269781ef39d5231135188d90ad | Python | 2,911 | 75 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
9d2ce56d72b4be97055241da4b7d34f361a666daabd810eff56d0010bb5352bc | Python | 2,911 | 93 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.tests.copy_view.util import get_array
def test_assigning_to_same_variable_removes_references():
df = pd.DataFrame({"a": [1, 2, 3]})
df = df.reset_index()
assert df._mgr._has_no_reference(1)
arr = get_array(d... |
aa671b761992a74a1d116a1016de4ac3421f8e7fcb5ad04b1d16425f2bbdd5ec | Python | 2,911 | 97 | # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# 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... |
5b74173543f91966126127710a5a2d7418b4eef2d51d15e92d2a9f34bdccc918 | Python | 2,912 | 78 | #!/usr/bin/env python
"""
Readers for STAR (spliced aligner) format reading
"""
class STARJunctionRecord:
"""
column 1: chromosome
column 2: first base of the intron (1-based) --> store as 0-based
column 3: last base of the intron (1-based)
column 4: strand (0: undefined, 1: +, 2: -)
column 5:... |
95433d093f7320cb079687da1feb46abe07087c07d2c027f3d00b086b30573e4 | Python | 2,913 | 66 | import torch
import numpy as np
####################### LightningModule #######################
import lightning as L
import torch.nn.functional as F
from graphite.nn.models.equivariant_transformer import Encoder, Processor, Decoder, EquivariantTransformer
class LitEquivariantNoiseNet(L.LightningModule):
def __i... |
36f7c22d4236e1ff50e85ea0d0bd85c61b0dae4441795c40c4084d147f610868 | Python | 2,914 | 85 | def _get_type(a):
if 'float' in str(a.dtype):
return 'float'
if 'int' in str(a.dtype):
return 'int'
return None
class vtkFields:
def __init__(self, data_type, size, scalars = None, vectors = None, normals = None,
tensors = None, fields = None):
if scalars is No... |
adc9ea4511349a2151e12ded61dc78cdeb679573b1e8034d94758161315c289b | Python | 2,914 | 97 | """
masked_accumulations.py is for accumulation algorithms using a mask-based approach
for missing values.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
if TYPE_CHECKING:
from collections.abc import Callable
from pandas._typing import npt
def _cum_func(
fu... |
bc329fbb89ef4e8c181a55f7c887ed50e8efaac11f0c6dd965d10c6ccba7bc53 | Python | 2,915 | 96 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize("categories", [["b", "a", "c"], ["a", "b", "c", "d"]])
def test_factorize(categories, ordered):
cat = pd.Categorical(
["b", "b", "a", "c", None], categories=categories, ordered=ordered
)
cod... |
d987643e156486a664c6d822e0b3eb282a10c4509ae3f9f5c5aee4db51e84d1c | Python | 2,915 | 74 | import torch
import numpy as np
####################### Dataset #######################
from torch_geometric.data import Data, Dataset
from sklearn.preprocessing import LabelEncoder
from graphite.nn import periodic_radius_graph
class PeriodicStructureDataset(Dataset):
def __init__(self, atoms_list, large_cutoff,... |
41d8b0a58b734e6bc8535119a7d326891f95a4058a2e5006758909dce94873f2 | Python | 2,917 | 81 | from tests import TestCaseNeSVoR
from nesvor.transform import RigidTransform, mat_update_resolution
from nesvor.slice_acquisition import slice_acquisition
from nesvor.utils import get_PSF
from nesvor.svort.models import SRR
from tests.phantom3d import phantom3d
import torch
import numpy as np
class TestSliceAcq(TestC... |
a05a27624c26e298d19749cfc33dd759fc0dd487cfd602034fd53058803b388d | Python | 2,920 | 87 | __all__ = ["PeptideRTPredictor"]
import os
from logging import Logger
from typing import Any, List, Mapping, Optional, Union
import numpy as np
import pandas as pd
import torch
from ....util.progress import ProgressFactoryProto
from ...common.prediction import PredictorBase
from ..common.data import PeptideData, Pep... |
f3c778d2508f3f14b24d80d7925472094275515b2d5c83c015b607034311dcd6 | Python | 2,925 | 102 | import torch.nn as nn
from roost.cgcnn.model import DescriptorNetwork
from roost.core import BaseModelClass
from roost.segments import MeanPooling
class CrystalGraphPreNet(BaseModelClass):
"""
Create a crystal graph convolutional neural network for predicting total
material properties.
This model is... |
207d7b9a1f12e60d8d01d658883309c9348c2cbb57ef72e4c77e0a0a2e5b60ae | Python | 2,927 | 88 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GCNConv, global_max_pool as gmp
# GCN based model
class GCNNet(torch.nn.Module):
def __init__(self, n_output=1, n_filters=32, embed_dim=128,num_features_xd=78, num_features_xt=25, output_dim=128, dropout=0.5):
... |
17de25f54a631fe718ef97477a6bacf80b8de974b5c91a541dddad2c5f6cbbf5 | Python | 2,928 | 72 | import os, sys
import vcf
import glob
from collections import defaultdict, Counter
def main(dirs, vcf_filename='phased.partial.vcf', output='IsoSeq_IsoPhase.vcf'):
no_snp_found_filename = vcf_filename[:vcf_filename.rfind('.')] + '.NO_SNPS_FOUND'
snps_by_chrom = defaultdict(lambda: [])
samp_ft = vcf.model.... |
cb350f61d7f9268db38eaa34373bbee4d29c57c94b3b34e6d43594d2402cf904 | Python | 2,928 | 78 | # Copyright 2026 Xanadu Quantum Technologies Inc.
# 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 agre... |
7362109ddb7bd5295655d1ec7a911d123d8ebf5a207eff22e12387099b03cc6c | Python | 2,930 | 75 | import os, sys, torch
import numpy as np
def read_dictionary(filename):
d = {}
with open(filename, 'r+') as f:
for line in f:
line = line.strip().split('\t')
d[line[1]] = int(line[0])
return d
def read_triplets(filename):
with open(filename, 'r+') as f:
for line... |
f7c24af9e20015f839ac69cb6681fe6cb042dd821f56b9627e07a52159994644 | Python | 2,930 | 95 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class DropDuplicates:
def test_drop_duplicates_metadata(self, idx):
# GH#10115
result = idx.drop_duplicates()
tm.assert_index_equal(idx, result)
assert idx.freq == result.freq
idx_dup = idx.... |
b829322dafbe44876b1338929ddcc76464295b596f52709c27fa5eeade94de73 | Python | 2,931 | 73 | import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestReindex:
def test_reindex_list_non_unique(self):
# GH#11586
msg = "cannot reindex on an axis with duplicate labels"
ci = pd.CategoricalIndex(["a", "b", "c", "a"])
with pytest.raises(ValueEr... |
3445ab371f60ce82c744f64756bb0c60d7ba1a74ddc3094bef7d657224d61450 | Python | 2,932 | 75 | #!/usr/bin/env python3
"""Rename chosen residues in a PDB so somo.residue no longer codes them.
The point is a GROUND TRUTH test. The atoms are untouched -- only the residue name in
columns 18-20 changes -- so whatever the perceiver derives for the renamed residue can be
compared directly against the coded entry for t... |
4988c9fdf9fce2e80f7d5eb7ea695e7ffc583c7841b953a477637ed636735b3a | Python | 2,934 | 84 | """Rearrange Operator."""
import re
import torch
from einops import rearrange
from mrpro.operators.LinearOperator import LinearOperator
class RearrangeOp(LinearOperator):
"""A Linear Operator that implements rearranging of axes.
Wraps the `einops.rearrange` function to rearrange the axes of a tensor.
... |
8d197f5a6fa107100392ec7ed35a60447af9fcc098c53fa60b6603372b280823 | Python | 2,934 | 86 | """
.. _decode_discrete:
============================
Discrete functional decoding
============================
Perform meta-analytic functional decoding on regions of interest.
We can use the methods in ``nimare.decode.discrete`` to apply functional
characterization analysis to regions of interest or subsets of th... |
1c8e3af964a3934f8951cc8c3012aa9ab53a80a2e10a298dea644ae5431da060 | Python | 2,935 | 89 | #!/usr/bin/python
# Script to convert HMMER/Infernal/Easel test suite output into JUnit XML for Teamcity integration
from lxml import etree
import sys
if len(sys.argv) != 3:
print"Usage: parse_test_results.py <infile_name> <outfile_name>"
quit()
infile_name = sys.argv[1]
outfile_name = sys.argv[2]
infile = open... |
204e3c5a8b7a1a0f5081d630ef51e1de7eb817b5e2598af036c82c0e239102e2 | Python | 2,935 | 95 | from Environment_ui import *
from math import ceil
ROOT_DIR = os.path.dirname(__file__)
PARAMETER_DIR = 'pages/Registration/parameters'
def generate_freesia_input(input_path: str, shape, channel, pixel_size, group_size, **kwargs):
doc = {
"group_size": group_size,
"image_path": os.path.split(input... |
549f91285f5b2e0a75566b5561bc8e16072856f97e5a1ac47d9e023ac37d9172 | Python | 2,938 | 89 | #!/usr/bin/python
# Script to convert HMMER/Infernal/Easel test suite output into JUnit XML for Teamcity integration
from lxml import etree
import sys
if len(sys.argv) != 3:
print"Usage: parse_test_results.py <infile> <outfile>"
quit()
infile_name = sys.argv[1]
outfile_name = sys.argv[2]
infile = open(infile_na... |
b495699d2ecf0b2140917340f2e787ec464073f79e3245a96e0f4f6f48ce4a5a | Python | 2,938 | 98 | # MOFTransformer version 2.0.0
import functools
from typing import Optional
from torch.utils.data import DataLoader
from pytorch_lightning import LightningDataModule
from moftransformer.datamodules.dataset import Dataset
class Datamodule(LightningDataModule):
def __init__(self, _config):
sup... |
b713740fa89ef03ad4f48d7cd8e0d6644b17907599b70188827f750c515f9655 | Python | 2,938 | 71 | # Copyright 2018-2025 Xanadu Quantum Technologies Inc.
# 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... |
bc60987cbff58c9b69664cbd713e32d555ed905ef07acec3cad83a38ddeca402 | Python | 2,940 | 71 | import numpy as np
from itertools import product
from quasinet import qnet
class MaskChecker:
"""For sanity-checking the Quasinet model, randomly mask entries in the original data frame and let the qnet fill in predictions. If the qnet model is good, we expect a minimal amount of difference between the original d... |
55068610270f24dd4aaa24201d4dd6de61aa1660cfa93cf0f59be321ce7437fd | Python | 2,941 | 87 | __author__ = 'etseng@pacb.com'
from Bio.Seq import Seq
from Bio.SeqIO import SeqRecord
class LazyFastqReader:
"""
Like LazyFastaReader except works with fastq!
"""
def __init__(self, fastq_filename, seqid_extraction=lambda x: x):
self.f = open(fastq_filename)
self.d = {}
while... |
d2e2b0fc2a146cb2e1dc59f8516578bdbe971db4d3689b0c63a2556149370b03 | Python | 2,941 | 81 | import pickle
import pandas as pd
import torch
from tqdm.auto import tqdm
import numpy as np
from data_utils import train_test_split_samples
from common import device
import mlflow
def accuracy(pred, true):
return ((pred > 0.5) == true).float().mean()
def predict_by_group(X, samples, model, slen=8, repetitions=5)... |
e91936f8d4707566232328ecf2e74cfd37cad3de6d6a2ede9d94db0ce26a46c5 | Python | 2,942 | 69 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# 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 ... |
f30edb944bc05c23dc4e56100c92d34d5ef1b83d093b0a894310c6c60549d4bc | Python | 2,944 | 79 | import glob
import argparse
import numpy as np
from base import surfaces
try:
from vtk import *
gotVTK = True
except ImportError:
print('could not import VTK functions')
gotVTK = False
def main():
if not gotVTK:
raise Exception('Cannot run function without VTK')
parser = argparse.Arg... |
0a2478029916fd368840bf14b90fba5925a6e7c087813cde664652c5d19bd38c | Python | 2,947 | 59 | import os.path
import argparse
from base import loggingUtils
import base.surfaces as surfaces
from base.kernelFunctions import *
from base import surfaceMatching
#import secondOrderMatching as match
def compute(tmpl, targetDir, outputDir, display=True, Atrophy=False, rescale=False):
if Atrophy:
import surf... |
6f161977fb678793d71b116fd789dfe7d39e14e06ab3f71a356d8b58b829d820 | Python | 2,948 | 91 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 9 18:08:13 2022
@author: jinani
"""
# Import Required Libraries
from tensorflow import keras
from tensorflow.keras.layers import Conv2D
from SupportFiles.k_layers import gaussian2dMapLayer, PowerLowNonLinearity
from tensorflow.keras.layers import ... |
8cc6a446099f4eb3d7dcecbc16c561c15ca5abbb6bf59ba85153302880f21c96 | Python | 2,948 | 80 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 18 16:39:53 2019
@author: Wladek
"""
import scipy.stats as st
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from figure_properties import *
def set_axis(ax, x, y, letter=None):
ax.text(x,
y,
... |
cba2c7822e960f0e904e597bf93379436d67958e81754f2d44668fcdbd5f0b07 | Python | 2,948 | 93 | """Smooth-bbox command for the lightning-pose CLI."""
from __future__ import annotations
import argparse
import logging
from pathlib import Path
from typing import Any
logger = logging.getLogger(__name__)
def register_parser(subparsers: Any) -> argparse.ArgumentParser:
"""Register the smooth_bbox command parse... |
313a3b3e04e505820a11bf84eb1b98905e13bc107d627a64e6da07b196f31fbf | Python | 2,949 | 61 | import torch
import torch.nn as nn
from torch.nn import functional as F
class EfficientAttention(nn.Module):
def __init__(self, in_channels, key_channels, value_channels, head_count=1):
super().__init__()
self.in_channels = in_channels
self.key_channels = key_channels
self.... |
d434ade905150ab0c376533d9b1015a79c9ce9d0af2aa3a92a4bc958476667b7 | Python | 2,949 | 112 | from __future__ import division
from pymatch import *
import sys
import numpy as np
def drop_static_cols(df, yvar, cols=None):
if not cols:
cols = list(df.columns)
# will be static for both groups
cols.pop(cols.index(yvar))
for col in df[cols]:
n_unique = len(np.unique(df[col]))
... |
6ff36e28f38d2582ab5c77e6bab32535b9b46bc85e68d054feabb65fe63b6304 | Python | 2,950 | 85 | import sys
import pandas as pd
# Adapted for use with DO from:
# https://github.com/obophenotype/human-phenotype-ontology/blob/master/src/scripts/compute_british_synonyms.py
labels = sys.argv[1]
synonyms = sys.argv[2]
dictionary = sys.argv[3]
template = sys.argv[4]
df_labels = pd.read_csv(labels)
df_labels.columns =... |
2803fcd731ce4b9c6b5dee92aa1a3a7c4a33ce162775b080e688a180cae4e0af | Python | 2,951 | 69 | import os
from data.base_dataset import BaseDataset, get_params, get_transform
from data.image_folder import make_dataset
from PIL import Image
import random
import torchvision.transforms.functional as TF
class AlignedDataset(BaseDataset):
"""A dataset class for paired image dataset.
It assumes that the direc... |
2ac9bfa14fefa2554109b3d34b3daacebec0794196f1925a39fb5db34317cc13 | Python | 2,951 | 111 | """
Process fMRIPrep outputs to timeseries based on denoising strategy.
"""
import argparse
from pathlib import Path
from fmriprep_denoise.dataset.fmriprep import (
get_prepro_strategy,
fetch_fmriprep_derivative,
)
from fmriprep_denoise.dataset.timeseries import (
generate_timeseries_per_dimension,
)
def... |
3f3f18dbd55b9eab2eb635f53bb72c2903f4f6a4169ad01abe9fc268096849e8 | Python | 2,951 | 141 | from pandas._libs import (
NaT,
Period,
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
ArrowDtype,
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
PeriodDtype,
)
from pandas.core.dtypes.missing import (
isna,
isnull,
... |
c1b64c488cd9e743ea1ba6919015a5477fde4a0514f92f95178d59bfe04af556 | Python | 2,951 | 70 | import numpy as np
import pandas as pd
import dask.dataframe as dd
from ._helper_functions import is_int
from ..plotfunctions._decorators import dask_to_pandas
from model_data_base.plotfunctions._figure_array_converter import PixelObject
#@dask_to_pandas
def calculate_vdensity_array_pd(v, bin_size = 0.05, ymin = -100... |
b1a7e359610a9ca08da60505dc9eba04dc12b73818bf7f4a3dc41442b3400ef9 | Python | 2,953 | 94 | import numpy as np
from numpy import genfromtxt
def coexpression_net(study_id, power):
exp_mat = genfromtxt('../data/raw_data/expression_data/expression_mat_' + study_id + '.csv', delimiter=',')
exp_mat = exp_mat[1:, 1:]
# Calculate co-exp net
cor_net = np.corrcoef(exp_mat)
# Set nan to be zero
... |
39be64781c18326435e7121f83ecbd6318b55559d8f73ece2a90ddfa885b2187 | Python | 2,957 | 80 | import array
from unittest import TestCase
import pysam
import dynast.preprocessing.consensus as consensus
from .. import mixins
class TestConsensus(mixins.TestMixin, TestCase):
def test_call_consensus_from_reads(self):
header = pysam.AlignmentHeader.from_dict({
'HD': {
'VN... |
264eb9a478f4f0c7c87f09aad9dc2b1736fd5190a7171c857c7095324dc881a7 | Python | 2,959 | 101 | #
# This file takes in a list of pdbs and retrieves all residues from them.
# It then outputs a list of all residues into an hdf5 file in the format
# (<aa>, <pdb>, <model>, <chain>, <insertion>, <seq id>, <hetero>)
#
from argparse import ArgumentParser
import logging
import sys
import h5py
import numpy as np
from ... |
40729a378e6e18cdbfd0d125fcc6680ca1798d33a50cc0665599167a92207429 | Python | 2,959 | 76 | #!/usr/bin/env python3
# MIT License
#
# Copyright 2026 Broad Institute
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to u... |
9c6eef20beda8090cc4136bd3d475f16d75bcceb28b261e071e2e4ab26e85f7e | Python | 2,959 | 78 | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
# Borrowed from https://github.com/rusty1s/pytorch_geometric/blob/master/torch_geometric/transforms/random_rotate.py
# with changes to keep t... |
1be1c1456dabffc478a99b45c228c1b6f4a773748d92292b1f9072e15912cfb1 | Python | 2,960 | 91 | """
Base test suite for extension arrays.
These tests are intended for third-party libraries to subclass to validate
that their extension arrays and dtypes satisfy the interface. Moving or
renaming the tests should not be done lightly.
Libraries are expected to implement a few pytest fixtures to provide data
for the ... |
6490ef3e2bc8e2c10b43ecd6f4ef02d97ac1a2dc9014fae29f14c044bfcad902 | Python | 2,960 | 78 | from typing import Mapping, Sequence, Union
import numpy as np
from ..chem.gpep.sort import GlycanComparer
from ..chem.gpep.glycans import GlycanNode, MonosaccharideCollection
from ..chem.gpep.gpmass import GlycoPeptideMassCalculator, GlycoPeptideMzAnnotation
from ..chem.pep.mods import ModifiedSequence
from ..specli... |
b558183c129c49196ffc4a3b296229073b327d9205de2c6fd58b0027ff534d6f | Python | 2,960 | 83 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# 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... |
04a9c56b72db68aba3bc3d1bdef6443dc512ab8261ab3cb861d9f99afe804d68 | Python | 2,962 | 74 | #! /usr/bin/env python
##############################################################################
## DendroPy Phylogenetic Computing Library.
##
## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder.
## All rights reserved.
##
## See "LICENSE.rst" for terms and conditions of usage.
##
## If you use this wo... |
7f51908c90208f1956171685b7376efbf2910932d4f9fc6c2e66be4386268ecb | Python | 2,963 | 86 | from src.weights import get_feature_weights
from src.step_factory import StepFactory
from src.test_config import get_step_config
import pandas as pd
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn import set_config
import numpy as np
import pytest
def _fit_test_pipe... |
855d1c97daa5f1081a9570ec35482de2b4e90c0449f1924c1e21a87a3aed9858 | Python | 2,964 | 76 | """Tests for `multimodal_ad.data.splits`."""
import polars as pl
import pytest
from multimodal_ad.data.splits import (
SubjectLeakageError,
assert_no_subject_leakage,
stratified_subject_folds,
subject_train_test_split,
)
def _multi_session_df(n_subjects: int = 40, sessions_per_subject: int = 3) -> p... |
5d2010ced9b8216301d8c2c155f52f579ad34ab3692dfb698934677062678d61 | Python | 2,965 | 84 | # Copyright 2024 Xanadu Quantum Technologies Inc.
# 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 agre... |
cd07da30efe6c8eb00ffb084361c4ffee4ceefb5bb86b83dc7c0001afab811f8 | Python | 2,965 | 109 | import datetime as dt
import json
import os
import sys
from contextlib import contextmanager
from typing import Any, Dict
from . import __version__
class Step:
"""Class that represents a processing step.
"""
def __init__(self, skipped: bool = False, **kwargs):
self.start_time = None
self... |
7b1ed2e4e36a47e304640ce8c0a8cdf2f415d80890bdc9bd2c4303b4fb56f6cd | Python | 2,968 | 109 | # -*- coding: utf-8 -*-
"""
Created on Mon May 22 13:29:45 2023
@author: Jonas Hartmann @ Mayor lab @ UCL CDB
@descript: Force functions F=f(dist, ...) for use in specifying
simple_cell_sim models.
"""
# Imports
import numpy as np
def f_Hooke(dist, dist0, k):
"""Hooke's law spring force functi... |
a44fb14b25a4645afe0c9cc151a468bf122fa964cc44b34a2ccde58fbb8f60e7 | Python | 2,968 | 105 | """
Create manhattan-plot-like visualizations of the discriminator predictions.
Authors: Sara Mathieson, Iain Mathieson
Date: 12/14/22
"""
import math
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
import sys
############################################################################... |
bd485f393b916fd0b4705db12fb50312191febe02a289f589d705175ac9b5c4a | Python | 2,969 | 90 | # Copyright 2018-2024 Xanadu Quantum Technologies Inc.
# 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... |
dd18a1bbe786ebc36d9179b4cc7037934bade154b58e387e0faf83862b122873 | Python | 2,969 | 92 | #! /usr/bin/env python
##############################################################################
## DendroPy Phylogenetic Computing Library.
##
## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder.
## All rights reserved.
##
## See "LICENSE.rst" for terms and conditions of usage.
##
## If you use this wo... |
8d77884b97c6225526ac282088e727ab8c70d3fc0e9014fe72d5eeccc0bdd09d | Python | 2,970 | 103 | import os
import pickle
import numpy as np
from tqdm import tqdm
import seaborn as sns
import scipy.io as scio
import pandas as pd
import random
import matplotlib.pyplot as plt
class TrainingProcess():
def __init__(self, config, dataStreaming) -> None:
self.personName = config.personName
... |
5ca254dd094c92809aa9ed502a8772e705ece7e7807e73c3038e71a89ece988c | Python | 2,971 | 112 | import os
import argparse
from image_registration.image_processing import run
# calls the run function and enables to put different arguments to process the images.
def dir_path(string):
if os.path.isdir(string):
return string
else:
raise argparse.ArgumentTypeError(f'"{string}" is not a valid path')
parse... |
871eb82ce332f9f0f83b57aa103fdeae274a119b3d0e939e543d827bbf2b2a62 | Python | 2,971 | 85 | from inference import *
from models import *
import sys
import os
import shutil
import itertools
if __name__ == "__main__":
gauss = sys.argv[1] == "True"
add_suffix = sys.argv[2]
base_path = os.path.abspath(__file__ + "/..")
# Load the network
model_weight_list = [
"/data/model-weig... |
b885053f7ee92c4f79c1d6d21364f58f0199488f37e5bd1f3a3176e3bbd1fbfc | Python | 2,972 | 85 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# ----------------------------------------------------------------------------------------------... |
23f88d49895503214a256b5bc2852a7a397b6d7f2bc5afe732500154c074e68d | Python | 2,973 | 88 | import os
from typing import Any, List, Union, cast
import torch
from ..ms2.training import GlycoPeptideMS2Trainer
from ....util.collections.dict import chain_item_typed
from ...common.training import TrainerBase
from ...util.weightloss import (
AutomaticWeightedLoss,
DynamicWeightAverageLoss,
ScaledDetac... |
835db4757ee88c63e7c8f8e3026f7ecd4f1de69b1f3235ed95b4d065f233ceda | Python | 2,974 | 79 | import argparse
from pathlib import Path
from fastmri_prostate.reconstruction.t2.prostate_t2_recon import t2_reconstruction
from fastmri_prostate.reconstruction.dwi.prostate_dwi_recon import dwi_reconstruction
from fastmri_prostate.data.mri_data import load_file_T2, load_file_dwi, save_recon
def main(args):
Path(... |
587e01282c742733982fa323a71d66c201ce92f7d2ca0d3acd9220084d70e34a | Python | 2,975 | 83 | import sys, re, os
from numpy import inf
R = re.compile('(\[[0-9]+\] "?)?([^"$]*)"?')
def deRify(s):
return R.match(s).group(2)
# Thanks to Daniel Sparks on StackOverflow for this one (post available at
# http://stackoverflow.com/questions/5084743/how-to-print-pretty-string-output-in-python)
def getPrintTable(r... |
7cd156f12a2113f0c949917ea3add31dc60419c104a7d89a7692ebd797e321a1 | Python | 2,977 | 93 | import numpy as np, matplotlib.pyplot as plt
from scipy.signal import savgol_coeffs
import pumpprobe as pp, wormdatamodel as wormdm
ds_list = "/projects/LEIFER/francesco/funatlas_list.txt"
folders = np.loadtxt(ds_list, dtype='str', delimiter="\n")
n_ds = len(folders)
signal_kwargs = {"remove_spikes": True, "smooth":... |
ec07853f0c372431a6960c31036716b8b25af93c26544a02ba08d28dfa4fca56 | Python | 2,978 | 93 | import numpy as np
from pandas import (
DataFrame,
IndexSlice,
)
class Render:
params = [[12, 24, 36], [12, 120]]
param_names = ["cols", "rows"]
def setup(self, cols, rows):
self.df = DataFrame(
np.random.randn(rows, cols),
columns=[f"float_{i + 1}" for i in range... |
90aa9e0398adec8d7d27ca91ee87c165c1ebbd874f7abd92b5da8b7544c0ce9f | Python | 2,980 | 110 | import numpy as np
import pandas as pd
import time
import datetime
from .esw_star import esw_star
from ..utils.compute_pvalues import compute_pvalues
from ..summarydata import SummaryData
def _ep(mean: pd.DataFrame, verbose: bool=False):
"""Computes Expression Proportion ES weights for each gene / cell-type
P... |
c4a4d65c0581240a95c57bee93370a53972ecd325876dedf95837c509a88ef87 | Python | 2,980 | 74 | import numpy as np
import pandas as pd
import matplotlib.pylab as plt
import matplotlib.gridspec as gridspec
pi = np.pi
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
#################################################################
def get_rmap(z, fstim, w):
''' For a given prc it runs the ph... |
a590af20a3536830567a8ea429e1a7286ea9e16e35066bfffb8ed245354ac579 | Python | 2,981 | 81 | #!/usr/bin/env python
__author__ = 'etseng@pacb.com'
"""
Used for getting per-barcode Fl count information after IsoSeq cluster is run and HQ is mapped and collapsed.
Required Input:
isoseq_classify.primer_info.csv -- CSV output from classify
*.collapsed.group.txt, *.collapsed.rep.fq --- to get the PB IDs and group ... |
69e44afddc188acb828c45d7560d73cc8713fd5036092221926e16db801da021 | Python | 2,982 | 112 | # JN 2015-01-11
# refactoring
"""
given a cluster tree, define clusters and return their index
"""
from __future__ import division, print_function, absolute_import
import logging
import numpy as np
from .. import options
logger = logging.getLogger(__name__)
def find_relevant_tree_points(tree, min_spikes):
"""
... |
11bd418a0c0a5220938c5c635a72a8659fcb16826d61d0e53ef3159cdf6f7778 | Python | 2,983 | 85 | import torch
import torch.nn as nn
class classifier(nn.Module):
'''
Deep Neural Network with 3 hidden layers,
each layer has batch normalization function locate before the activation function (ELU),
the followed by the dropout function to reduce overfiting the reference and overcome batch effect
''... |
51ba08c63b3d3d634ce5f4c1395666f8ea34b9c6bd246fc14f8c3edaa9123615 | Python | 2,983 | 75 | """The optional `capability_manifest` config key travels with checkpoints.
Whatever the config declares under `capability_manifest` is saved into
full-state checkpoints and restored on load (PPO and SAC). rl_games never
interprets it. On restore, a manifest declared in the current config wins
over the checkpoint's.
R... |
55fc80910937ac499e5cdece7b1757262773d610333a2162c999064b64aaa6d1 | Python | 2,985 | 68 | import json
import os
import numpy as np
import pandas as pd
import wget
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
class AAIndexTokenizer(object):
"""Convert between strings and their AAIndex representations."""
def __init__(self, dpath: str, n_comp: int = 20):
... |
5ea01bd22c837938a621578bf10862671676d3b3dbb84c61c8774960f2dec360 | Python | 2,985 | 76 | import numpy as np
import csv
from string import Template
from stl import mesh
def read_grd(infile):
with open(infile, 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=' ')
type_str = reader.next()
nx, ny = [int(v) for v in reader.next()]
min_x, max_x = [float(v) for v in r... |
afcfb633fd6e757c3caf761dbaa97314d6606e194ba5a2d7eecfcffdf97d8950 | Python | 2,985 | 97 | """Tests of unit conversion."""
import numpy as np
import torch
from mrpro.utils import RandomGenerator
from mrpro.utils.unit_conversion import (
deg_to_rad,
lamor_frequency_to_magnetic_field,
m_to_micrometer,
m_to_mm,
magnetic_field_to_lamor_frequency,
micrometer_to_m,
mm_to_m,
ms_to_s... |
ec8e99681dc2a876a54913042d158b3fd2ba3c3420501d2a6e46f3549ca61b84 | Python | 2,985 | 75 | """
This file contains the code for creating a dense block (as used in DenseNets).
Code credits to titu1994: `https://github.com/titu1994/DenseNet`
"""
from keras.layers.core import Dropout, Activation
from keras.layers.convolutional import Conv2D
from keras.layers import Input
from keras.layers.merge import... |
ac34865254bc9cad67d8220bcc723d48dbc01b593287da98459b49dcada49173 | Python | 2,986 | 84 | __all__ = ["GlycoPeptideSpectrumFilter"]
from typing import Generic, Mapping, Optional, Sequence, TypeVar, Union
import numpy as np
from ..pep.filter import PeptideSpectrumFilter
from .spec import GlycoPeptideMS2SpectrumProto
MS2SpectrumType = TypeVar("MS2SpectrumType", bound=GlycoPeptideMS2SpectrumProto)
class G... |
b14d49dfe16415c4fa6f6ebe24e2cb83949e88f1787a6aef768c820ddf4488a6 | Python | 2,986 | 131 | #
# File to split a protein list into training, validation, and testing data
#
from argparse import ArgumentParser
import sys
import Bio.PDB as pdb
import Bio.PDB.mmtf as mmtf
import h5py
import numpy as np
from protein_holography.utils.posterity import get_metadata, record_metadata
parser = ArgumentParser()
pars... |
88e6e7f277f2b628cc35b65383dea8e644fcb04d71c66b132b642d356e50cad5 | Python | 2,988 | 95 | # MIT License
#
# Copyright (c) 2020 Gabriel Nogueira (Talendar)
# Copyright (c) 2023 Martin Kubovcik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without ... |
a94523432fef9ded0e5936e6cf48a59e792861307c3d3df65ecf1f2089156fee | Python | 2,988 | 93 | import os
import sys
import numpy as np
import pandas as pd
import scanpy as sc
import scipy
def convert_h5ad_to_df(adata):
if type(adata.X) == np.ndarray:
X = adata.X
elif type(adata.X) == np.matrix:
X = np.array(adata.X)
elif (
type(adata.X) == scipy.sparse.csr.csr_matrix
... |
e335975011c6e255608a90814b9a8e50163be932348ab140cd1914cff8ef04ae | Python | 2,988 | 63 |
from ..utils import get_phenolist
from ..file_utils import write_json, get_filepath, get_pheno_filepath, write_heterogenous_variantfile
import json
from pathlib import Path
from typing import Iterator,Dict,Any,List
def get_phenotypes_including_top_variants() -> Iterator[Dict[str,Any]]:
for pheno in get_phenolist... |
f750a541fcbe3334f6a6201ff1ca34131edc880e4bb5211e285df5f5300ebc9d | Python | 2,990 | 101 | import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
try:
from PIL import ImageEnhance
from PIL import Image as pil_image
except ImportError:
pil_image = None
ImageEnhance = None
def mask_to_onehot(mask, palette):
"""
Converts a segmentation mask (H, W, C) to (... |
39af3a2d4494a88c3ebeaba80d581404e5ee9e7e6ae99ed8bc4e65d86064ffe4 | Python | 2,991 | 118 | import os
from typing import Any, Mapping, Optional, Type, TypeVar, Union, cast, overload
from .collections.dict import chain_get, chain_get_typed, chain_item, chain_item_typed
from .io.json import load_json
from .io.yaml import load_yaml
T = TypeVar("T")
class Configurable:
def __init__(self, configs: Union[... |
e6fb9fe59241b44b58036b2ef38c85f4bb60834c1ce623206a3644d5e584e143 | Python | 2,991 | 80 | """Pileup alignment files using NumPy-backed PileupV2 routines.
This command mirrors :mod:`MACS3.Commands.pileup_cmd` but routes
through the PileupV2 implementation.
"""
import os
from MACS3.Utilities.OptValidator import opt_validate_pileup
from MACS3.Signal import PileupV2
# Reuse the existing loaders so option ha... |
1d817e02a14dc04f24ba3e633faf50b4c65eb2a32bd61d11d90e8e8606bfac0e | Python | 2,992 | 84 | """
This advanced example takes a complex JSON file, the result from the Wikidata
API for the movie Blade Runner, and shows you how to transform this to many
different formats.
You can get the original data using this API call:
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q184843&format=json
"""
from d... |
76c30968a4df9b49868c04bda8bc3e98a9943545e9d1c8736d117a4d1ce1743a | Python | 2,992 | 75 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
9a9da1e24b1227e63875a02308faf84afb593ab18cddb111be3d27369c45e04b | Python | 2,992 | 75 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
bd6472b375636c4f2e560d7659286b500ce5b03cc2a8c8d667743566f3d73e59 | Python | 2,992 | 75 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
f1f1cb29cd7822005d0b58e19a1b444119f4f1f88afd20d29dc0c88934a24d97 | Python | 2,992 | 75 | #Run and save results of sweeps over eps, eta for 5 fields.
#Date written and executed: 2022-04-26
#Runs multiple replicates at each set of parameter values
# ran test run with two replicates at one set of parameter values
import numpy as np
from placerg.funcs import *
from placerg.funcsrg import *
from placerg.object... |
f55c76ecda766cc27d94e27d47410a7ba0058d216d3f4990d883678c202aa297 | Python | 2,992 | 102 | # Copyright 2018-2023 Xanadu Quantum Technologies Inc.
# 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... |
2f7f7d7d186ffce43d32ad47b882f626fdde75dc8c8b2e0a8ca187cc13ca3303 | Python | 2,993 | 74 | """2.0 dead-registry cleanup: removed registrations stay removed, shipped
configs only name registered builders, and the recurrent example configs
really build recurrent networks."""
import glob
import os
import pytest
import torch
import yaml
from rl_games.algos_torch import models
from rl_games.algos_torch.model_b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.