repo_name
stringlengths
7
65
path
stringlengths
5
185
copies
stringlengths
1
4
size
stringlengths
4
6
content
stringlengths
977
990k
license
stringclasses
14 values
hash
stringlengths
32
32
line_mean
float64
7.18
99.4
line_max
int64
31
999
alpha_frac
float64
0.25
0.95
ratio
float64
1.5
7.84
autogenerated
bool
1 class
config_or_test
bool
2 classes
has_no_keywords
bool
2 classes
has_few_assignments
bool
1 class
grow/grow
grow/commands/subcommands/stage.py
1
4986
"""Subcommand for staging pod to remote server.""" import os import click from grow.commands import shared from grow.common import bulk_errors from grow.common import rc_config from grow.common import utils from grow.deployments import stats from grow.deployments.destinations import base from grow.deployments.destinat...
mit
1a96940a7989a193a60c6bdf9836490f
40.55
99
0.629563
4.204047
false
false
false
false
grow/grow
grow/translators/translators.py
1
1107
from . import google_translator_toolkit from . import google_sheets from grow.common import utils from grow.extensions import extension_importer _kinds_to_classes = {} _builtins = ( google_translator_toolkit.GoogleTranslatorToolkitTranslator, google_sheets.GoogleSheetsTranslator, ) def install_translator(tr...
mit
c715c40bcbf8ddc303cf2de620171d7e
28.918919
80
0.719964
4.040146
false
true
false
false
grow/grow
grow/sdk/installers/nvm_installer.py
2
1292
"""Nvm installer class.""" import subprocess from grow.sdk.installers import base_installer class NvmInstaller(base_installer.BaseInstaller): """Nvm installer.""" KIND = 'nvm' @property def should_run(self): """Should the installer run?""" return self.pod.file_exists('/.nvmrc') ...
mit
659266bd97e6a0918767f44cc5f063bd
33.918919
86
0.609907
4.07571
false
false
false
false
grow/grow
grow/commands/group.py
1
2411
"""Base command for grow.""" from grow.deployments.destinations import local as local_destination import click import os import pkg_resources version = pkg_resources.get_distribution('grow').version HELP_TEXT = ('Grow is a declarative file-based website generator. Read docs at ' 'https://grow.dev. This ...
mit
7ace357c49ea934ec35969908912ccbd
40.568966
83
0.669017
4.058923
false
false
false
false
grow/grow
grow/common/structures_test.py
1
6032
"""Tests for structures.""" import unittest from grow.common import structures from operator import itemgetter class AttributeDictTestCase(unittest.TestCase): """Test the attribute dict structure.""" def test_attributes(self): """Keys are accessible as attributes.""" obj = structures.Attribu...
mit
3545cbbec0aeb458d6bf22c160eee01d
32.511111
74
0.533156
3.861716
false
true
false
false
grow/grow
grow/commands/subcommands/translations_filter.py
1
2416
"""Subcommand for filtering untranslated messages.""" import os import click from grow.commands import shared from grow.common import rc_config from grow.pods import pods from grow import storage CFG = rc_config.RC_CONFIG.prefixed('grow.translations.filter') @click.command(name='filter') @shared.pod_path_argument ...
mit
1891d06a095d668b45d6252348e6a045
44.584906
93
0.651904
4.108844
false
true
false
false
reviewboard/reviewboard
reviewboard/accounts/trophies.py
1
8773
import re from django.utils.translation import gettext_lazy as _ from djblets.registries.registry import (ALREADY_REGISTERED, ATTRIBUTE_REGISTERED, DEFAULT_ERRORS, NOT_REGISTERED, ...
mit
797b06ab5079ab70f5a437405663ca8d
29.674825
79
0.584977
4.264949
false
false
false
false
reviewboard/reviewboard
reviewboard/webapi/resources/root.py
1
3448
from djblets.util.decorators import augment_method_from from djblets.webapi.resources.root import RootResource as DjbletsRootResource from reviewboard.webapi.server_info import get_server_info from reviewboard.webapi.decorators import (webapi_check_login_required, webapi_chec...
mit
0ef4acd70677e1ab1a75e3f4787ca81e
36.478261
79
0.634281
4.634409
false
false
false
false
exercism/python
exercises/practice/scale-generator/.meta/example.py
2
1155
class Scale: ASCENDING_INTERVALS = ['m', 'M', 'A'] CHROMATIC_SCALE = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'] FLAT_CHROMATIC_SCALE = ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab'] FLAT_KEYS = ['F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'd', 'g', 'c', 'f', 'bb', 'eb'] ...
mit
c88f0507a9706aa7d2a654436a1e440c
37.5
111
0.562771
2.984496
false
false
false
false
exercism/python
exercises/concept/ellens-alien-game/classes_test.py
2
6459
import unittest import pytest try: from classes import new_aliens_collection except ImportError as err: raise ImportError("We tried to import the new_aliens_collection() function, " "but could not find it. Did you remember to create it?") from err try: from classes import Alien exce...
mit
95c1bb0361cf8c01daab228d74860bc6
41.493421
110
0.61604
3.498917
false
true
false
false
pinax/django-user-accounts
account/forms.py
1
7834
import re from collections import OrderedDict from django import forms from django.contrib import auth from django.contrib.auth import get_user_model from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from account.conf import settings from account.hooks import hookset f...
mit
90f697e1e4d38d379a129aa6a04f29ea
33.209607
106
0.63518
4.273868
false
false
false
false
exercism/python
exercises/concept/black-jack/.meta/exemplar.py
2
3205
"""Functions to help play and score a game of blackjack. How to play blackjack: https://bicyclecards.com/how-to-play/blackjack/ "Standard" playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck """ def value_of_card(card): """Determine the scoring value of a card. :param card: str - given car...
mit
9c4662db2c667efd4c2ad88a360aefe8
28.953271
116
0.613417
3.10562
false
false
false
false
exercism/python
exercises/concept/cater-waiter/sets_categories_data.py
2
18454
# pylint: disable-all # flake8: noqa, VEGAN = { 'chives', 'nutritional yeast', 'tomato', 'orange zest', 'pareve puff pastry', 'cashews', 'tofu', 'rice vinegar', 'black pepper', 'cardamom powder', 'mustard seeds', 'parev shortcrust pastry', 'scallions', 'water', 'chinese eggplants', 'lemon jui...
mit
4e50b483db4d314cf5a2e58c571cefdd
86.033019
121
0.582895
2.846937
false
false
true
false
hendrix/hendrix
hendrix/contrib/concurrency/resources.py
3
2381
import json import uuid from twisted.internet import threads from twisted.internet.protocol import Protocol from hendrix.facilities.resources import NamedResource from .messaging import hxdispatcher def send_django_signal(transport, data): from .signals import message_signal message_signal.send(None, dispat...
mit
ed99fe148edfe2983a36666876315fd2
29.525641
78
0.634607
4.790744
false
false
false
false
hendrix/hendrix
test/test_request_behavior.py
1
2050
import io import os import pytest_twisted import requests from twisted.internet import threads from hendrix.deploy.base import HendrixDeploy from hendrix.facilities.resources import MediaResource from .resources import application @pytest_twisted.inlineCallbacks def test_max_upload_bytes(): statics_path = 'pat...
mit
4c3f742ef029cf24c5cfb29dca2d1d94
28.285714
72
0.623902
3.831776
false
true
false
false
pastas/pastas
pastas/solver.py
1
19679
"""This module contains the different solvers that are available for Pastas. All solvers inherit from the BaseSolver class, which contains general method for selecting the correct time series to misfit and options to weight the residuals or noise series. To solve a model the following syntax can be used: >>> ml.sol...
mit
170b489f7cb6148a86e4221ba81a4e9b
35.714552
109
0.567
4.294849
false
false
false
false
pastas/pastas
pastas/stats/metrics.py
2
17960
"""The following methods may be used to describe the fit between the model simulation and the observations. Examples ======== These methods may be used as follows: >>> ps.stats.rmse(sim, obs) or >>> ml.stats.rmse() """ from logging import getLogger from numpy import abs, average, log, nan, sqrt from pastas.stats....
mit
c554a2b78b235c9fb6e2914e776d0b25
31.829982
79
0.619835
3.732696
false
false
false
false
pastas/pastas
tests/test_recharge.py
1
3575
from pandas import read_csv, Series from numpy import sin, arange, isclose import pastas as ps # Load series before rain = read_csv("tests/data/rain.csv", index_col=0, parse_dates=True).squeeze("columns").loc["2005":] * 1e3 evap = read_csv("tests/data/evap.csv", index_col=0, parse_dates...
mit
3b5ff27a10f6abe28df2338189b44f85
25.887218
78
0.607832
2.773468
false
true
false
false
pipermerriam/flex
flex/validation/parameter.py
1
5834
# Standard libraries import re from flex.datastructures import ValidationDict from flex.utils import is_non_string_iterable from flex.exceptions import ( ValidationError, MultipleParametersFound, NoParameterFound, ) from flex.error_messages import MESSAGES from flex.context_managers import ErrorDict from f...
mit
c60e27d48dcd755668356bb6a191cd21
33.116959
93
0.698149
4.311899
false
false
false
false
pipermerriam/flex
flex/loading/schema/paths/path_item/operation/responses/__init__.py
1
1191
import functools from flex.datastructures import ( ValidationDict, ValidationList, ) from flex.constants import ( OBJECT, ) from flex.validation.common import ( generate_object_validator, apply_validator_to_object, ) from flex.validation.utils import ( generate_any_validator, ) from flex.loadin...
mit
95fc39f759683331b86fb31fda38bcbe
19.894737
55
0.712007
3.97
false
false
true
false
pipermerriam/flex
flex/loading/common/single_header/__init__.py
1
2366
from flex.datastructures import ( ValidationDict, ) from flex.error_messages import ( MESSAGES, ) from flex.constants import ( OBJECT, ARRAY, EMPTY, ) from flex.exceptions import ValidationError from flex.utils import ( pluralize, ) from flex.decorators import ( pull_keys_from_obj, suffi...
mit
d842d234ace38d515d74b7c48d975b97
27.166667
91
0.751057
3.595745
false
false
false
false
pipermerriam/flex
tests/loading/schema/paths/operation/responses/test_response_validation.py
1
2139
import pytest from flex.error_messages import MESSAGES from flex.exceptions import ( ValidationError, ) from flex.loading.schema.paths.path_item.operation.responses import ( responses_validator, ) def test_description_is_required(msg_assertions): with pytest.raises(ValidationError) as err: respon...
mit
95eab451e80c622940bf32d771a4857e
23.033708
69
0.603086
4.051136
false
true
false
false
kornai/4lang
src/fourlang/longman_parser.py
3
3441
#!/usr/bin/env python # Module for reading Longman XML and producing JSON output from collections import defaultdict import json import re import sys from xml_parser import XMLParser assert json # silence pyflakes class LongmanParser(XMLParser): @staticmethod def add_suffixes(text): return re.sub...
mit
a88b9bb642ad5f8ef98bce0523efd84f
31.462264
77
0.598663
3.941581
false
false
false
false
joke2k/django-environ
docs/conf.py
1
5973
# This file is part of the django-environ. # # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> # # For the full copyright and license information, please view # the LICENSE.txt file that was distributed with this source code. # # ...
mit
34620ee0ec444d9a9e608dc5c31e1ecf
26.027149
80
0.612757
3.751884
false
false
false
false
joke2k/django-environ
environ/fileaware_mapping.py
1
3113
# This file is part of the django-environ. # # Copyright (c) 2021-2022, Serghei Iakovlev <egrep@protonmail.ch> # Copyright (c) 2013-2021, Daniele Faraglia <daniele.faraglia@gmail.com> # # For the full copyright and license information, please view # the LICENSE.txt file that was distributed with this source code. """D...
mit
27cb905a2a7ebfa7e25792b7b965e86c
32.836957
79
0.58079
4.048114
false
false
false
false
hynek/doc2dash
src/doc2dash/parsers/patcher.py
1
2074
from __future__ import annotations import logging import urllib from collections import defaultdict from pathlib import Path from typing import Generator from rich.progress import Progress from ..output import console from .types import EntryType, Parser, ParserEntry log = logging.getLogger(__name__) def patch_...
mit
faaa2cedfa0b27210f6ca067d245abf5
27.410959
78
0.547734
4.139721
false
false
false
false
hynek/doc2dash
tests/parsers/intersphinx/test_intersphinx.py
1
9429
from pathlib import Path import pytest from bs4 import BeautifulSoup from doc2dash.parsers.intersphinx import ( InterSphinxParser, _find_entry_and_add_ref, ) from doc2dash.parsers.types import EntryType, ParserEntry HERE = Path(__file__).parent class TestInterSphinxParser: def test_parses(self, sphin...
mit
a437b6170a7548fa1b7009cec6b03328
28.19195
79
0.471206
4.347165
false
true
false
false
robotpy/pyfrc
pyfrc/tests/basic.py
1
2531
""" The primary purpose of these tests is to run through your code and make sure that it doesn't crash. If you actually want to test your code, you need to write your own custom tests to tease out the edge cases. To use these, add the following to a python file in your tests directory:: ...
mit
93039b2655ba33ddbcb385a32990d1b1
30.6375
78
0.689846
3.936236
false
true
false
false
robotpy/pyfrc
pyfrc/mains/cli_sim.py
1
2510
import os from os.path import abspath, dirname import argparse import inspect import logging import pathlib from pkg_resources import iter_entry_points try: from importlib.metadata import metadata except ImportError: from importlib_metadata import metadata logger = logging.getLogger("pyfrc.sim") class PyFrc...
mit
3ee22c37c009bfbb60eccbf8240a8ca4
27.522727
79
0.556574
4.490161
false
false
false
false
alisaifee/flask-limiter
tests/test_configuration.py
1
4054
import math import time import pytest from flask import Flask from limits.errors import ConfigurationError from limits.storage import MemcachedStorage from limits.strategies import MovingWindowRateLimiter from flask_limiter import HeaderNames from flask_limiter.constants import ConfigVars from flask_limiter.extension...
mit
d38146b8ea4e21b2f8920af0e3ddf4f5
30.92126
86
0.653675
3.622878
false
true
false
false
robotpy/pyfrc
docs/conf.py
1
5080
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Imports # import sys import os from os.path import abspath, dirname # Project must be built+installed to generate docs import pyfrc import pyfrc.config pyfrc.config.config_obj["pyfrc"] = dict(game_specific_messages=[]) # -- RTD configuration ----------------------...
mit
6d5540d39a7f3c2fe7b0f961635345f0
27.700565
98
0.628937
3.799551
false
false
false
false
explosion/thinc
thinc/layers/hard_swish.py
1
2037
from typing import Tuple, Optional, Callable, cast from ..config import registry from ..model import Model from .chain import chain from .layernorm import LayerNorm from .dropout import Dropout from ..types import Floats1d, Floats2d from ..util import partial, get_width from ..initializers import he_normal_init, zero_...
mit
29524bd5cf82c59caff558ddcea23502
29.863636
87
0.628866
2.864979
false
false
false
false
explosion/thinc
thinc/tests/model/test_model.py
1
19914
from collections import Counter import pytest import threading import time from thinc.api import Adam, CupyOps, Dropout, Linear, Model, Relu from thinc.api import Shim, Softmax, chain, change_attr_values from thinc.api import concatenate, set_dropout_rate from thinc.api import use_ops, with_debug, wrap_model_recursive ...
mit
21722dcaf25664745a799c6a05abeb01
29.449541
87
0.570804
3.275868
false
true
false
false
rapptz/discord.py
examples/custom_context.py
3
1951
# This example requires the 'message_content' privileged intent to function. import random import discord from discord.ext import commands class MyContext(commands.Context): async def tick(self, value): # reacts to the message with an emoji # depending on whether value is True or False ...
mit
e827119e2432caa886da6d182b279a15
32.067797
76
0.670938
3.965447
false
false
false
false
rapptz/discord.py
discord/role.py
1
17038
""" The MIT License (MIT) Copyright (c) 2015-present Rapptz 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 use, copy, modify, merg...
mit
79e5a8e9da6487f2eb98d787f6c30f22
32.342466
114
0.599366
4.19139
false
false
false
false
rapptz/discord.py
discord/audit_logs.py
2
33755
""" The MIT License (MIT) Copyright (c) 2015-present Rapptz 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 use, copy, modify, merg...
mit
636269f57da64171e3290146e2a20163
39.964806
144
0.617953
4.014152
false
false
false
false
explosion/thinc
examples/mnist.py
2
1591
""" PyTorch version: https://github.com/pytorch/examples/blob/master/mnist/main.py TensorFlow version: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist.py """ # pip install thinc ml_datasets typer from thinc.api import Model, chain, Relu, Softmax, Adam import ml_datasets fr...
mit
893abcf5904813db69b11f27933fbb9d
32.851064
117
0.615965
3.150495
false
false
false
false
explosion/thinc
thinc/optimizers.py
1
11881
import math from typing import Dict, Optional, Union, Tuple, List, cast from collections import defaultdict from .backends import get_array_ops from .types import Generator, FloatsXd from .config import registry KeyT = Tuple[int, str] FloatOrSeq = Union[float, List[float], Generator] IntOrSeq = Union[int, List[int]...
mit
37b51889015ecc0a5c5e4d6a7874ca42
32.280112
80
0.546082
3.302112
false
false
false
false
rapptz/discord.py
discord/webhook/async_.py
1
66566
""" The MIT License (MIT) Copyright (c) 2015-present Rapptz 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 use, copy, modify, merg...
mit
abbb1ec425ea3618310245726a9712c5
32.789848
143
0.572695
4.335982
false
false
false
false
explosion/thinc
thinc/tests/layers/test_transforms.py
2
1975
from thinc.api import strings2arrays, NumpyOps, Ragged, registry import numpy import pytest from ..util import get_data_checker @pytest.fixture(params=[[], [(10, 2)], [(5, 3), (1, 3)], [(2, 3), (0, 3), (1, 3)]]) def shapes(request): return request.param @pytest.fixture def ops(): return NumpyOps() @pytes...
mit
b9ea6f1a6f790ce9f286bfa954966288
24.320513
83
0.682025
3.095611
false
true
false
false
explosion/thinc
thinc/layers/with_nvtx_range.py
2
1293
from typing import Optional, Callable, Any, Tuple, TypeVar from ..model import Model from ..util import use_nvtx_range _ModelT = TypeVar("_ModelT", bound=Model) def with_nvtx_range( layer: _ModelT, name: Optional[str] = None, *, forward_color: int = -1, backprop_color: int = -1, ) -> _ModelT: ...
mit
6eb2cd04350ddc7b8ef4d0c73c04c0b6
27.108696
79
0.622583
3.494595
false
false
false
false
b1naryth1ef/rowboat
rowboat/util/__init__.py
3
1771
from __future__ import absolute_import import re import yaml from collections import OrderedDict from datetime import datetime from gevent.local import local # Invisible space that can be used to escape mentions ZERO_WIDTH_SPACE = u'\u200B' # Replacement grave accent that can be used to escape codeblocks MODIFIER_G...
mit
97c539830ccea4243276dce2eb93b8f1
23.943662
76
0.678713
3.63655
false
false
false
false
b1naryth1ef/rowboat
rowboat/tasks/backfill.py
2
1204
from . import task, get_client from rowboat.models.message import Message from disco.types.channel import MessageIterator @task(max_concurrent=1, max_queue_size=10, global_lock=lambda guild_id: guild_id) def backfill_guild(task, guild_id): client = get_client() for channel in client.api.guilds_channels_list(g...
mit
25919fc61db65ef0858400be329de65b
34.411765
112
0.703488
3.40113
false
false
false
false
b1naryth1ef/rowboat
rowboat/plugins/infractions.py
1
26065
import csv import gevent import humanize from StringIO import StringIO from holster.emitter import Priority from datetime import datetime from disco.bot import CommandLevels from disco.types.user import User as DiscoUser from disco.types.message import MessageTable, MessageEmbed from rowboat.plugins import RowboatP...
mit
3776e80bd810e04da1e899a2e88bbc8c
37.614815
119
0.563821
3.936122
false
false
false
false
craffel/mir_eval
mir_eval/pattern.py
4
23544
""" Pattern discovery involves the identification of musical patterns (i.e. short fragments or melodic ideas that repeat at least twice) both from audio and symbolic representations. The metrics used to evaluate pattern discovery systems attempt to quantify the ability of the algorithm to not only determine the presen...
mit
05aa119780c527de8c578859941e1a7b
33.471449
84
0.619309
4.086081
false
false
false
false
craffel/mir_eval
tests/test_hierarchy.py
1
10581
''' Unit tests for mir_eval.hierarchy ''' from glob import glob import re import warnings import json import numpy as np import scipy.sparse import mir_eval from nose.tools import raises A_TOL = 1e-12 def test_tmeasure_pass(): # The estimate here gets none of the structure correct. ref = [[[0, 30]], [[0...
mit
3d95896eaaa1cb3f9a29a3144bff04fc
26.992063
76
0.489935
3.205392
false
true
false
false
craffel/mir_eval
mir_eval/key.py
1
6857
''' Key Detection involves determining the underlying key (distribution of notes and note transitions) in a piece of music. Key detection algorithms are evaluated by comparing their estimated key to a ground-truth reference key and reporting a score according to the relationship of the keys. Conventions ----------- K...
mit
0e32bf67aed1531d3ce5bdaba65bfa41
33.807107
79
0.540907
4.083979
false
false
false
false
craffel/mir_eval
mir_eval/tempo.py
1
5348
''' The goal of a tempo estimation algorithm is to automatically detect the tempo of a piece of music, measured in beats per minute (BPM). See http://www.music-ir.org/mirex/wiki/2014:Audio_Tempo_Estimation for a description of the task and evaluation criteria. Conventions ----------- Reference and estimated tempi sh...
mit
ed85adce793a9ae76ad5b90ab50b94fa
28.224044
79
0.618923
4.107527
false
false
false
false
jorvis/biocode
fasta/report_or_replace_nonstandard_residues.py
1
6164
#!/usr/bin/env python3 import argparse import sys from biocode import utils ''' Description: Some software is not written to handle the ambiguity residues defined by IUPAC. The residue "J" in a protein sequence, for example, can represent leucine or isoleucine but can cause some software to fail. You can use this...
mit
c579ca2a10a09722089aa11cd8afecf3
40.369128
237
0.652012
3.611013
false
false
false
false
jorvis/biocode
sandbox/jorvis/collapse_gene_coordinates_to_mRNA_range.py
1
2985
#!/usr/bin/env python3 ''' This script was needed when some tools (such as WebApollo) were generating gene models where the gene coordinates extended past the boundaries of the mRNA child feature, and it was required to trim them to a matching range. INPUT GFF3 The encoding convention for gene models is: Superconti...
mit
99ccb7b6157e6917ed1e1fa82407d86c
36.78481
153
0.591625
3.142105
false
false
false
false
jorvis/biocode
gff/convert_gff3_to_ncbi_tbl.py
1
3924
#!/usr/bin/env python3 """ This script can be used to transform a GFF3 file into a TBL file suitable for submitting to NCBI. Its encoding is meant to include prokaryotes and eukaryotes, though it was written/tested first for eukaryotes. Note, you'll need to modify the IDs if you're doing an update to an already exis...
mit
9f44446c567a1754c81d66d21ff0a106
39.875
148
0.681702
3.409209
false
false
false
false
jorvis/biocode
gff/convert_blast_btab_to_gff3.py
3
6536
#!/usr/bin/env python3 """ Converts the btab output of Ergatis ncbi-blast to GFF3 Example input: GluR_4 3300 BLASTN Trinity.fasta comp93586_c0_seq1 26 2208 2180 1 99.6 0.0 2139 4240 len=2337 path=[1:0-1874 1876:1875-1882 1884:1883-2336] 1 Plus 2337 ...
mit
fc36944d3c886db3b0ae8145ec9837a7
34.139785
347
0.561965
2.983113
false
false
false
false
jorvis/biocode
sandbox/jorvis/create_glimmerHMM_training_files_from_gff.py
1
2685
#!/usr/bin/env python3 """ The GlimmerHMM training documentation says that two files are needed for training. One is a multi-fasta file of what are presumably transcript sequences (this is never stated, so it could be CDS?) and the coordinates of the exons relative to the same sequences. This script generates that g...
mit
a47baf125f5849090a38ed418e5dcd26
27.870968
121
0.605587
3.824786
false
false
false
false
jorvis/biocode
fasta/fasta_size_distribution_plot.py
3
4191
#!/usr/bin/env python3 import argparse import matplotlib # back-end options are here: http://matplotlib.sourceforge.net/faq/usage_faq.html#what-is-a-backend matplotlib.use('Agg') import matplotlib.pyplot as plot import os import re def fasta_entry_sizes(file): seq_lengths = [] ## these are reset as eac...
mit
e8c64f08097679e41bf6aca3b825e8df
33.073171
124
0.59938
3.65388
false
false
false
false
jorvis/biocode
gff/report_gff3_statistics.py
1
4576
#!/usr/bin/env python3 ''' This script reports some basic statistics about a GFF3 file. It was written with an initial focus on gene-structure containing content, though can be expanded as desired. The output is a tab-delimited file where the first column is the description of a statistic and the second is the value...
mit
b649639990bb23948656e8f506959c84
37.133333
135
0.626967
3.25231
false
false
false
false
jorvis/biocode
fastq/split_interleaved_sequence_file.py
3
7623
#!/usr/bin/env python3 """ OVERVIEW Some analysis tasks produce an interleaved FASTA or FASTQ file (such as digital normalization). Use this script to split that interleaved file back out into R1, R2 and singleton files. The read mates will be kept in pairwise order within the R1 and R2 files. The -o option defines...
mit
0eff5dec60a987764b273ef2cc8f896a
31.716738
127
0.528007
3.723986
false
false
false
false
jorvis/biocode
sandbox/jorvis/generate_read_coverage_figure.py
1
4414
#!/usr/bin/env python3 """ INPUT Expected input file format (pileup): Each line consists of 5 (or optionally 6) tab-separated columns: 1. Sequence identifier 2. Position in sequence (starting from 1) 3. Reference nucleotide at that position 4. Number of aligned reads covering that position (depth of co...
mit
a3a490cbf1c31a2bfad542c009052131
34.312
183
0.662438
3.56831
false
false
false
false
jorvis/biocode
sandbox/jorvis/assign_igs_ids_from_evm_gff.py
1
4035
#!/usr/bin/env python3 """ The annotation pipeline is pretty liberal about the input molecule identifiers. Once we've reached the EVM step we assign IGS-convention identifiers. This script will export the new GFF3 file as well as a plain text file mapping the old and new IDs. INPUT ----- jcf7180000271712 EV...
mit
8bed4be0756859cb92dc6cc2eca3eda7
37.428571
153
0.590087
2.892473
false
false
false
false
jorvis/biocode
gff/replace_gff_type_column_value.py
1
1553
#!/usr/bin/env python3 """ This simple script allows you to replace the type (3rd) column in a GFF with another value. For example, WebApollo writes 'transcript' features rows, and many of our scripts assume these will be 'mRNA' instead: ./replace_gff_type_column_value.py -i in.gff -it transcript -o out.gff -ot mRNA...
mit
72e4d6735c13df4da918b4a7043c1baf
26.245614
116
0.603348
3.505643
false
false
false
false
jorvis/biocode
genbank/convert_gff3_to_gbk.py
1
7974
#!/usr/bin/env python3 """ Converts GFF3 representing gene models to Genbank flat-file format. GFF3 specification: http://www.sequenceontology.org/gff3.shtml Genbank flat file specification: https://www.ncbi.nlm.nih.gov/Sitemap/samplerecord.html --molecule_type: http://www.ncbi.nlm.nih.gov/Sequin/sequin.hlp.htm...
mit
e0c29c21ec348411f27841c97561ac9f
47.036145
243
0.664159
3.509683
false
false
false
false
jorvis/biocode
lib/biocode/annotation.py
1
19857
''' Warning: this module requires Python 3.2 or higher This is a set of classes to represent what I have most commonly needed when working on dozens (eukaryotic) or hundreds (prokaryotic) of annotation projects. If you have other attributes that you'd like to see supported, please add an 'issue' on the biocode GitHub...
mit
ce2bab2032b9c8cd9cdfdbf381303e41
45.503513
203
0.638415
3.787335
false
false
false
false
jorvis/biocode
lib/biocode/bed.py
1
4091
import sys import biocode.utils import biocode.things def print_bed_from_assemblies(assemblies=None, ofh=None): """ Utility function to write a BED file from a list() of biothings.Assembly objects. No headers are used so the output is compatible with other tools like bedToBigBed. References: ...
mit
d1a19b82fe7d70610724d6762f49c8a5
30.713178
127
0.56661
3.34232
false
false
false
false
jorvis/biocode
gff/convert_metagenemark_gff_to_gff3.py
1
7302
#!/usr/bin/env python3 import argparse import re from biocode import things ''' This script converts the GFF-ish output of Metagenemark into legal GFF3 with full, canonical gene models. http://www.sequenceontology.org/gff3.shtml EXPECTED INPUT example (the commented lines are ignored): 855 length:1510 GeneMark.hm...
mit
1059223de303d474d5f9c553cfdef940
40.488636
237
0.625308
2.846784
false
false
false
false
ginkgobioworks/edge
src/edge/south_migrations/0004_auto__chg_field_genome_parent.py
1
7758
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Changing field 'Genome.parent' db.alter_column( u"edge_geno...
mit
cc591a673ae249a27dc4f526864cbd78
36.119617
92
0.412349
4.420513
false
false
false
false
ginkgobioworks/edge
src/edge/ssr/crelox.py
1
2387
from edge.ssr import rc, lower_no_whitespace, Reaction, Integration, Excision, Inversion, RMCE class Sites(object): loxP = lower_no_whitespace("ATAACTTCGTATA GCATACAT TATACGAAGTTAT") lox66 = lower_no_whitespace("ATAACTTCGTATA GCATACAT TATACGAACGGTA") lox71 = lower_no_whitespace("TACCGTTCGTATA GCATACAT TAT...
mit
643ac372e6a6edbc223d416490329235
45.803922
98
0.653121
2.520591
false
false
false
false
ginkgobioworks/edge
src/edge/tests/test_importer.py
1
50909
# flake8: noqa import os import tempfile import unittest.mock as mock from django.test import TestCase from edge import import_gff from edge.models import Genome class ImporterTest(TestCase): def test_import_gff_procedure_creates_genome_and_annotations(self): data = """##gff-version 3 chrI\tTest\tchrom...
mit
ad49bed400bf513e61e39308c6a1daa4
46.182576
159
0.698521
2.918759
false
true
false
false
ginkgobioworks/edge
src/edge/models/genome_updater.py
1
2981
from contextlib import contextmanager from edge.models.fragment import Fragment class Genome_Updater(object): """ Mixin with helpers for updating genome. """ @contextmanager def annotate_fragment_by_name(self, name): f = [x for x in self.fragments.all() if x.name == name] if len(f...
mit
867eb981de64484cd0d6663587627a88
36.2625
86
0.588393
4.01752
false
false
false
false
ginkgobioworks/edge
src/edge/tests/test_views.py
1
43035
import json import re from django import forms from django.test import TestCase from django.urls import reverse import unittest.mock as mock from edge.models import Genome, Fragment, Genome_Fragment class GenomeListTest(TestCase): def test_empty_db(self): url = reverse("genome_list") res = self....
mit
20686ba6ba47478a6ed489fdde8928c1
35.012552
96
0.473405
3.961978
false
false
false
false
ginkgobioworks/edge
src/edge/blastdb.py
1
4077
import re import os import os.path import shutil import uuid import tempfile import subprocess from django.conf import settings from edge.blast import BLAST_DB, default_genome_db_name from edge.blast import Blast_Accession from edge.models import Fragment, Genome from edge.utils import make_required_dirs def fragme...
mit
19fcb40adf7342d520b17db17db6e992
31.616
98
0.644837
3.604775
false
false
false
false
westpa/westpa
tests/refs/odld_system.py
2
3853
import numpy as np from numpy.random import RandomState from westpa.core.binning import RectilinearBinMapper from westpa.core.propagators import WESTPropagator from westpa.core.systems import WESTSystem PI = np.pi pcoord_len = 21 pcoord_dtype = np.float32 class ODLDPropagator(WESTPropagator): def __init__(self...
mit
877f3332e2f37c70a33170ed790b718f
34.027273
127
0.593563
3.335931
false
false
false
false
westpa/westpa
src/westpa/core/propagators/__init__.py
2
2374
import westpa import itertools def blocked_iter(blocksize, iterable, fillvalue=None): # From the Python "itertools recipes" (grouper) args = [iter(iterable)] * blocksize return itertools.zip_longest(fillvalue=fillvalue, *args) class WESTPropagator: def __init__(self, rc=None): # For maximum...
mit
74a32d46362c991bd688a50ae78f366e
42.163636
123
0.686184
4.347985
false
false
false
false
westpa/westpa
src/westpa/work_managers/core.py
1
15061
# # This implementation is derived from the ``concurrent.futures`` # module of Python 3.2, by Brian Quinlan, (C) 2011 the Python Software # Foundation. See http://docs.python.org/3/license.html for more information. import logging import signal import threading import uuid from itertools import islice from contextlib ...
mit
4c65d1ecfa862b71378977c024de0c28
37.032828
129
0.60421
4.702154
false
false
false
false
westpa/westpa
src/westpa/westext/weed/weed_driver.py
1
8129
import logging import operator import numpy as np import westpa from westpa.core.yamlcfg import check_bool from westpa.core.kinetics import RateAverager from westpa.westext.weed.ProbAdjustEquil import probAdjustEquil from westpa.core._rc import bins_from_yaml_dict EPS = np.finfo(np.float64).eps log = logging.getLog...
mit
f4ec5aa878c715679c64fdf46ecc44c2
43.664835
130
0.624062
3.585796
false
true
false
false
westpa/westpa
src/westpa/cli/tools/w_assign.py
1
25946
import logging import math import os import numpy as np from numpy import index_exp from westpa.core.data_manager import seg_id_dtype, weight_dtype from westpa.core.binning import index_dtype, assign_and_label, accumulate_labeled_populations from westpa.tools import WESTParallelTool, WESTDataReader, WESTDSSynthesizer...
mit
f5a0c13b06d245dd07cd1515aea91861
42.460637
130
0.598127
4.08856
false
false
false
false
westpa/westpa
src/westpa/trajtree/trajtree.py
2
4499
import collections import numpy as np import westpa from westpa.tools.selected_segs import AllSegmentSelection from . import _trajtree from ._trajtree import _trajtree_base # @UnresolvedImport trajnode = collections.namedtuple('trajnode', ('n_iter', 'seg_id')) class TrajTreeSet(_trajtree_base): def __init__(...
mit
4ead9d93108a424bce9ad17bc073b915
36.806723
126
0.493665
3.556522
false
false
false
false
westpa/westpa
examples/ex_fluxanl_plot.py
2
1119
import argparse import h5py from matplotlib import pyplot parser = argparse.ArgumentParser(description='''Plot flux evolution obtained with w_fluxanl.''') parser.add_argument('-s', '--state', default=0, help='''Create a plot for target state index STATE (default: %(default)s)''') parser.add_argument('-i', '--input', d...
mit
faf88f34df201495591c0d8b7ca46c3d
40.444444
129
0.689008
3.09116
false
false
false
false
westpa/westpa
tests/test_tools/test_w_ipa.py
2
2590
import os import shutil from h5diff import H5Diff import unittest import pytest import argparse from unittest import mock from westpa.cli.tools.w_ipa import entry_point class Test_W_IPA(unittest.TestCase): test_name = 'W_IPA' def test_run_w_ipa(self): '''Testing if w_ipa runs as expected and the h5...
mit
e4d2bdb9ecae051efc33dc0234ef7582
35.478873
99
0.571429
3.5
false
true
false
false
westpa/westpa
src/westpa/oldtools/aframe/mcbs.py
2
5928
''' Tools for Monte Carlo bootstrap error analysis ''' import logging import math import numpy as np import westpa from westpa.oldtools.aframe import AnalysisMixin log = logging.getLogger(__name__) class MCBSMixin(AnalysisMixin): def __init__(self): super().__init__() self.mcbs_alpha = None ...
mit
cfd8561a4e3882c5bd1f576d738285be
39.60274
129
0.628036
3.661519
false
false
false
false
westpa/westpa
src/westpa/tools/iter_range.py
2
8730
import logging import numpy as np import westpa from westpa.tools.core import WESTToolComponent from westpa.core import h5io log = logging.getLogger(__name__) class IterRangeSelection(WESTToolComponent): '''Select and record limits on iterations used in analysis and/or reporting. This class provides both t...
mit
83959c9fde5e42d7bf9c041d377341e1
43.090909
141
0.627606
3.888641
false
false
false
false
jendrikseipp/vulture
vulture/noqa.py
1
1351
from collections import defaultdict import re NOQA_REGEXP = re.compile( # Use the same regex as flake8 does. # https://github.com/pycqa/flake8/blob/main/src/flake8/defaults.py # We're looking for items that look like this: # `# noqa` # `# noqa: E123` # `# noqa: E123,W451,F921` # `# NoQA: E1...
mit
4518cd43fb9352e5cd2207028b3f4344
29.704545
75
0.612139
3.149184
false
false
false
false
geopython/pywps
pywps/processing/scheduler.py
1
3108
################################################################## # Copyright 2018 Open Source Geospatial Foundation and others # # licensed under MIT, Please consult LICENSE.txt for details # ################################################################## import os import pywps.configuration as config from...
mit
c1cec57fc824d8a7981c5d917cbb752a
44.043478
112
0.553411
4.334728
false
true
false
false
geopython/pywps
pywps/tests.py
1
7593
################################################################## # Copyright 2018 Open Source Geospatial Foundation and others # # licensed under MIT, Please consult LICENSE.txt for details # ################################################################## import json import tempfile from pathlib import Path...
mit
1345dcca86c3409ba38d304b6a10d2b5
34.816038
118
0.598973
4.05609
false
false
false
false
geopython/pywps
pywps/response/basic.py
1
2117
from abc import abstractmethod from typing import TYPE_CHECKING if TYPE_CHECKING: from pywps import WPSRequest from pywps.dblog import store_status from . import RelEnvironment from .status import WPS_STATUS from pywps.translations import get_translation from jinja2 import Environment, PackageLoader import os cl...
mit
f22c600ad2b7ad409bd422c0926bafe5
31.569231
92
0.633444
4.118677
false
false
false
false
geopython/pywps
pywps/response/execute.py
1
11499
################################################################## # Copyright 2018 Open Source Geospatial Foundation and others # # licensed under MIT, Please consult LICENSE.txt for details # ################################################################## import json import logging import time from werkzeu...
mit
4ac70119a1bfea4231443860772e88f3
40.215054
117
0.574311
4.390607
false
false
false
false
geopython/pywps
pywps/app/WPSRequest.py
1
31469
################################################################## # Copyright 2018 Open Source Geospatial Foundation and others # # licensed under MIT, Please consult LICENSE.txt for details # ################################################################## import logging import lxml from pywps import xml_u...
mit
04670d006985e75a1751153550ea737a
37.802713
120
0.572246
4.134673
false
false
false
false
keon/algorithms
algorithms/queues/priority_queue.py
1
1790
""" Implementation of priority queue using linear array. Insertion - O(n) Extract min/max Node - O(1) """ import itertools class PriorityQueueNode: def __init__(self, data, priority): self.data = data self.priority = priority def __repr__(self): return "{}: {}".format(self.data, self....
mit
4940ff75f42a6fd68f25c71fcbb5ea31
31.545455
71
0.616201
4.272076
false
false
false
false
keon/algorithms
algorithms/strings/strip_url_params.py
2
3680
""" Write a function that does the following: Removes any duplicate query string parameters from the url Removes any query string parameters specified within the 2nd argument (optional array) An example: www.saadbenn.com?a=1&b=2&a=2') // returns 'www.saadbenn.com?a=1&b=2' """ from collections import defaultdict import...
mit
1f351f218b7382d4fafdb0bab6fd72ff
37.747368
86
0.480435
4.259259
false
false
false
false
keon/algorithms
algorithms/matrix/count_paths.py
2
1178
# # Count the number of unique paths from a[0][0] to a[m-1][n-1] # We are allowed to move either right or down from a cell in the matrix. # Approaches- # (i) Recursion- Recurse starting from a[m-1][n-1], upwards and leftwards, # add the path count of both recursions and return count. # (ii) Dynamic Progr...
mit
c59a18b5ae29be8f4d67c01febc2e2f6
29.205128
74
0.528014
2.997455
false
false
false
false
keon/algorithms
algorithms/strings/breaking_bad.py
2
3053
""" Given an api which returns an array of words and an array of symbols, display the word with their matched symbol surrounded by square brackets. If the word string matches more than one symbol, then choose the one with longest length. (ex. 'Microsoft' matches 'i' and 'cro'): Example: Words array: ['Amazon', 'Micro...
mit
1142d605319ab2a0b4808dcfce97b848
31.136842
82
0.562398
3.558275
false
false
false
false
keon/algorithms
algorithms/bfs/maze_search.py
1
1487
from collections import deque ''' BFS time complexity : O(|E| + |V|) BFS space complexity : O(|E| + |V|) do BFS from (0,0) of the grid and get the minimum number of steps needed to get to the lower right column only step on the columns whose value is 1 if there is no path, it returns -1 Ex 1) If grid is [[1,0,1,1,...
mit
7b1c564096eb3e661e6ef5cc20c31100
21.19403
105
0.544048
2.733456
false
false
false
false
keon/algorithms
tests/test_sort.py
1
4137
from algorithms.sort import ( bitonic_sort, bogo_sort, bubble_sort, comb_sort, counting_sort, cycle_sort, exchange_sort, max_heap_sort, min_heap_sort, merge_sort, pancake_sort, pigeonhole_sort, quick_sort, selection_sort, bucket_sort, shell_sort, radix_sor...
mit
3d6c12d0587c4f9b2029bde7f6fa23ab
30.823077
79
0.495528
3.416185
false
true
false
false
keon/algorithms
algorithms/strings/knuth_morris_pratt.py
1
1270
from typing import Sequence, List def knuth_morris_pratt(text : Sequence, pattern : Sequence) -> List[int]: """ Given two strings text and pattern, return the list of start indexes in text that matches with the pattern using knuth_morris_pratt algorithm. Args: text: Text to search patt...
mit
829a4bc8b454f3405c86183911f20e32
27.863636
110
0.530709
3.567416
false
false
false
false
keon/algorithms
algorithms/backtrack/pattern_match.py
3
1316
""" Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty substring in str. Examples: pattern = "abab", str = "redblueredblue" should return true. pattern = "aaaa", str = "asdasdasdasd" should ...
mit
c8eb385f5e6a25a593de01fd13a17ec7
30.333333
74
0.598784
3.905045
false
false
false
false
keon/algorithms
algorithms/bfs/shortest_distance_from_all_buildings.py
2
1349
import collections """ do BFS from each building, and decrement all empty place for every building visit when grid[i][j] == -b_nums, it means that grid[i][j] are already visited from all b_nums and use dist to record distances from b_nums """ def shortest_distance(grid): if not grid or not grid[0]: return...
mit
4ca9d17702b6f7a1d62523c46c42307e
32.725
88
0.525574
3.174118
false
false
false
false
keon/algorithms
algorithms/tree/max_height.py
1
1211
""" Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. """ # def max_height(root): # if not root: # return 0 # return max(maxDepth(root.left), maxDepth(root.right)) + 1 # iterative from tree ...
mit
5ffe177bfbf6ef028bc55add5ba6fd26
21.425926
63
0.58877
3.489914
false
false
false
false
keon/algorithms
algorithms/map/separate_chaining_hashtable.py
2
2380
import unittest class Node(object): def __init__(self, key=None, value=None, next=None): self.key = key self.value = value self.next = next class SeparateChainingHashTable(object): """ HashTable Data Type: By having each bucket contain a linked list of elements that are hashe...
mit
00acb1fca670d3a8b80204b31dcb8ff8
27.333333
91
0.511765
3.908046
false
false
false
false
keon/algorithms
algorithms/tree/bst/height.py
2
1441
""" Write a function height returns the height of a tree. The height is defined to be the number of levels. The empty tree has height 0, a tree of one node has height 1, a root node with one or two leaves as children has height 2, and so on For example: height of tree is 4 9 / ...
mit
18f3426298c52daf237d263762e7f0c1
23.016667
80
0.462873
4.013928
false
true
false
false
keon/algorithms
algorithms/search/jump_search.py
1
1064
""" Jump Search Find an element in a sorted array. """ import math def jump_search(arr,target): """ Worst-case Complexity: O(√n) (root(n)) All items in list must be sorted like binary search Find block that contains target value and search it linearly in that block It returns a first target valu...
mit
18b024553c76df29325699f490037417
22.6
78
0.625235
3.833935
false
false
false
false
keon/algorithms
algorithms/matrix/bomb_enemy.py
1
2560
""" Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb. The bomb kills all the enemies in the same row and column from the planted point until it hits the wall since the wall is too strong to be destroyed. Note that you ca...
mit
78ae40e23c6331653c32765c1d5ed0bc
25.122449
69
0.475391
3.043995
false
true
false
false
keon/algorithms
algorithms/strings/is_palindrome.py
1
2480
""" Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ask during an interview. F...
mit
ae88b5c17e529b0eccc05396d90661d4
22.619048
100
0.619355
3.27609
false
false
false
false