sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
a0b44d175e05d8e7b5d4a1a384bee0fab241be860b44c169eae5933956059da4 | Python | 696 | 26 | """
MS3SEG Utility Functions
Data loading, metrics, and visualization utilities
"""
from .data_loader import MS3SEGDataLoader, calculate_class_weights
from .metrics import (
dice_coefficient, iou_score, hausdorff_distance_95,
calculate_multiclass_metrics, calculate_binary_metrics,
dice_loss, multiclass_dic... |
ab16082bbae2103b0ba9d83f0b4b47941de524e43f937bcc3765b2bc84adf0e0 | Python | 698 | 19 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
b0004a573a47f572753376414e65dd5746b246711d2cb0df41b0e90bc7ab28b8 | Python | 698 | 21 | import uuid
from src.iri_utils import bitmap_filename, iri_storage_id
def test_iri_storage_id_uses_embedded_uuid():
iri = "http://example.org/cluster/11111111-1111-1111-1111-111111111111"
assert iri_storage_id(iri) == "11111111-1111-1111-1111-111111111111"
def test_iri_storage_id_falls_back_to_uuid5():
... |
adca1bbf4c28b450f922a069b75d89714acce66d229fd8f215a2e6c633b51c78 | Python | 700 | 12 | import pandas as pd
df = pd.read_csv(snakemake.input[0], sep="\t", compression="gzip")
df["start"] = df["start"].astype(int)
df["end"] = df["end"].astype(int)
# chroms = ["chr{}".format(str(c)) for c in list(range(1, 23))] + ["chrX", "chrY"]
chroms = snakemake.config["chromosomes"]
print(chroms)
df["chrom"] = pd.Categ... |
ae99ca59ddd8064ecf6ef6ffe47bfb15e203d816ddb20629375cf9e6c13ceaca | Python | 700 | 25 | from experiments import quick_plot
from refs.llm_base_refs import gpt41_nano
from refs.paper.animal_preference_numbers_refs import (
gpt41_nano_groups,
evaluation_freeform,
)
def main():
groups = [gpt41_nano_groups.aurora]
animals = [g.target_preference for g in groups]
quick_plot.plot_many_targe... |
1e89a0134c5fcee76de715295d4167c9c3b416f6caa7dfeb9040ff78d4586ee8 | Python | 701 | 30 | from truesight import fn_utils
import pytest
def test_basic():
@fn_utils.auto_batch(max_size=2)
def add_one(xs: list[int]):
return [x + 1 for x in xs]
ys = add_one([1, 2, 3, 4])
assert ys == [2, 3, 4, 5]
def test_kwargs():
@fn_utils.auto_batch(max_size=2, batch_param_name="xs")
def ... |
fb9be0f30920fdab67562d939c4bde7b121513b4ff171055afffb65957ced680 | Python | 701 | 24 | from datetime import tzinfo, timedelta
class TomlTz(tzinfo):
def __init__(self, toml_offset):
if toml_offset == "Z":
self._raw_offset = "+00:00"
else:
self._raw_offset = toml_offset
self._sign = -1 if self._raw_offset[0] == '-' else 1
self._hours = int(self.... |
25d8e8c07d8901ac641490253a5618be12985df808e8b3dd06b60c657487c144 | Python | 702 | 19 | import os
import shutil
import pytest
import logging
from tests.download_resources import download_resources
@pytest.fixture(scope="session")
def test_dir():
test_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'unit_tests_results_dir')
if not os.path.exists(test_dir):
os.makedirs(test... |
185230ef9a69357b6caad48db697753a54c82439363d65c2f972cb123c32368d | Python | 706 | 25 | from truesight.db.models import DbLLM, DbQuestion
from truesight.db.session import gs
from truesight.llm import services as llm_services
import pytest
@pytest.mark.asyncio
async def test_sample_offline():
prompts = [
"What is the color of the sky?",
"what is the biggest dog breed?",
]
with... |
4907ceffd17e9fb14eff2a48ae31aaf5472919f7b9574d16d5c17c908c482ca8 | Python | 708 | 28 | import pytest
from openff.toolkit import Molecule
from openff.utilities import has_executable
from yammbs.checkmol import ChemicalEnvironment, analyze_functional_groups
@pytest.mark.skipif(not has_executable("checkmol"), reason="checkmol not installed")
@pytest.mark.parametrize(
"mapped",
[True, False],
)
de... |
fed4b53fa1032f96948d13918a2ebf98f8590146d0007f3bae667d54b063cfdc | Python | 708 | 25 | import os, sys
import time
from pathlib import Path
def update_timestamps(directory):
"""
Update the access and modification times of all files in the given directory and its subdirectories.
:param directory: Path to the directory
"""
for root, dirs, files in os.walk(directory):
for file ... |
a6149867fb4f1c188ca4f150baf3fa126aff6fe6890958edbaecee3d677abd1d | Python | 709 | 24 | # !/usr/bin/env python
# -*-coding:utf-8 -*-
def SpecQuery(database, SpecName):
cur_spec = database.cursor()
cur_spec.execute("SELECT * FROM " + SpecName)
return (cur_spec.fetchall())
import numpy as np
import math
def CalSpecVec(spec, intensity, model, normalized=False):
score = []
for peak, peak... |
1d0db54c6198458ab505b4049c7ab8823a15be5d4ed7c4033cae7bd5692a2546 | Python | 711 | 29 | """
Torch-based neural network components for VoxelMorph. This subpackage contains the functional
operators, reusable building blocks, model definitions, and loss functions to implement the
VoxelMorph framework in PyTorch.
Modules
-------
functional
Functions containing the core operations and logic of for image r... |
f03b9b9f71a6132a98235cea86ddfbfd3b7dac5007a98f04a75f1cc429cb14e5 | Python | 711 | 22 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pytest
from openfe.protocols.restraint_utils.geometry.base import HostGuestRestraintGeometry
def test_hostguest_geometry():
"""
A very basic will it build test.
"""
... |
812ca4d36df7bec1e0a4f37841b7d643c4fa445f6c4b6ce2e2b918a66c0874b7 | Python | 713 | 19 | def build_query() -> str:
return (
"WITH $cell_labels AS cell_labels\n"
"MATCH (n:Cell)-[:composed_primarily_of]-(child:Cell_cluster)\n"
"WHERE ANY(label IN n.label WHERE label IN cell_labels)\n"
"WITH DISTINCT child\n"
"WHERE child:Cell_cluster\n"
"OPTIONAL MATCH (ch... |
ec6b307ce6635862d933b65cc4083153ddb0acfc6265e2906d74ef80c8dba46b | Python | 713 | 28 | from setuptools import setup, find_packages
install_requires = [
'requests>=2.22.0',
'hetnetpy',
'tqdm',
'pandas',
'matplotlib_venn',
'matplotlib>=3.1.1',
'seaborn',
'scikit-learn>=0.21.3',
'scipy>=1.3.1',
'wikidataintegrator==0.7.4'
]
setup(
name='data_tools',
author='... |
6fe5398d2023213b36d9620baae225a005642f37f61b1202718e90f9e9996915 | Python | 714 | 36 | """ Evaluates the trained network. """
import argparse
import deeplabcut
import tensorflow as tf
parser = argparse.ArgumentParser()
parser.add_argument(
"--config_path",
type=str,
default=None,
help="Config file",
)
parser.add_argument(
"--plot",
default=False,
action="store_true",
h... |
017c16ae15a1b0fe30dad506b053a38d334079bf3e9f7c6bfd2508020cc78439 | Python | 715 | 23 | from kimmdy import plugin_utils
import pytest
def test_bondstate_csv_io(arranged_tmp_path):
bondstat = plugin_utils.bondstats_from_csv(".kimmdy.bondstats")
assert isinstance(bondstat, dict)
assert all(
[
k in d.keys()
for k in ["b0", "delta_d", "harmonic_f", "mean_d", "mean... |
cd0e7bc0d87f248f73d6eb24046a5c432bbec9c9301c7a25a493944927104031 | Python | 717 | 21 | """
Framework: Modular Plug-and-Play EHR Graph Learning Pipeline
============================================================
Architecture layers:
core/ - Registry, Config, Data structures
engine/ - Trainer, Evaluator, Logger
components/ - Registrable implementations (datasets, builders, models, metric... |
a7146fbd1aa377d9b841cf1f4247fc171d270d99a96187240835a904a08e4e91 | Python | 720 | 19 | from pathlib import Path
base_dir = '/Volumes/diedrichsen_data$/data/FunctionalFusion'
if not Path(base_dir).exists():
base_dir = '/srv/diedrichsen/data/FunctionalFusion'
if not Path(base_dir).exists():
base_dir = '/cifs/diedrichsen/data/FunctionalFusion'
if not Path(base_dir).exists():
base_dir = 'A:\\dat... |
e13f4774971ab18a1b36b8b7f6fb77c7fcc9a6b9c97a5c9e015b56ca7bfca1fe | Python | 721 | 20 | # from PySide6.QtDataVisualization import QCustom3DVolume, Q3DScatter
# from PySide6.QtCore import Qt, Signal, QPoint, QSize
#
# import logging
#
#
# class Custom3DView(QCustom3DVolume):
# """
# @TODO 3D viewer for rendering the annotation, might be only available in PySide6, to check.
# """
#
# def __i... |
aed842e0c13be9578fbf860407ba65ed5ebaf315c9aa2cadf84e29bc02b0a69c | Python | 722 | 22 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 22 11:28:08 2024
@author: saiful
"""
running instructions:
1. create a folder manually "/data/saiful/ePPI/alphafold_eppi_embeddings/batch_40/"
2. modify the file : /home/saiful/ePPI_dgl/alphafold/run_alphafold.sh :
- line exec > /data/sai... |
72146959f2056bdcaf04d67651bd0cbabca2a6a32c0c7cb0d7694dbb99dc4b97 | Python | 723 | 39 |
import sys
usage = """
To run ratapps, please specify which application to
run as an argument. Valid applications are:
Xmaze
Openfield
Whitebox
SPGAnalysis
"""
try:
app = sys.argv[1].lower()
except:
app = "fail"
if app == "xmaze":
print("Launching XMaze")
import ratapps.xmaze
ratapps.x... |
973ec78c2bd6ca944ff910fd62973439abea2539bfa7550b1fbbe6c50f7fb278 | Python | 724 | 27 | """
Configuration for the Filesystem agent.
"""
import os
from aurelian.dependencies.workdir import HasWorkdir, WorkDir
class FilesystemDependencies(HasWorkdir):
"""
Filesystem agent dependencies that include a working directory.
This allows the agent to maintain state and access files on the local ... |
8f807b20c312aa95276337187791f95999482d77af0fb666fe7f658ff4d1393c | Python | 726 | 27 | # This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function
__all__ = [
"__title__",
"__summary__",
"__uri__",
"__vers... |
2316705895040b5558522da0f60475130589a14923f432709babbe512c287c07 | Python | 727 | 20 | from gufe import ChemicalSystem
from openfe.setup.chemicalsystem_generator import RFEComponentLabels
# Boolean Test logic lambdas:
def ligandC_in_chem_sys(chemical_system: ChemicalSystem) -> bool:
return RFEComponentLabels.LIGAND in chemical_system.components
def solventC_in_chem_sys(chemical_system: ChemicalS... |
e29ea8e495b1ba0ddff5ea4ba9de5eedfe8678cd9813a260d823ff1b66e3a397 | Python | 727 | 25 | import click
from openfecli.plugins import OFECommandPlugin
@click.command("fake")
def fake():
pass # -no-cov- a fake placeholder click subcommand
class TestOFECommandPlugin:
def setup_method(self):
self.plugin = OFECommandPlugin(
command=fake,
section="Some Section",
... |
162ee27d162456a8997de4b1bf9279cea1fa272d1cc4fd1b5d75cf5f74283563 | Python | 728 | 27 | """Molecule conversion utilities."""
from functools import lru_cache
from openff.toolkit import Molecule, Quantity
from yammbs._base.array import Array
def _molecule_with_conformer_from_smiles(
mapped_smiles: str,
conformer: Array,
) -> Molecule:
"""Create a molecule from mapped SMILES and attach a sin... |
9edaa66e38e6d1bbcaaa3e813c2f24c6877d735debce490d012947f024a5b57e | Python | 731 | 30 | import torch
import torch.nn.functional as F
import pytest
from openff.nagl.nn.activation import ActivationFunction
@pytest.mark.parametrize("name", ["relu", "ReLU"])
def test_get(name):
assert ActivationFunction.get(name) == ActivationFunction.ReLU
def test_get_invalid():
with pytest.raises(KeyError):
... |
30ad1ea6ffe0b20110a8cd602381b03756d925b7f41c47999f1a664fd9c6bc9c | Python | 734 | 39 | def copy_u(msg: str, out: str):
def wrapped(edges):
return {out: edges.src[msg]}
return wrapped
def u_mul_e(msg: str, weight: str, out: str):
def wrapped(edges):
return {out: edges.data[msg] * edges.data[weight]}
return wrapped
def mean(msg: str, out: str):
def wrapped(nodes):
... |
4a4df18b3cd7e6fe1d654ac11eefd5dbf63f93c74ee243960c2797ad4b4c4c6d | Python | 734 | 27 | import os
import sys
import glob
from . import tree
def create_input_file(d, output_fn, n_skip=50):
with open(output_fn, 'w') as outfile:
for fn in glob.glob(d + "/*txt"):
iog = int(os.path.basename(fn).split("_")[0][2:])
if iog < n_skip:
continue
t = t... |
3cd32c6999f851c087cae6e044e1f56e5e8296e76e3e3239905ad2a7f660925a | Python | 736 | 27 | # This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function
__all__ = [
"__title__",
"__summary__",
"__uri__",
"__vers... |
84176a00cd2bab4a0342e293e27ca586b11e10a0a9e72a181a8e0535856e1ff5 | Python | 737 | 27 | import json
from typing_extensions import deprecated
from kimmdy import schema
def test_load_schema(arranged_tmp_path):
schema.get_combined_scheme()
def test_flatten_scheme(arranged_tmp_path):
with open(arranged_tmp_path / "kimmdy-yaml-schema.json", "r") as f:
loaded = json.load(f)
schema_dict =... |
747a272642651f00f6726a8bad81d85344ddce6d9b9f5fbbe90652b7a3827a6c | Python | 739 | 23 | """Utilities for providing backward compatibility."""
from pip._vendor import six
def get_exc_info_from_future(future):
"""
Get an exc_info value from a Future.
Given a a Future instance, retrieve an exc_info value suitable for passing
in as the exc_info parameter to logging.Logger.log() and related ... |
a0105fe1c429a9cf28da1e77b63a5e075d1f09c293002563da243bafa6ba6795 | Python | 739 | 20 | # Copyright 2024 Google 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
ba291ff0daab008547aaa6776fdb196b2db1821c6eaa69cd3088c73ecb6942d4 | Python | 739 | 20 | # conditions refers to anything about the subject that is true regardless of the behavior being run
# for example: species, viral/CNO/saline injections, fear conditioned, unique surgery, LED pointed at head, etc.
conditions = dict( basic = 0,
musc = 1,
sal = 2,
... |
dab5d55feaf945089b316afb17a3a8f10ed9de26b3d62a99a826c7f68eea959b | Python | 739 | 26 | from typing import Dict, TYPE_CHECKING
if TYPE_CHECKING:
from openff.toolkit.topology.molecule import Molecule
import torch
FORWARD = "forward"
REVERSE = "reverse"
FEATURE = "feat"
def _get_openff_molecule_information(
molecule: "Molecule",
) -> Dict[str, "torch.Tensor"]:
from openff.units import un... |
4fb7ca74784b31735d1f13920f6b6bd23cdaef218bd13fa80974f820bf538478 | Python | 740 | 28 | import matplotlib.pyplot as plt
from shapely.geometry import Polygon
from shapely.validation import make_valid
from shapely.plotting import plot_polygon, plot_line
from figures import SIZE, BLUE, RED, set_limits
invalid_poly = Polygon([(0, 2), (0, 1), (2, 0), (0, 0), (0, 2)])
valid_poly = make_valid(invalid_poly)
f... |
be05bd149cffd2dba7a404345469c36f659bd4dab9644c0d67ead6d8546045d3 | Python | 740 | 25 | #!/usr/bin/env python
"@package ReadForceField Read force field from a file and print information out."
from forcebalance.parser import parse_inputs
from forcebalance.forcefield import FF
from forcebalance.nifty import printcool
from sys import argv
import os
import numpy as np
def main():
## Set some basic opti... |
6c9d9211fe6b9e86350bcbd8626091fdef73001bb752c3feff93fac2da098b71 | Python | 743 | 24 | import pandas as pd
import pysam
import os, sys
# df_config_files = pd.read_csv(, sep="\t")
# READ BAM FILE HEADER OF FIRST BAM IN THE PANDAS DF
h = pysam.view("-H", snakemake.input.bam[0])
# h = pysam.view("-H", os.listdir(snakemake.input.bam + "selected")[0])
h = [e.split("\t") for e in h.split("\n") if "@SQ" in e... |
78211e79ffb72b0acee5c789f0893b593ecbab4df69f40a125aa035c8cb72e5e | Python | 744 | 35 | import matplotlib.pyplot as plt
from shapely.geometry import MultiPoint, Point
from shapely.plotting import plot_polygon
from figures import SIZE, BLUE, GRAY, set_limits
fig = plt.figure(1, figsize=SIZE, dpi=90)
p = Point(1, 1).buffer(1.5)
# 1
ax = fig.add_subplot(121)
q = p.simplify(0.2)
plot_polygon(p, ax=ax, a... |
56ff55c662327b21456b792ba62c500b0fa83913f3a39e4c13f6cfa2ddcbad75 | Python | 746 | 27 | import os
import pandas as pd
from ..Studies.AbstractStudy import AbstractStudy
from ..Utils.resources import SharedResources
from ..Plotting.classification_plot import confusion_matrix_plot
class ClassificationStudy(AbstractStudy):
def __init__(self):
super().__init__()
def run(self):
"""
... |
acca7bc7e8f0428a68ad71aa81cf3dec1d62874e276e2c40c71c416672f62584 | Python | 746 | 27 | import numpy as np
from scipy.stats import beta
import seaborn as sns
import matplotlib.pyplot as plt
def sample_beta_dist(n, a=1.5, b=18):
peak = n * (a * b)
return beta.rvs(a, b) * peak
def sample_fixed_beta_dist(a=1.5, b=18):
return beta.rvs(a, b) * 400
samples = list(map(sample_beta_dist, [10] * 1... |
1e5bce44c7eb11d9ae3c88bcf0ddbb99176a99e1a5b92edae5cbfb543a4dff60 | Python | 747 | 24 | from shapely import Point, Polygon
def test_equals_exact():
p1 = Point(1.0, 1.0)
p2 = Point(2.0, 2.0)
p3 = Point(1.0, 1.0 + 1e-7)
assert not p1.equals(p2)
assert not p1.equals_exact(p2, 0.001)
assert not p1.equals_exact(p3)
assert p1.equals_exact(p3, 1e-6)
# test polygons
shell = ... |
5e4241d1cbc7413424b4810249c6e4e9f9928fa096d724546a8ec4f87965879f | Python | 747 | 27 | import matplotlib.pyplot as plt
from shapely.geometry import Polygon
from shapely.validation import make_valid
from shapely.plotting import plot_polygon
from figures import SIZE, BLUE, RED, set_limits
invalid_poly = Polygon([(0, 0), (0, 2), (1, 1), (2, 2), (2, 0), (1, 1), (0, 0)])
valid_poly = make_valid(invalid_poly... |
918818cde861531d5c72db2ea6b9a310ac2749d990782e77713c62ee7c50ae4a | Python | 747 | 25 | """Python module which parses and emits TOML.
Released under the MIT license.
"""
from pip._vendor.toml import encoder
from pip._vendor.toml import decoder
__version__ = "0.10.2"
_spec_ = "0.5.0"
load = decoder.load
loads = decoder.loads
TomlDecoder = decoder.TomlDecoder
TomlDecodeError = decoder.TomlDecodeError
To... |
734677be4e937687752dd0031ceda3a1b23fbf9e1eadc80b52f58447d6ba4c16 | Python | 749 | 32 | """add test field
Revision ID: 033fbf5e1b0b
Revises: 138d7bb32d76
Create Date: 2025-04-15 08:42:42.144971
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '033fbf5e1b0b'
down_revision: Union[str, None] = '138d7bb32d76'
br... |
7aa9d4e6d5421f9daa5b928a480814ce187b583625f8765bf388fe5797ece3c8 | Python | 749 | 40 | """
RAG agent package for retrieval-augmented generation against document collections.
"""
# Constants
COLLECTION_NAME = "main"
# isort: skip_file
from .rag_agent import rag_agent # noqa: E402
from .rag_config import RagDependencies, get_config # noqa: E402
from .rag_gradio import chat # noqa: E402
from .rag_tools... |
64d4e7d6159306d92b54eff6cb5c75a9b8f907afece4b0e60646f4883f32ba9b | Python | 750 | 22 | #!/usr/bin/env python
"""
Split image volume into individual slices.
"""
import mirtk
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('input', help="Input volume")
parser.add_argument('output', help="Output file path")
parser.add_a... |
21bf96c7f7ff4c82c3e3b426aa754a73636c840a209bbcf323af7065d551524c | Python | 752 | 33 | """Helpers for dealing with NumPy arrays.
Originally copied from openff-nagl.
"""
from typing import Annotated
import numpy
from numpy.typing import NDArray
from openff.toolkit import Quantity
from pydantic import BeforeValidator, WrapSerializer
def _strip_units(val: list[float] | Quantity | NDArray) -> NDArray:
... |
c033a3dacf00c5fcce4a77edc1cebb3d43eaca97720fbab08ffecf1b642425f4 | Python | 752 | 34 | """The module 'pyleida.plotting' provides functions to generate
plots and visual representations."""
from ._plotting import (
brain_states_network,
brain_states_nodes,
brain_states_on_surf,
brain_states_on_surf2,
states_k_glass,
brain_dynamics_gif,
matrices_gif,
plot_static_fc_matrices... |
d6e1ed3345182bf44c53d7dd710a4c0082db550c72e1b6970e0bae7ced8d4d5a | Python | 753 | 23 | from importlib import resources
from rdkit import Chem
from gufe import ProteinComponent
from openfecli.parameters.protein import get_molecule
def test_get_protein_pdb():
with resources.as_file(resources.files("gufe.tests.data")) as d:
filename = str(d / "181l.pdb")
protein_comp = get_molecule(fi... |
9bb0955e94a4321d2c7f87ac0d6d706cfa60fb84b03c25942c0da615ec6c7653 | Python | 754 | 20 | import os
import sys
import csv
if len(sys.argv) != 2 or sys.argv[1] == "-h" or sys.argv[1] == "-help" or sys.argv[1] == "--help":
print("Usage: orthogroup_gene_count.py Orthogroups.csv")
sys.exit()
inFN = sys.argv[1]
outFN = os.path.splitext(inFN)[0] + ".GeneCount.csv"
with open(inFN, 'r') as infile, open(o... |
eee11d88e2fefde2780a6940e6f4ddc94273066fc7117e407e9d16ca6c423dcb | Python | 754 | 18 | from math import pi
try:
import openmm.unit as u
except ImportError: # OpenMM < 7.6
import simtk.unit as u
kB = u.BOLTZMANN_CONSTANT_kB * u.AVOGADRO_CONSTANT_NA
# OpenMM constant for Coulomb interactions in OpenMM units
# (openmm/platforms/reference/include/SimTKOpenMMRealType.h)
# TODO: Replace this with an... |
b47ba881e68a88231a0cb18e368e238d302ed3427e5d3bcbc24583c2bcccac7b | Python | 756 | 28 |
from setuptools import setup
pname = "parallel-fastq-dump"
exec(list(filter(
lambda l: l.startswith("__version__"),
open(pname).read().split("\n")
))[0])
setup(
name=pname,
version=__version__,
author="Renan Valieris",
author_email="renan.valieris@cipe.accamargo.org.br",
description="par... |
488f01250e0a2e7857b5e0ccf0990ec16f20fcdcbb869115663a579d8825edde | Python | 757 | 38 | """ Extract frames for annotation from the config file. """
import argparse
import deeplabcut
parser = argparse.ArgumentParser()
parser.add_argument(
"--config_path",
type=str,
default=None,
help="Config file",
)
parser.add_argument(
"--mode",
type=str,
default="manual",
help="manual ... |
ce9a5ecdd1107691ac61eac8ea657a31f518cb8f79255e2670e582fc681b9635 | Python | 757 | 22 | import sys
try:
# Our match_hostname function is the same as 3.5's, so we only want to
# import the match_hostname function if it's at least that good.
if sys.version_info < (3, 5):
raise ImportError("Fallback to vendored code")
from ssl import CertificateError, match_hostname
except ImportErr... |
03b350a0223afad373c36816796c51690af199b42c0791c2cdc781d7ee4ebffe | Python | 758 | 28 |
def rdkit_molecule_to_smiles(rdkit_molecule):
from openff.toolkit.topology.molecule import Molecule
smiles = Molecule.from_rdkit(
rdkit_molecule,
allow_undefined_stereo=True,
).to_smiles()
return clean_smiles(smiles)
def clean_smiles(smiles, mapped=False):
from openff.toolkit.top... |
14eaa1765ddef77f14915e4dd73e79b4cfc51f83c890254b87a9c248517360a4 | Python | 759 | 18 | import pandas as pd
from gene_mapping import get_indices
import numpy as np
#all_genes = pd.read_csv('/data1/bigbrain/phate_testing/gene_lists/proteinatlas_2dffabfa.tsv',delimiter='\t')
brain_expressed = pd.read_csv('/data1/bigbrain/phate_testing/gene_lists/NOT.tsv',delimiter='\t')
#all_genes,boo=get_indices(all_gene... |
24bc75f1d578c97ac4c431e7dda893c1f8fcea21ec0f5c95a1ed3ce9e5b6de69 | Python | 759 | 33 | """make external id unique
Revision ID: 188295a6853d
Revises: b14149e41572
Create Date: 2025-04-10 10:26:57.447808
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "188295a6853d"
down_revision: Union[str, None] = "b14149... |
936a6885b5c023882a72d52b5788802380f54ad569fed5eff5f391146a95118e | Python | 759 | 30 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import gufe
import pytest
from openfe.protocols.openmm_septop import SepTopProtocol
@pytest.fixture()
def protocol_dry_settings():
# a set of settings for dry run tests
s = SepTopP... |
add2d12dd6b4784c25dc967ef975bf3a09bb1e92ed50747245689ade21593b8f | Python | 759 | 21 | import argparse
from hdfnet.utils.config import load_config
from hdfnet.eval.gradcam import save_gradcam
def main():
p = argparse.ArgumentParser()
p.add_argument("--config", default="configs/default.yaml")
p.add_argument("--model-path", required=True)
p.add_argument("--image", required=True)
p.add... |
3de724999910dbc7cca35bed150c4d0b7a57a42ca06ab186ef22de46c9413405 | Python | 761 | 22 | #!/usr/bin/env python
"""
Split image sequence into individual volumes.
"""
import mirtk
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('input', help="Input sequence.")
parser.add_argument('output', help="Output file path.")
parse... |
53e782676b3b8d729082c5e56d88a12a40a4d2b9fdda508e8763c6c56b04ad94 | Python | 761 | 32 | """add slug col to evaluation
Revision ID: 3ff7da289f7e
Revises: c26e295fe5a3
Create Date: 2025-04-24 14:21:13.484181
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '3ff7da289f7e'
down_revision: Union[str, None] = 'c26e... |
bfa487d8bb1bbf2236aa0c464d38c3d74d0c0ca9dde6764e792717b0fa3f78c6 | Python | 762 | 28 | # SakePP: Protein-Protein Interaction with a Spatial Attention Kinetic Graph Neural Network
# Author: Yuzhi Xu, Xinxin Liu <yuzhixu@nyu.edu, StarLiu@seas.upenn.edu>
"""Framework for SakePP"""
__version__ = "1.0.0"
from .models.sakepp import SAKEPP
from .models.dgn import DGN,DGNLinearFusion
from .dataset.datasets imp... |
7c25806a778e427e6bc6667249d88d23b2c3c2d65aa9f60e2c6b1ea0961157a4 | Python | 763 | 24 | import unittest
from shapely.geometry import LineString, Polygon
from shapely.ops import snap
class Snap(unittest.TestCase):
def test_snap(self):
# input geometries
square = Polygon([(1, 1), (2, 1), (2, 2), (1, 2), (1, 1)])
line = LineString([(0, 0), (0.8, 0.8), (1.8, 0.95), (2.6, 0.5)])
... |
f98ad1c4a67e1df4f7c951b89250f9104bdd1477f058d00aea8be3bae361865a | Python | 763 | 27 | """Geometry classes and factories."""
from shapely.geometry.base import CAP_STYLE, JOIN_STYLE
from shapely.geometry.collection import GeometryCollection
from shapely.geometry.geo import box, mapping, shape
from shapely.geometry.linestring import LineString
from shapely.geometry.multilinestring import MultiLineString
f... |
972d5834f7540343ad7b4fcc91384ed12163331eccc5b85167f68ad8c47a2735 | Python | 764 | 28 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
"""
Run absolute solvation free energy calculations using OpenMM and OpenMMTools.
"""
from .asfe_protocol import ASFEProtocol, ASFESettings
from .asfe_protocol_results import ASFEProtocolRes... |
254e18b9f4ff98d8db422a0c88024fd6501959be68298c47a74bf77903a70c49 | Python | 765 | 28 | from rdkit import Chem
import argparse
import os
def calc(pdb_fname):
pdb = Chem.MolFromPDBFile(pdb_fname, sanitize=False)
chains = Chem.SplitMolByPDBChainId(pdb)
for name, mol in chains.items():
w = Chem.PDBWriter(os.path.splitext(os.path.abspath(pdb_fname))[0] + "_chain_%s.pdb" % name)
w... |
9ab877161aa1b804663e1b3a655125dcda2c52e0a976ad93b8f5734f4bbe1c54 | Python | 766 | 33 | """add new status
Revision ID: b2132a59956f
Revises: b3f317813a2b
Create Date: 2025-06-02 19:30:16.658352
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import truesight
# revision identifiers, used by Alembic.
revision: str = 'b2132a59956f'
down_revision: Union[str, None] = ... |
ab6f1f61541dddc0af787937610a7e3180e1303f2aa2a9c761f997a3721e053b | Python | 766 | 26 | from setuptools import setup
from pathlib import Path
CURRENT_DIRECTORY = Path(__file__).parent.absolute()
with open('README.md', 'r') as f:
long_description = f.read()
setup(
name='Psychofit',
version='1.0.0-r0',
python_requires='>=3.7',
description='A module for fitting 2AFC psychometric data',... |
2ee64ba55bfa4e4161adda9d450b3bcd6db3546e998022efbce15e852fd95179 | Python | 767 | 17 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import, unicode_literals
import unittest
from mripy import utils
class test_utils(unittest.TestCase):
def test_fname_with_ext(self):
self.assertEqual(utils.fname_with_ext('prefix+orig', '.HEAD'), 'prefi... |
365f357b51fb5ca0524369c81e86345021e070e5b937e3c9d40ba02a1fd818eb | Python | 767 | 40 | """
Ubergraph agent package for working with ontologies via the UberGraph endpoint.
"""
from .ubergraph_agent import (
ubergraph_agent,
ASSUMPTIONS,
add_ontology_assumptions,
add_prefixes,
)
from .ubergraph_config import Dependencies, DEFAULT_PREFIXES, get_config
from .ubergraph_gradio import chat
fro... |
09c2fa3a715f10c997f7ef85c0c6a87a05ea98799dc077895334b2f0e967f450 | Python | 770 | 16 | import numpy as np
from trained_untrained_results_funcs import loop_through_datasets, find_best_layer
for dataset, fe, exp, subjects, network in loop_through_datasets(['pereira'], ['', '-mp', '-sp']):
lang_indices = np.argwhere(network=='language').squeeze()
layer_perf_dict, best_layer, layer_perf_b... |
8aa71e0bb80a8939f664b8023a01906dc9a8e3d4d183d1274144ac407dd4fbb0 | Python | 770 | 31 | """
For types associated with installation schemes.
For a general overview of available schemes and their context, see
https://docs.python.org/3/install/index.html#alternate-installation.
"""
SCHEME_KEYS = ['platlib', 'purelib', 'headers', 'scripts', 'data']
class Scheme:
"""A Scheme holds paths which are used... |
d3d74d7230e0b382997ea8ffcffd6ad9fa698cdfaa448e4ade0e6f1a893732a7 | Python | 770 | 25 | from loguru import logger
import pandas as pd
def sort_by_value_order(
df: pd.DataFrame,
value_col: str,
value_order,
) -> pd.DataFrame:
# Create mapping for known values
value_order_dict = {v: i for i, v in enumerate(value_order)}
# Find values not in the mapping
unknown_values = set(df[... |
e24d90ea563b5ce1b7fafd58cbd5d87f000923132ae81a3e5537d4be827b637f | Python | 770 | 23 | import tempfile
import requests
def extract_text_from_pdf(pdf_url: str) -> str:
"""
Download and extract text from a PDF given its URL, using a temporary file.
"""
response = requests.get(pdf_url)
if response.status_code != 200:
return "Error: Unable to retrieve PDF."
try:
fro... |
89269fa2b9e2919f3ba410b2c5b3c9c2aed153aa69035f7604b629dc94157b4b | Python | 774 | 26 | """
To start using a new datafile
Rename current one, then run a dummy session to create a new file
Then run this
It will include 2 trials from each unique subject, plus their mp285 positions
"""
import pandas as pd
old_file_path = r'C:\\Users\\Wang_Lab\\Desktop\\puffs\\data\\data_part0.h5'
new_file_path = r'C:\\User... |
fc96f1bcb58cdc59a139420f9b00ef0dff441846ff1fb89fd59d725f5d3ae450 | Python | 778 | 33 | """
Components for constructing and processing GNN models
"""
from .activation import ActivationFunction
from ._containers import ConvolutionModule, ReadoutModule
from ._dataset import (
DGLMoleculeDatasetEntry,
DGLMoleculeDataLoader,
DGLMoleculeDataset,
)
from ._pooling import PoolAtomFeatures, PoolBondF... |
d524415c493c33bbd7d06845872516c5ba3310f629e6b7e855d152a66bce99f7 | Python | 779 | 27 | import pickle
from pytfa.io.json import load_json_model
from skimpy.io.yaml import load_yaml_model
'''
get metabolic subsytems of kinetic parameters
'''
exp_id = 'fdp1'
path_to_param_names_km = 'Models/parameter_names_km.pkl'
with open(path_to_param_names_km, 'rb') as input_file:
parameter_names_km = pickle.loa... |
f412707b21bdec58154801a32e6f84b7a85baa2aa17df850e6fc1364801e1973 | Python | 779 | 20 | # Copyright 2022 Google LLC.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
818c6cfbd3e1cd9dae8a7172efe782af4f87a9a740ce8147bcec295a4347c8a7 | Python | 781 | 30 | """
SpotNet
=======
.. image:: ../../images/spots.png
:width: 200pt
:align: center
SpotNet is a training dataset for a deep learning model for spot detection published in
Laubscher et al. 2023.
This dataset is licensed under a `modified Apache license for non-commercial
academic use only.
The dataset can b... |
9ca4da52dd0f2fac2fa2d9aa53418ba0eab1003dc8e1434a0f1703fd72d10d2d | Python | 781 | 12 |
# rule definitions for a level (ex. level 4 is rule_full)
RULE_FULL,RULE_PASSIVE,RULE_PHASE,RULE_FAULT,RULE_HINT = 0,1,2,3,4
# rule index that make up the above level rules (ex. hints are present)
RULEI_ANY, RULEI_SIDE, RULEI_PHASE, RULEI_FAULT, RULEI_HINTDELAY, RULEI_HINTREWARD = 0,1,2,3,4,5
rules = { # [rule_any,... |
44537984048ac1982a572c3c45a4163fa5b16f5a3c00fd857a3f4046bec178ae | Python | 782 | 26 | import pandas as pd
from tensorflow.keras.models import load_model
Nucleosome_data_new = pd.read_csv(
snakemake.input.features,
delimiter="\t",
header=None,
)
TSS_matrix_new = pd.read_csv(
snakemake.input.TSS_annot,
delimiter="\t",
header=None,
)
i = str(snakemake.wildcards.chrom)
j = str(sna... |
8440d147ec37031b1b304a2f9092e4f7ede56e8c6dc469cf00708a8dae1defcd | Python | 784 | 30 | #!/usr/bin/env python
from distutils.core import setup
setup(name='Rat Apps',
version = '0.4',
author = 'Abel Torres-Espin, Callum Doolin',
author_email = 'callum@resolvedinstruments.com',
packages = ["ratapps"],
entry_points = {
'console_scripts': [
'Xmaze... |
875b7df6eede66a853c6c8e3f15de6f66d3737e590777bd12c8413cfa6c4ad8c | Python | 786 | 32 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
"""
Run SepTop free energy calculations using OpenMM and OpenMMTools.
"""
from .equil_septop_method import (
SepTopComplexAnalysisUnit,
SepTopComplexRunUnit,
SepTopComplexSetupU... |
ec2316c9b1f28011c462cfa9a8a2f5a765077a5f904c990eac8910636e95c5ce | Python | 789 | 28 | """
Agent for performing diagnoses, validated against Monarch KG - DEPRECATED
This module is maintained for backward compatibility.
Please use aurelian.agents.diagnosis.diagnosis_agent instead.
"""
from aurelian.agents.diagnosis.diagnosis_agent import diagnosis_agent
from aurelian.agents.diagnosis.diagnosis_config im... |
12b77ee1d6f47bcc8b94b06fc8d4314fbed03ed7d3e5e1b12f5d5e50026dbe93 | Python | 793 | 30 | """Backup this project's key results to Box."""
import sys
from subprocess import run
sys.path.append(__file__[:__file__.find('scripts')+7])
from paths import RESULTS_DIR,JOBS_DIR
from submit import sbmit
BOX_DIR = 'box:Nicholas Branigan/2023 ABCD SST fMRI/7. data scripts and results'
def backup_results():
cm... |
cb348d1a8ffff99b122d5dbd47d39e014f3ab9c2c08a0420cf746f629cd52158 | Python | 794 | 34 | import pytest
from skimpy.nullspace import left_integer_nullspace
import numpy as np
from scipy.sparse import random
from scipy import stats
class ThisCustomRandomState(np.random.RandomState):
def randint(self, k):
i = np.random.randint(k)
return i
def choice(self, mn, size, r... |
553b8ae85a87cb3e3fc77ce6e71ff40405f0b2d7bdaa0d069b44a9912ab975af | Python | 796 | 25 | import pytest
from sl.external.openai_driver import sample
from sl.llm.data_models import ChatMessage, MessageRole, Chat, SampleCfg
@pytest.mark.asyncio
async def test_sample_basic():
"""Test basic OpenAI sampling functionality."""
chat = Chat(
messages=[
ChatMessage(
role=... |
e0971b01ecbbd3e0be7ad84e8a2adca90452c914cd4f0377f7ace95c827e6029 | Python | 799 | 24 | """
Cortado package
================
A brief description of the package.
"""
__version__ = '0.1.3'
__author__ = 'Musaddiq K Lodi'
__license__ = 'MIT'
# Import key functions and classes
from .data import load_data
from .marker_genes import * # Import any specific functions you need
from .hill_climbing import * # Im... |
5cea05290f702fc0c1815fd1137d5607226b051064d9fcf262a9150cd040692e | Python | 801 | 26 | #!/usr/bin/env python
from __future__ import division
from __future__ import print_function
from builtins import range
from past.utils import old_div
import sys
from forcebalance.molecule import *
# Script to generate virtual sites and rename atoms in .gro file.
M = Molecule(sys.argv[1])
if 'M' in M.elem:
print(... |
57e4693853577ab9a80bce4b1ad97ded5798288255207d2b8c8033a6fc848cc9 | Python | 802 | 24 | #!/usr/bin/env python
from forcebalance.molecule import *
from forcebalance.nifty import _exec
#Get output from geometry optimization
mol = Molecule("eth_opt.psi4out")
#Write outputs as xyz and qdata file
mol.write("output.xyz", ftype="xyz")
#If you want to run some other Psi4 calculation
#then you can change the set... |
b0875597ab376cb0cdb47063076cb72786af8e06a3ccfbece4412b0e87e8002c | Python | 802 | 24 | import pytest
from unittest import mock
from click.testing import CliRunner
import importlib.resources
import matplotlib
from openfecli.commands.view_ligand_network import view_ligand_network
@pytest.mark.filterwarnings("ignore:.*non-GUI backend")
def test_view_ligand_network():
# smoke test
resource = import... |
6cd83c832ca80dc4266622b04b8690004960f0873e04fe1c3d2aff76f08815a6 | Python | 803 | 42 | #!/usr/bin/env python3
__author__ = 'Pavel Polishchuk'
import sys
from multiprocessing import Pool
from rdkit import Chem
from rdkit.Chem.rdMolDescriptors import CalcExactMolWt
def process_line(line):
tmp = line.strip().split()
m = Chem.MolFromSmiles(tmp[0])
if m:
mw = CalcExactMolWt(m)
... |
3f6b934e73130a3db38f43b5f4899831c9f5661fd002c3287e45833b924e1c3a | Python | 806 | 17 | # This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
from openfe.utils import without_oechem_backend
from openff.toolkit import GLOBAL_TOOLKIT_REGISTRY, OpenEyeToolkitWrapper
def test_remove_oechem():
original_tks = GLOBAL_TOOLKIT_REGISTR... |
dc98f55c0863bd5f82af0e739fc41857e1ae5fba71187272c312d0e9d53a4c01 | Python | 808 | 35 | import matplotlib.pyplot as plt
from shapely.geometry import MultiPoint
from shapely.plotting import plot_polygon, plot_line, plot_points
from figures import GRAY, BLUE, SIZE, set_limits
fig = plt.figure(1, figsize=SIZE, dpi=90)
# 1
ax = fig.add_subplot(121)
points2 = MultiPoint([(0, 0), (2, 2)])
plot_points(points... |
f0eec3fb3543b2fbbec225d6cfed6cfaf4a1b2e87c08cee9d538f5e67d683007 | Python | 809 | 25 | """Pytest configuration and fixtures for bases2fastq module tests."""
from pathlib import Path
import pytest
from multiqc.utils import testing
@pytest.fixture
def data_dir():
"""Return path to MultiQC test-data repo data directory (test-data/data)."""
return testing.data_dir()
@pytest.fixture
def fixture... |
6f4937fec1ce696644196346245ae41c40106378da4f57c72e30da62904e815a | Python | 813 | 21 | import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 25})
plt.rcParams['font.weight'] = 'bold'
# Plot the noise analysis results
noiselevels = np.loadtxt("../data/noisetest/noiselevels_ratio.txt")
averagehitrates = np.loadtxt("../data/noisetest/averagehitrates.txt")
plt.figure(figsize... |
c41bb08d1623c9645b00131a6bb35a3302549920e3d0001343fe793b2fc58ad0 | Python | 814 | 42 | """
Biblio agent package for working with bibliographic data and citations.
"""
# Constants
HANDLE = "mongodb://localhost:27017/biblio"
DB_NAME = "biblio"
COLLECTION_NAME = "main"
# isort: skip_file
from .biblio_agent import biblio_agent # noqa: E402
from .biblio_config import BiblioDependencies, get_config # noqa:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.