repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
SBRG/ssbio | ssbio/protein/structure/structprop.py | StructProp.find_disulfide_bridges | def find_disulfide_bridges(self, threshold=3.0):
"""Run Biopython's search_ss_bonds to find potential disulfide bridges for each chain and store in ChainProp.
Will add a list of tuple pairs into the annotations field, looks like this::
[ ((' ', 79, ' '), (' ', 110, ' ')),
(('... | python | def find_disulfide_bridges(self, threshold=3.0):
"""Run Biopython's search_ss_bonds to find potential disulfide bridges for each chain and store in ChainProp.
Will add a list of tuple pairs into the annotations field, looks like this::
[ ((' ', 79, ' '), (' ', 110, ' ')),
(('... | [
"def",
"find_disulfide_bridges",
"(",
"self",
",",
"threshold",
"=",
"3.0",
")",
":",
"if",
"self",
".",
"structure",
":",
"parsed",
"=",
"self",
".",
"structure",
"else",
":",
"parsed",
"=",
"self",
".",
"parse_structure",
"(",
")",
"if",
"not",
"parsed... | Run Biopython's search_ss_bonds to find potential disulfide bridges for each chain and store in ChainProp.
Will add a list of tuple pairs into the annotations field, looks like this::
[ ((' ', 79, ' '), (' ', 110, ' ')),
((' ', 174, ' '), (' ', 180, ' ')),
((' ', 369, '... | [
"Run",
"Biopython",
"s",
"search_ss_bonds",
"to",
"find",
"potential",
"disulfide",
"bridges",
"for",
"each",
"chain",
"and",
"store",
"in",
"ChainProp",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L319-L349 | train | 29,100 |
SBRG/ssbio | ssbio/protein/structure/structprop.py | StructProp.get_polypeptide_within | def get_polypeptide_within(self, chain_id, resnum, angstroms, only_protein=True,
use_ca=False, custom_coord=None, return_resnums=False):
"""Get a Polypeptide object of the amino acids within X angstroms of the specified chain + residue number.
Args:
resnum (in... | python | def get_polypeptide_within(self, chain_id, resnum, angstroms, only_protein=True,
use_ca=False, custom_coord=None, return_resnums=False):
"""Get a Polypeptide object of the amino acids within X angstroms of the specified chain + residue number.
Args:
resnum (in... | [
"def",
"get_polypeptide_within",
"(",
"self",
",",
"chain_id",
",",
"resnum",
",",
"angstroms",
",",
"only_protein",
"=",
"True",
",",
"use_ca",
"=",
"False",
",",
"custom_coord",
"=",
"None",
",",
"return_resnums",
"=",
"False",
")",
":",
"# XTODO: documentat... | Get a Polypeptide object of the amino acids within X angstroms of the specified chain + residue number.
Args:
resnum (int): Residue number of the structure
chain_id (str): Chain ID of the residue number
angstroms (float): Radius of the search sphere
only_protein ... | [
"Get",
"a",
"Polypeptide",
"object",
"of",
"the",
"amino",
"acids",
"within",
"X",
"angstroms",
"of",
"the",
"specified",
"chain",
"+",
"residue",
"number",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L351-L390 | train | 29,101 |
SBRG/ssbio | ssbio/protein/structure/structprop.py | StructProp.get_seqprop_within | def get_seqprop_within(self, chain_id, resnum, angstroms, only_protein=True,
use_ca=False, custom_coord=None, return_resnums=False):
"""Get a SeqProp object of the amino acids within X angstroms of the specified chain + residue number.
Args:
resnum (int): Residue ... | python | def get_seqprop_within(self, chain_id, resnum, angstroms, only_protein=True,
use_ca=False, custom_coord=None, return_resnums=False):
"""Get a SeqProp object of the amino acids within X angstroms of the specified chain + residue number.
Args:
resnum (int): Residue ... | [
"def",
"get_seqprop_within",
"(",
"self",
",",
"chain_id",
",",
"resnum",
",",
"angstroms",
",",
"only_protein",
"=",
"True",
",",
"use_ca",
"=",
"False",
",",
"custom_coord",
"=",
"None",
",",
"return_resnums",
"=",
"False",
")",
":",
"# XTODO: change \"remov... | Get a SeqProp object of the amino acids within X angstroms of the specified chain + residue number.
Args:
resnum (int): Residue number of the structure
chain_id (str): Chain ID of the residue number
angstroms (float): Radius of the search sphere
only_protein (boo... | [
"Get",
"a",
"SeqProp",
"object",
"of",
"the",
"amino",
"acids",
"within",
"X",
"angstroms",
"of",
"the",
"specified",
"chain",
"+",
"residue",
"number",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L392-L422 | train | 29,102 |
SBRG/ssbio | ssbio/protein/structure/structprop.py | StructProp.get_dssp_annotations | def get_dssp_annotations(self, outdir, force_rerun=False):
"""Run DSSP on this structure and store the DSSP annotations in the corresponding ChainProp SeqRecords
Calculations are stored in the ChainProp's ``letter_annotations`` at the following keys:
* ``SS-dssp``
* ``RSA-dssp`... | python | def get_dssp_annotations(self, outdir, force_rerun=False):
"""Run DSSP on this structure and store the DSSP annotations in the corresponding ChainProp SeqRecords
Calculations are stored in the ChainProp's ``letter_annotations`` at the following keys:
* ``SS-dssp``
* ``RSA-dssp`... | [
"def",
"get_dssp_annotations",
"(",
"self",
",",
"outdir",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"self",
".",
"structure",
":",
"parsed",
"=",
"self",
".",
"structure",
"else",
":",
"parsed",
"=",
"self",
".",
"parse_structure",
"(",
")",
"if... | Run DSSP on this structure and store the DSSP annotations in the corresponding ChainProp SeqRecords
Calculations are stored in the ChainProp's ``letter_annotations`` at the following keys:
* ``SS-dssp``
* ``RSA-dssp``
* ``ASA-dssp``
* ``PHI-dssp``
* ... | [
"Run",
"DSSP",
"on",
"this",
"structure",
"and",
"store",
"the",
"DSSP",
"annotations",
"in",
"the",
"corresponding",
"ChainProp",
"SeqRecords"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L424-L499 | train | 29,103 |
SBRG/ssbio | ssbio/protein/structure/structprop.py | StructProp.get_freesasa_annotations | def get_freesasa_annotations(self, outdir, include_hetatms=False, force_rerun=False):
"""Run ``freesasa`` on this structure and store the calculated properties in the corresponding ChainProps
"""
if self.file_type != 'pdb':
log.error('{}: unable to run freesasa with "{}" file type. P... | python | def get_freesasa_annotations(self, outdir, include_hetatms=False, force_rerun=False):
"""Run ``freesasa`` on this structure and store the calculated properties in the corresponding ChainProps
"""
if self.file_type != 'pdb':
log.error('{}: unable to run freesasa with "{}" file type. P... | [
"def",
"get_freesasa_annotations",
"(",
"self",
",",
"outdir",
",",
"include_hetatms",
"=",
"False",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"self",
".",
"file_type",
"!=",
"'pdb'",
":",
"log",
".",
"error",
"(",
"'{}: unable to run freesasa with \"{}\... | Run ``freesasa`` on this structure and store the calculated properties in the corresponding ChainProps | [
"Run",
"freesasa",
"on",
"this",
"structure",
"and",
"store",
"the",
"calculated",
"properties",
"in",
"the",
"corresponding",
"ChainProps"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L548-L618 | train | 29,104 |
SBRG/ssbio | ssbio/protein/structure/structprop.py | StructProp.view_structure | def view_structure(self, only_chains=None, opacity=1.0, recolor=False, gui=False):
"""Use NGLviewer to display a structure in a Jupyter notebook
Args:
only_chains (str, list): Chain ID or IDs to display
opacity (float): Opacity of the structure
recolor (bool): If str... | python | def view_structure(self, only_chains=None, opacity=1.0, recolor=False, gui=False):
"""Use NGLviewer to display a structure in a Jupyter notebook
Args:
only_chains (str, list): Chain ID or IDs to display
opacity (float): Opacity of the structure
recolor (bool): If str... | [
"def",
"view_structure",
"(",
"self",
",",
"only_chains",
"=",
"None",
",",
"opacity",
"=",
"1.0",
",",
"recolor",
"=",
"False",
",",
"gui",
"=",
"False",
")",
":",
"# TODO: show_structure_file does not work for MMTF files - need to check for that and load accordingly",
... | Use NGLviewer to display a structure in a Jupyter notebook
Args:
only_chains (str, list): Chain ID or IDs to display
opacity (float): Opacity of the structure
recolor (bool): If structure should be cleaned and recolored to silver
gui (bool): If the NGLview GUI sh... | [
"Use",
"NGLviewer",
"to",
"display",
"a",
"structure",
"in",
"a",
"Jupyter",
"notebook"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L620-L666 | train | 29,105 |
SBRG/ssbio | ssbio/protein/sequence/properties/tmhmm.py | label_TM_tmhmm_residue_numbers_and_leaflets | def label_TM_tmhmm_residue_numbers_and_leaflets(tmhmm_seq):
"""Determine the residue numbers of the TM-helix residues that cross the membrane and label them by leaflet.
Args:
tmhmm_seq: g.protein.representative_sequence.seq_record.letter_annotations['TM-tmhmm']
Returns:
leaflet_dict: a dic... | python | def label_TM_tmhmm_residue_numbers_and_leaflets(tmhmm_seq):
"""Determine the residue numbers of the TM-helix residues that cross the membrane and label them by leaflet.
Args:
tmhmm_seq: g.protein.representative_sequence.seq_record.letter_annotations['TM-tmhmm']
Returns:
leaflet_dict: a dic... | [
"def",
"label_TM_tmhmm_residue_numbers_and_leaflets",
"(",
"tmhmm_seq",
")",
":",
"TM_number_dict",
"=",
"{",
"}",
"T_index",
"=",
"[",
"]",
"T_residue",
"=",
"[",
"]",
"residue_count",
"=",
"1",
"for",
"residue_label",
"in",
"tmhmm_seq",
":",
"if",
"residue_lab... | Determine the residue numbers of the TM-helix residues that cross the membrane and label them by leaflet.
Args:
tmhmm_seq: g.protein.representative_sequence.seq_record.letter_annotations['TM-tmhmm']
Returns:
leaflet_dict: a dictionary with leaflet_variable : [residue list] where the variable i... | [
"Determine",
"the",
"residue",
"numbers",
"of",
"the",
"TM",
"-",
"helix",
"residues",
"that",
"cross",
"the",
"membrane",
"and",
"label",
"them",
"by",
"leaflet",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/tmhmm.py#L101-L169 | train | 29,106 |
SBRG/ssbio | ssbio/protein/sequence/properties/residues.py | biopython_protein_scale | def biopython_protein_scale(inseq, scale, custom_scale_dict=None, window=7):
"""Use Biopython to calculate properties using a sliding window over a sequence given a specific scale to use."""
if scale == 'kd_hydrophobicity':
scale_dict = kd_hydrophobicity_one
elif scale == 'bulkiness':
scale... | python | def biopython_protein_scale(inseq, scale, custom_scale_dict=None, window=7):
"""Use Biopython to calculate properties using a sliding window over a sequence given a specific scale to use."""
if scale == 'kd_hydrophobicity':
scale_dict = kd_hydrophobicity_one
elif scale == 'bulkiness':
scale... | [
"def",
"biopython_protein_scale",
"(",
"inseq",
",",
"scale",
",",
"custom_scale_dict",
"=",
"None",
",",
"window",
"=",
"7",
")",
":",
"if",
"scale",
"==",
"'kd_hydrophobicity'",
":",
"scale_dict",
"=",
"kd_hydrophobicity_one",
"elif",
"scale",
"==",
"'bulkines... | Use Biopython to calculate properties using a sliding window over a sequence given a specific scale to use. | [
"Use",
"Biopython",
"to",
"calculate",
"properties",
"using",
"a",
"sliding",
"window",
"over",
"a",
"sequence",
"given",
"a",
"specific",
"scale",
"to",
"use",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/residues.py#L113-L134 | train | 29,107 |
SBRG/ssbio | ssbio/protein/sequence/properties/residues.py | biopython_protein_analysis | def biopython_protein_analysis(inseq):
"""Utiize Biopython's ProteinAnalysis module to return general sequence properties of an amino acid string.
For full definitions see: http://biopython.org/DIST/docs/api/Bio.SeqUtils.ProtParam.ProteinAnalysis-class.html
Args:
inseq: Amino acid sequence
Re... | python | def biopython_protein_analysis(inseq):
"""Utiize Biopython's ProteinAnalysis module to return general sequence properties of an amino acid string.
For full definitions see: http://biopython.org/DIST/docs/api/Bio.SeqUtils.ProtParam.ProteinAnalysis-class.html
Args:
inseq: Amino acid sequence
Re... | [
"def",
"biopython_protein_analysis",
"(",
"inseq",
")",
":",
"inseq",
"=",
"ssbio",
".",
"protein",
".",
"sequence",
".",
"utils",
".",
"cast_to_str",
"(",
"inseq",
")",
"analysed_seq",
"=",
"ProteinAnalysis",
"(",
"inseq",
")",
"info_dict",
"=",
"{",
"}",
... | Utiize Biopython's ProteinAnalysis module to return general sequence properties of an amino acid string.
For full definitions see: http://biopython.org/DIST/docs/api/Bio.SeqUtils.ProtParam.ProteinAnalysis-class.html
Args:
inseq: Amino acid sequence
Returns:
dict: Dictionary of sequence pr... | [
"Utiize",
"Biopython",
"s",
"ProteinAnalysis",
"module",
"to",
"return",
"general",
"sequence",
"properties",
"of",
"an",
"amino",
"acid",
"string",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/residues.py#L137-L180 | train | 29,108 |
SBRG/ssbio | ssbio/protein/sequence/properties/residues.py | emboss_pepstats_on_fasta | def emboss_pepstats_on_fasta(infile, outfile='', outdir='', outext='.pepstats', force_rerun=False):
"""Run EMBOSS pepstats on a FASTA file.
Args:
infile: Path to FASTA file
outfile: Name of output file without extension
outdir: Path to output directory
outext: Extension of resul... | python | def emboss_pepstats_on_fasta(infile, outfile='', outdir='', outext='.pepstats', force_rerun=False):
"""Run EMBOSS pepstats on a FASTA file.
Args:
infile: Path to FASTA file
outfile: Name of output file without extension
outdir: Path to output directory
outext: Extension of resul... | [
"def",
"emboss_pepstats_on_fasta",
"(",
"infile",
",",
"outfile",
"=",
"''",
",",
"outdir",
"=",
"''",
",",
"outext",
"=",
"'.pepstats'",
",",
"force_rerun",
"=",
"False",
")",
":",
"# Create the output file name",
"outfile",
"=",
"ssbio",
".",
"utils",
".",
... | Run EMBOSS pepstats on a FASTA file.
Args:
infile: Path to FASTA file
outfile: Name of output file without extension
outdir: Path to output directory
outext: Extension of results file, default is ".pepstats"
force_rerun: Flag to rerun pepstats
Returns:
str: Path... | [
"Run",
"EMBOSS",
"pepstats",
"on",
"a",
"FASTA",
"file",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/residues.py#L183-L207 | train | 29,109 |
SBRG/ssbio | ssbio/protein/sequence/properties/residues.py | emboss_pepstats_parser | def emboss_pepstats_parser(infile):
"""Get dictionary of pepstats results.
Args:
infile: Path to pepstats outfile
Returns:
dict: Parsed information from pepstats
TODO:
Only currently parsing the bottom of the file for percentages of properties.
"""
with open(infile) a... | python | def emboss_pepstats_parser(infile):
"""Get dictionary of pepstats results.
Args:
infile: Path to pepstats outfile
Returns:
dict: Parsed information from pepstats
TODO:
Only currently parsing the bottom of the file for percentages of properties.
"""
with open(infile) a... | [
"def",
"emboss_pepstats_parser",
"(",
"infile",
")",
":",
"with",
"open",
"(",
"infile",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"read",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"info_dict",
"=",
"{",
"}",
"for",
"l",
"in",
"lines",
"[",
"... | Get dictionary of pepstats results.
Args:
infile: Path to pepstats outfile
Returns:
dict: Parsed information from pepstats
TODO:
Only currently parsing the bottom of the file for percentages of properties. | [
"Get",
"dictionary",
"of",
"pepstats",
"results",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/residues.py#L210-L237 | train | 29,110 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS.load_strain | def load_strain(self, strain_id, strain_genome_file):
"""Load a strain as a new GEM-PRO by its ID and associated genome file. Stored in the ``strains`` attribute.
Args:
strain_id (str): Strain ID
strain_genome_file (str): Path to strain genome file
"""
# logging... | python | def load_strain(self, strain_id, strain_genome_file):
"""Load a strain as a new GEM-PRO by its ID and associated genome file. Stored in the ``strains`` attribute.
Args:
strain_id (str): Strain ID
strain_genome_file (str): Path to strain genome file
"""
# logging... | [
"def",
"load_strain",
"(",
"self",
",",
"strain_id",
",",
"strain_genome_file",
")",
":",
"# logging.disable(logging.WARNING)",
"strain_gp",
"=",
"GEMPRO",
"(",
"gem_name",
"=",
"strain_id",
",",
"genome_path",
"=",
"strain_genome_file",
",",
"write_protein_fasta_files"... | Load a strain as a new GEM-PRO by its ID and associated genome file. Stored in the ``strains`` attribute.
Args:
strain_id (str): Strain ID
strain_genome_file (str): Path to strain genome file | [
"Load",
"a",
"strain",
"as",
"a",
"new",
"GEM",
"-",
"PRO",
"by",
"its",
"ID",
"and",
"associated",
"genome",
"file",
".",
"Stored",
"in",
"the",
"strains",
"attribute",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L212-L225 | train | 29,111 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS.download_patric_genomes | def download_patric_genomes(self, ids, force_rerun=False):
"""Download genome files from PATRIC given a list of PATRIC genome IDs and load them as strains.
Args:
ids (str, list): PATRIC ID or list of PATRIC IDs
force_rerun (bool): If genome files should be downloaded again even ... | python | def download_patric_genomes(self, ids, force_rerun=False):
"""Download genome files from PATRIC given a list of PATRIC genome IDs and load them as strains.
Args:
ids (str, list): PATRIC ID or list of PATRIC IDs
force_rerun (bool): If genome files should be downloaded again even ... | [
"def",
"download_patric_genomes",
"(",
"self",
",",
"ids",
",",
"force_rerun",
"=",
"False",
")",
":",
"ids",
"=",
"ssbio",
".",
"utils",
".",
"force_list",
"(",
"ids",
")",
"counter",
"=",
"0",
"log",
".",
"info",
"(",
"'Downloading sequences from PATRIC...... | Download genome files from PATRIC given a list of PATRIC genome IDs and load them as strains.
Args:
ids (str, list): PATRIC ID or list of PATRIC IDs
force_rerun (bool): If genome files should be downloaded again even if they exist | [
"Download",
"genome",
"files",
"from",
"PATRIC",
"given",
"a",
"list",
"of",
"PATRIC",
"genome",
"IDs",
"and",
"load",
"them",
"as",
"strains",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L227-L250 | train | 29,112 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS._pare_down_model | def _pare_down_model(self, strain_gempro, genes_to_remove):
"""Mark genes as non-functional in a GEM-PRO. If there is a COBRApy model associated with it, the
COBRApy method delete_model_genes is utilized to delete genes.
Args:
strain_gempro (GEMPRO): GEMPRO object
ge... | python | def _pare_down_model(self, strain_gempro, genes_to_remove):
"""Mark genes as non-functional in a GEM-PRO. If there is a COBRApy model associated with it, the
COBRApy method delete_model_genes is utilized to delete genes.
Args:
strain_gempro (GEMPRO): GEMPRO object
ge... | [
"def",
"_pare_down_model",
"(",
"self",
",",
"strain_gempro",
",",
"genes_to_remove",
")",
":",
"# Filter out genes in genes_to_remove which do not show up in the model",
"strain_genes",
"=",
"[",
"x",
".",
"id",
"for",
"x",
"in",
"strain_gempro",
".",
"genes",
"]",
"... | Mark genes as non-functional in a GEM-PRO. If there is a COBRApy model associated with it, the
COBRApy method delete_model_genes is utilized to delete genes.
Args:
strain_gempro (GEMPRO): GEMPRO object
genes_to_remove (list): List of gene IDs to remove from the model | [
"Mark",
"genes",
"as",
"non",
"-",
"functional",
"in",
"a",
"GEM",
"-",
"PRO",
".",
"If",
"there",
"is",
"a",
"COBRApy",
"model",
"associated",
"with",
"it",
"the",
"COBRApy",
"method",
"delete_model_genes",
"is",
"utilized",
"to",
"delete",
"genes",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L418-L455 | train | 29,113 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS._load_strain_sequences | def _load_strain_sequences(self, strain_gempro):
"""Load strain sequences from the orthology matrix into the base model for comparisons, and into the
strain-specific model itself.
"""
if self._orthology_matrix_has_sequences: # Load directly from the orthology matrix if it contains sequ... | python | def _load_strain_sequences(self, strain_gempro):
"""Load strain sequences from the orthology matrix into the base model for comparisons, and into the
strain-specific model itself.
"""
if self._orthology_matrix_has_sequences: # Load directly from the orthology matrix if it contains sequ... | [
"def",
"_load_strain_sequences",
"(",
"self",
",",
"strain_gempro",
")",
":",
"if",
"self",
".",
"_orthology_matrix_has_sequences",
":",
"# Load directly from the orthology matrix if it contains sequences",
"strain_sequences",
"=",
"self",
".",
"df_orthology_matrix",
"[",
"st... | Load strain sequences from the orthology matrix into the base model for comparisons, and into the
strain-specific model itself. | [
"Load",
"strain",
"sequences",
"from",
"the",
"orthology",
"matrix",
"into",
"the",
"base",
"model",
"for",
"comparisons",
"and",
"into",
"the",
"strain",
"-",
"specific",
"model",
"itself",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L457-L491 | train | 29,114 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS.build_strain_specific_models | def build_strain_specific_models(self, save_models=False):
"""Using the orthologous genes matrix, create and modify the strain specific models based on if orthologous
genes exist.
Also store the sequences directly in the reference GEM-PRO protein sequence attribute for the strains.
... | python | def build_strain_specific_models(self, save_models=False):
"""Using the orthologous genes matrix, create and modify the strain specific models based on if orthologous
genes exist.
Also store the sequences directly in the reference GEM-PRO protein sequence attribute for the strains.
... | [
"def",
"build_strain_specific_models",
"(",
"self",
",",
"save_models",
"=",
"False",
")",
":",
"if",
"len",
"(",
"self",
".",
"df_orthology_matrix",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"'Empty orthology matrix'",
")",
"# Create an emptied copy of the... | Using the orthologous genes matrix, create and modify the strain specific models based on if orthologous
genes exist.
Also store the sequences directly in the reference GEM-PRO protein sequence attribute for the strains. | [
"Using",
"the",
"orthologous",
"genes",
"matrix",
"create",
"and",
"modify",
"the",
"strain",
"specific",
"models",
"based",
"on",
"if",
"orthologous",
"genes",
"exist",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L493-L530 | train | 29,115 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS.align_orthologous_genes_pairwise | def align_orthologous_genes_pairwise(self, gapopen=10, gapextend=0.5):
"""For each gene in the base strain, run a pairwise alignment for all orthologous gene sequences to it."""
for ref_gene in tqdm(self.reference_gempro.genes):
if len(ref_gene.protein.sequences) > 1:
alignme... | python | def align_orthologous_genes_pairwise(self, gapopen=10, gapextend=0.5):
"""For each gene in the base strain, run a pairwise alignment for all orthologous gene sequences to it."""
for ref_gene in tqdm(self.reference_gempro.genes):
if len(ref_gene.protein.sequences) > 1:
alignme... | [
"def",
"align_orthologous_genes_pairwise",
"(",
"self",
",",
"gapopen",
"=",
"10",
",",
"gapextend",
"=",
"0.5",
")",
":",
"for",
"ref_gene",
"in",
"tqdm",
"(",
"self",
".",
"reference_gempro",
".",
"genes",
")",
":",
"if",
"len",
"(",
"ref_gene",
".",
"... | For each gene in the base strain, run a pairwise alignment for all orthologous gene sequences to it. | [
"For",
"each",
"gene",
"in",
"the",
"base",
"strain",
"run",
"a",
"pairwise",
"alignment",
"for",
"all",
"orthologous",
"gene",
"sequences",
"to",
"it",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L532-L540 | train | 29,116 |
SBRG/ssbio | ssbio/pipeline/atlas.py | ATLAS.get_atlas_per_gene_mutation_df | def get_atlas_per_gene_mutation_df(self, gene_id):
"""Create a single data frame which summarizes a gene and its mutations.
Args:
gene_id (str): Gene ID in the base model
Returns:
DataFrame: Pandas DataFrame of the results
"""
# TODO: also count: number... | python | def get_atlas_per_gene_mutation_df(self, gene_id):
"""Create a single data frame which summarizes a gene and its mutations.
Args:
gene_id (str): Gene ID in the base model
Returns:
DataFrame: Pandas DataFrame of the results
"""
# TODO: also count: number... | [
"def",
"get_atlas_per_gene_mutation_df",
"(",
"self",
",",
"gene_id",
")",
":",
"# TODO: also count: number of unique mutations (have to consider position, amino acid change)",
"# TODO: keep track of strain with most mutations, least mutations",
"# TODO: keep track of strains that conserve the l... | Create a single data frame which summarizes a gene and its mutations.
Args:
gene_id (str): Gene ID in the base model
Returns:
DataFrame: Pandas DataFrame of the results | [
"Create",
"a",
"single",
"data",
"frame",
"which",
"summarizes",
"a",
"gene",
"and",
"its",
"mutations",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas.py#L701-L799 | train | 29,117 |
SBRG/ssbio | ssbio/viz/nglview.py | add_residues_highlight_to_nglview | def add_residues_highlight_to_nglview(view, structure_resnums, chain, res_color='red'):
"""Add a residue number or numbers to an NGLWidget view object.
Args:
view (NGLWidget): NGLWidget view object
structure_resnums (int, list): Residue number(s) to highlight, structure numbering
chain ... | python | def add_residues_highlight_to_nglview(view, structure_resnums, chain, res_color='red'):
"""Add a residue number or numbers to an NGLWidget view object.
Args:
view (NGLWidget): NGLWidget view object
structure_resnums (int, list): Residue number(s) to highlight, structure numbering
chain ... | [
"def",
"add_residues_highlight_to_nglview",
"(",
"view",
",",
"structure_resnums",
",",
"chain",
",",
"res_color",
"=",
"'red'",
")",
":",
"chain",
"=",
"ssbio",
".",
"utils",
".",
"force_list",
"(",
"chain",
")",
"if",
"isinstance",
"(",
"structure_resnums",
... | Add a residue number or numbers to an NGLWidget view object.
Args:
view (NGLWidget): NGLWidget view object
structure_resnums (int, list): Residue number(s) to highlight, structure numbering
chain (str, list): Chain ID or IDs of which residues are a part of. If not provided, all chains in th... | [
"Add",
"a",
"residue",
"number",
"or",
"numbers",
"to",
"an",
"NGLWidget",
"view",
"object",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/viz/nglview.py#L7-L41 | train | 29,118 |
SBRG/ssbio | ssbio/databases/kegg.py | download_kegg_gene_metadata | def download_kegg_gene_metadata(gene_id, outdir=None, force_rerun=False):
"""Download the KEGG flatfile for a KEGG ID and return the path.
Args:
gene_id: KEGG gene ID (with organism code), i.e. "eco:1244"
outdir: optional output directory of metadata
Returns:
Path to metadata file
... | python | def download_kegg_gene_metadata(gene_id, outdir=None, force_rerun=False):
"""Download the KEGG flatfile for a KEGG ID and return the path.
Args:
gene_id: KEGG gene ID (with organism code), i.e. "eco:1244"
outdir: optional output directory of metadata
Returns:
Path to metadata file
... | [
"def",
"download_kegg_gene_metadata",
"(",
"gene_id",
",",
"outdir",
"=",
"None",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"not",
"outdir",
":",
"outdir",
"=",
"''",
"# Replace colon with dash in the KEGG gene ID",
"outfile",
"=",
"op",
".",
"join",
"("... | Download the KEGG flatfile for a KEGG ID and return the path.
Args:
gene_id: KEGG gene ID (with organism code), i.e. "eco:1244"
outdir: optional output directory of metadata
Returns:
Path to metadata file | [
"Download",
"the",
"KEGG",
"flatfile",
"for",
"a",
"KEGG",
"ID",
"and",
"return",
"the",
"path",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/databases/kegg.py#L74-L103 | train | 29,119 |
SBRG/ssbio | ssbio/databases/kegg.py | parse_kegg_gene_metadata | def parse_kegg_gene_metadata(infile):
"""Parse the KEGG flatfile and return a dictionary of metadata.
Dictionary keys are:
refseq
uniprot
pdbs
taxonomy
Args:
infile: Path to KEGG flatfile
Returns:
dict: Dictionary of metadata
"""
metadata = def... | python | def parse_kegg_gene_metadata(infile):
"""Parse the KEGG flatfile and return a dictionary of metadata.
Dictionary keys are:
refseq
uniprot
pdbs
taxonomy
Args:
infile: Path to KEGG flatfile
Returns:
dict: Dictionary of metadata
"""
metadata = def... | [
"def",
"parse_kegg_gene_metadata",
"(",
"infile",
")",
":",
"metadata",
"=",
"defaultdict",
"(",
"str",
")",
"with",
"open",
"(",
"infile",
")",
"as",
"mf",
":",
"kegg_parsed",
"=",
"bs_kegg",
".",
"parse",
"(",
"mf",
".",
"read",
"(",
")",
")",
"# TOD... | Parse the KEGG flatfile and return a dictionary of metadata.
Dictionary keys are:
refseq
uniprot
pdbs
taxonomy
Args:
infile: Path to KEGG flatfile
Returns:
dict: Dictionary of metadata | [
"Parse",
"the",
"KEGG",
"flatfile",
"and",
"return",
"a",
"dictionary",
"of",
"metadata",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/databases/kegg.py#L106-L146 | train | 29,120 |
SBRG/ssbio | ssbio/databases/kegg.py | map_kegg_all_genes | def map_kegg_all_genes(organism_code, target_db):
"""Map all of an organism's gene IDs to the target database.
This is faster than supplying a specific list of genes to map,
plus there seems to be a limit on the number you can map with a manual REST query anyway.
Args:
organism_code: the three... | python | def map_kegg_all_genes(organism_code, target_db):
"""Map all of an organism's gene IDs to the target database.
This is faster than supplying a specific list of genes to map,
plus there seems to be a limit on the number you can map with a manual REST query anyway.
Args:
organism_code: the three... | [
"def",
"map_kegg_all_genes",
"(",
"organism_code",
",",
"target_db",
")",
":",
"mapping",
"=",
"bs_kegg",
".",
"conv",
"(",
"target_db",
",",
"organism_code",
")",
"# strip the organism code from the keys and the identifier in the values",
"new_mapping",
"=",
"{",
"}",
... | Map all of an organism's gene IDs to the target database.
This is faster than supplying a specific list of genes to map,
plus there seems to be a limit on the number you can map with a manual REST query anyway.
Args:
organism_code: the three letter KEGG code of your organism
target_db: ncb... | [
"Map",
"all",
"of",
"an",
"organism",
"s",
"gene",
"IDs",
"to",
"the",
"target",
"database",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/databases/kegg.py#L180-L201 | train | 29,121 |
SBRG/ssbio | ssbio/protein/structure/homology/itasser/itasserprep.py | ITASSERPrep.prep_folder | def prep_folder(self, seq):
"""Take in a sequence string and prepares the folder for the I-TASSER run."""
itasser_dir = op.join(self.root_dir, self.id)
if not op.exists(itasser_dir):
os.makedirs(itasser_dir)
tmp = {self.id: seq}
fasta.write_fasta_file_from_dict(ind... | python | def prep_folder(self, seq):
"""Take in a sequence string and prepares the folder for the I-TASSER run."""
itasser_dir = op.join(self.root_dir, self.id)
if not op.exists(itasser_dir):
os.makedirs(itasser_dir)
tmp = {self.id: seq}
fasta.write_fasta_file_from_dict(ind... | [
"def",
"prep_folder",
"(",
"self",
",",
"seq",
")",
":",
"itasser_dir",
"=",
"op",
".",
"join",
"(",
"self",
".",
"root_dir",
",",
"self",
".",
"id",
")",
"if",
"not",
"op",
".",
"exists",
"(",
"itasser_dir",
")",
":",
"os",
".",
"makedirs",
"(",
... | Take in a sequence string and prepares the folder for the I-TASSER run. | [
"Take",
"in",
"a",
"sequence",
"string",
"and",
"prepares",
"the",
"folder",
"for",
"the",
"I",
"-",
"TASSER",
"run",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/homology/itasser/itasserprep.py#L107-L120 | train | 29,122 |
SBRG/ssbio | ssbio/protein/sequence/utils/blast.py | run_makeblastdb | def run_makeblastdb(infile, dbtype, outdir=''):
"""Make the BLAST database for a genome file.
Args:
infile (str): path to genome FASTA file
dbtype (str): "nucl" or "prot" - what format your genome files are in
outdir (str): path to directory to output database files (default is original... | python | def run_makeblastdb(infile, dbtype, outdir=''):
"""Make the BLAST database for a genome file.
Args:
infile (str): path to genome FASTA file
dbtype (str): "nucl" or "prot" - what format your genome files are in
outdir (str): path to directory to output database files (default is original... | [
"def",
"run_makeblastdb",
"(",
"infile",
",",
"dbtype",
",",
"outdir",
"=",
"''",
")",
":",
"# TODO: add force_rerun option",
"# TODO: rewrite using utils function command",
"# Output location",
"og_dir",
",",
"name",
",",
"ext",
"=",
"utils",
".",
"split_folder_and_pat... | Make the BLAST database for a genome file.
Args:
infile (str): path to genome FASTA file
dbtype (str): "nucl" or "prot" - what format your genome files are in
outdir (str): path to directory to output database files (default is original folder)
Returns:
Paths to BLAST databases... | [
"Make",
"the",
"BLAST",
"database",
"for",
"a",
"genome",
"file",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/blast.py#L24-L68 | train | 29,123 |
SBRG/ssbio | ssbio/protein/sequence/utils/blast.py | run_bidirectional_blast | def run_bidirectional_blast(reference, other_genome, dbtype, outdir=''):
"""BLAST a genome against another, and vice versa.
This function requires BLAST to be installed, do so by running:
sudo apt install ncbi-blast+
Args:
reference (str): path to "reference" genome, aka your "base strain"
... | python | def run_bidirectional_blast(reference, other_genome, dbtype, outdir=''):
"""BLAST a genome against another, and vice versa.
This function requires BLAST to be installed, do so by running:
sudo apt install ncbi-blast+
Args:
reference (str): path to "reference" genome, aka your "base strain"
... | [
"def",
"run_bidirectional_blast",
"(",
"reference",
",",
"other_genome",
",",
"dbtype",
",",
"outdir",
"=",
"''",
")",
":",
"# TODO: add force_rerun option",
"if",
"dbtype",
"==",
"'nucl'",
":",
"command",
"=",
"'blastn'",
"elif",
"dbtype",
"==",
"'prot'",
":",
... | BLAST a genome against another, and vice versa.
This function requires BLAST to be installed, do so by running:
sudo apt install ncbi-blast+
Args:
reference (str): path to "reference" genome, aka your "base strain"
other_genome (str): path to other genome which will be BLASTed to the refer... | [
"BLAST",
"a",
"genome",
"against",
"another",
"and",
"vice",
"versa",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/blast.py#L71-L132 | train | 29,124 |
SBRG/ssbio | ssbio/protein/sequence/utils/blast.py | print_run_bidirectional_blast | def print_run_bidirectional_blast(reference, other_genome, dbtype, outdir):
"""Write torque submission files for running bidirectional blast on a server and print execution command.
Args:
reference (str): Path to "reference" genome, aka your "base strain"
other_genome (str): Path to other genom... | python | def print_run_bidirectional_blast(reference, other_genome, dbtype, outdir):
"""Write torque submission files for running bidirectional blast on a server and print execution command.
Args:
reference (str): Path to "reference" genome, aka your "base strain"
other_genome (str): Path to other genom... | [
"def",
"print_run_bidirectional_blast",
"(",
"reference",
",",
"other_genome",
",",
"dbtype",
",",
"outdir",
")",
":",
"# TODO: add force_rerun option",
"if",
"dbtype",
"==",
"'nucl'",
":",
"command",
"=",
"'blastn'",
"elif",
"dbtype",
"==",
"'prot'",
":",
"comman... | Write torque submission files for running bidirectional blast on a server and print execution command.
Args:
reference (str): Path to "reference" genome, aka your "base strain"
other_genome (str): Path to other genome which will be BLASTed to the reference
dbtype (str): "nucl" or "prot" - w... | [
"Write",
"torque",
"submission",
"files",
"for",
"running",
"bidirectional",
"blast",
"on",
"a",
"server",
"and",
"print",
"execution",
"command",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/blast.py#L135-L177 | train | 29,125 |
SBRG/ssbio | ssbio/protein/structure/utils/structureio.py | StructureIO.write_pdb | def write_pdb(self, custom_name='', out_suffix='', out_dir=None, custom_selection=None, force_rerun=False):
"""Write a new PDB file for the Structure's FIRST MODEL.
Set custom_selection to a PDB.Select class for custom SMCRA selections.
Args:
custom_name: Filename of the new file (... | python | def write_pdb(self, custom_name='', out_suffix='', out_dir=None, custom_selection=None, force_rerun=False):
"""Write a new PDB file for the Structure's FIRST MODEL.
Set custom_selection to a PDB.Select class for custom SMCRA selections.
Args:
custom_name: Filename of the new file (... | [
"def",
"write_pdb",
"(",
"self",
",",
"custom_name",
"=",
"''",
",",
"out_suffix",
"=",
"''",
",",
"out_dir",
"=",
"None",
",",
"custom_selection",
"=",
"None",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"not",
"custom_selection",
":",
"custom_selec... | Write a new PDB file for the Structure's FIRST MODEL.
Set custom_selection to a PDB.Select class for custom SMCRA selections.
Args:
custom_name: Filename of the new file (without extension)
out_suffix: Optional string to append to new PDB file
out_dir: Optional dire... | [
"Write",
"a",
"new",
"PDB",
"file",
"for",
"the",
"Structure",
"s",
"FIRST",
"MODEL",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/utils/structureio.py#L80-L119 | train | 29,126 |
SBRG/ssbio | ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py | XMLParser._handle_builder_exception | def _handle_builder_exception(self, message, residue):
"""
Makes a PDB Construction Error a bit more verbose and informative
"""
message = "%s. Error when parsing residue %s:%s" %(message, residue['number'], residue['name'])
raise PDBConstructionException(messag... | python | def _handle_builder_exception(self, message, residue):
"""
Makes a PDB Construction Error a bit more verbose and informative
"""
message = "%s. Error when parsing residue %s:%s" %(message, residue['number'], residue['name'])
raise PDBConstructionException(messag... | [
"def",
"_handle_builder_exception",
"(",
"self",
",",
"message",
",",
"residue",
")",
":",
"message",
"=",
"\"%s. Error when parsing residue %s:%s\"",
"%",
"(",
"message",
",",
"residue",
"[",
"'number'",
"]",
",",
"residue",
"[",
"'name'",
"]",
")",
"raise",
... | Makes a PDB Construction Error a bit more verbose and informative | [
"Makes",
"a",
"PDB",
"Construction",
"Error",
"a",
"bit",
"more",
"verbose",
"and",
"informative"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py#L72-L79 | train | 29,127 |
SBRG/ssbio | ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py | XMLParser._parse | def _parse(self):
"""
Parse atomic data of the XML file.
"""
atom_counter = 0
structure_build = self.structure_builder
residues = self._extract_residues()
cur_model = None
cur_chain = None
structure_build.init_se... | python | def _parse(self):
"""
Parse atomic data of the XML file.
"""
atom_counter = 0
structure_build = self.structure_builder
residues = self._extract_residues()
cur_model = None
cur_chain = None
structure_build.init_se... | [
"def",
"_parse",
"(",
"self",
")",
":",
"atom_counter",
"=",
"0",
"structure_build",
"=",
"self",
".",
"structure_builder",
"residues",
"=",
"self",
".",
"_extract_residues",
"(",
")",
"cur_model",
"=",
"None",
"cur_chain",
"=",
"None",
"structure_build",
".",... | Parse atomic data of the XML file. | [
"Parse",
"atomic",
"data",
"of",
"the",
"XML",
"file",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py#L81-L182 | train | 29,128 |
SBRG/ssbio | ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py | XMLParser._extract_residues | def _extract_residues(self):
"""
WHAT IF puts terminal atoms in new residues at the end for some reason..
"""
r_list = self.handle.getElementsByTagName("response")
r_data = {}
for r in r_list:
data = self._parse_residue(r)
... | python | def _extract_residues(self):
"""
WHAT IF puts terminal atoms in new residues at the end for some reason..
"""
r_list = self.handle.getElementsByTagName("response")
r_data = {}
for r in r_list:
data = self._parse_residue(r)
... | [
"def",
"_extract_residues",
"(",
"self",
")",
":",
"r_list",
"=",
"self",
".",
"handle",
".",
"getElementsByTagName",
"(",
"\"response\"",
")",
"r_data",
"=",
"{",
"}",
"for",
"r",
"in",
"r_list",
":",
"data",
"=",
"self",
".",
"_parse_residue",
"(",
"r"... | WHAT IF puts terminal atoms in new residues at the end for some reason.. | [
"WHAT",
"IF",
"puts",
"terminal",
"atoms",
"in",
"new",
"residues",
"at",
"the",
"end",
"for",
"some",
"reason",
".."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py#L187-L205 | train | 29,129 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | calculate_residue_counts_perstrain | def calculate_residue_counts_perstrain(protein_pickle_path, outdir, pdbflex_keys_file, wt_pid_cutoff=None, force_rerun=False):
"""Writes out a feather file for a PROTEIN counting amino acid occurences for ALL STRAINS along with SUBSEQUENCES"""
from collections import defaultdict
from ssbio.protein.sequence.... | python | def calculate_residue_counts_perstrain(protein_pickle_path, outdir, pdbflex_keys_file, wt_pid_cutoff=None, force_rerun=False):
"""Writes out a feather file for a PROTEIN counting amino acid occurences for ALL STRAINS along with SUBSEQUENCES"""
from collections import defaultdict
from ssbio.protein.sequence.... | [
"def",
"calculate_residue_counts_perstrain",
"(",
"protein_pickle_path",
",",
"outdir",
",",
"pdbflex_keys_file",
",",
"wt_pid_cutoff",
"=",
"None",
",",
"force_rerun",
"=",
"False",
")",
":",
"from",
"collections",
"import",
"defaultdict",
"from",
"ssbio",
".",
"pr... | Writes out a feather file for a PROTEIN counting amino acid occurences for ALL STRAINS along with SUBSEQUENCES | [
"Writes",
"out",
"a",
"feather",
"file",
"for",
"a",
"PROTEIN",
"counting",
"amino",
"acid",
"occurences",
"for",
"ALL",
"STRAINS",
"along",
"with",
"SUBSEQUENCES"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L722-L785 | train | 29,130 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.filter_genes_and_strains | def filter_genes_and_strains(self, remove_genes_not_in_reference_model=True,
remove_strains_with_no_orthology=True, remove_strains_with_no_differences=False,
custom_keep_strains=None, custom_keep_genes=None):
"""Filters the analysis by keeping a ... | python | def filter_genes_and_strains(self, remove_genes_not_in_reference_model=True,
remove_strains_with_no_orthology=True, remove_strains_with_no_differences=False,
custom_keep_strains=None, custom_keep_genes=None):
"""Filters the analysis by keeping a ... | [
"def",
"filter_genes_and_strains",
"(",
"self",
",",
"remove_genes_not_in_reference_model",
"=",
"True",
",",
"remove_strains_with_no_orthology",
"=",
"True",
",",
"remove_strains_with_no_differences",
"=",
"False",
",",
"custom_keep_strains",
"=",
"None",
",",
"custom_keep... | Filters the analysis by keeping a subset of strains or genes based on certain criteria.
Args:
remove_genes_not_in_reference_model (bool): Remove genes from reference model not in orthology matrix
remove_strains_with_no_orthology (bool): Remove strains which have no orthologous genes fou... | [
"Filters",
"the",
"analysis",
"by",
"keeping",
"a",
"subset",
"of",
"strains",
"or",
"genes",
"based",
"on",
"certain",
"criteria",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L242-L310 | train | 29,131 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2._write_strain_functional_genes | def _write_strain_functional_genes(self, strain_id, ref_functional_genes, orth_matrix, force_rerun=False):
"""Create strain functional genes json file"""
func_genes_path = op.join(self.model_dir, '{}_funcgenes.json'.format(strain_id))
if ssbio.utils.force_rerun(flag=force_rerun, outfile=func_ge... | python | def _write_strain_functional_genes(self, strain_id, ref_functional_genes, orth_matrix, force_rerun=False):
"""Create strain functional genes json file"""
func_genes_path = op.join(self.model_dir, '{}_funcgenes.json'.format(strain_id))
if ssbio.utils.force_rerun(flag=force_rerun, outfile=func_ge... | [
"def",
"_write_strain_functional_genes",
"(",
"self",
",",
"strain_id",
",",
"ref_functional_genes",
",",
"orth_matrix",
",",
"force_rerun",
"=",
"False",
")",
":",
"func_genes_path",
"=",
"op",
".",
"join",
"(",
"self",
".",
"model_dir",
",",
"'{}_funcgenes.json'... | Create strain functional genes json file | [
"Create",
"strain",
"functional",
"genes",
"json",
"file"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L312-L334 | train | 29,132 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.write_strain_functional_genes | def write_strain_functional_genes(self, force_rerun=False):
"""Wrapper function for _write_strain_functional_genes"""
if len(self.df_orthology_matrix) == 0:
raise RuntimeError('Empty orthology matrix, please calculate first!')
ref_functional_genes = [g.id for g in self.reference_gemp... | python | def write_strain_functional_genes(self, force_rerun=False):
"""Wrapper function for _write_strain_functional_genes"""
if len(self.df_orthology_matrix) == 0:
raise RuntimeError('Empty orthology matrix, please calculate first!')
ref_functional_genes = [g.id for g in self.reference_gemp... | [
"def",
"write_strain_functional_genes",
"(",
"self",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"len",
"(",
"self",
".",
"df_orthology_matrix",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"'Empty orthology matrix, please calculate first!'",
")",
"ref_f... | Wrapper function for _write_strain_functional_genes | [
"Wrapper",
"function",
"for",
"_write_strain_functional_genes"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L336-L347 | train | 29,133 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2._build_strain_specific_model | def _build_strain_specific_model(self, strain_id, ref_functional_genes, orth_matrix, force_rerun=False):
"""Create strain GEMPRO, set functional genes"""
gp_noseqs_path = op.join(self.model_dir, '{}_gp.pckl'.format(strain_id))
if ssbio.utils.force_rerun(flag=force_rerun, outfile=gp_noseqs_path)... | python | def _build_strain_specific_model(self, strain_id, ref_functional_genes, orth_matrix, force_rerun=False):
"""Create strain GEMPRO, set functional genes"""
gp_noseqs_path = op.join(self.model_dir, '{}_gp.pckl'.format(strain_id))
if ssbio.utils.force_rerun(flag=force_rerun, outfile=gp_noseqs_path)... | [
"def",
"_build_strain_specific_model",
"(",
"self",
",",
"strain_id",
",",
"ref_functional_genes",
",",
"orth_matrix",
",",
"force_rerun",
"=",
"False",
")",
":",
"gp_noseqs_path",
"=",
"op",
".",
"join",
"(",
"self",
".",
"model_dir",
",",
"'{}_gp.pckl'",
".",
... | Create strain GEMPRO, set functional genes | [
"Create",
"strain",
"GEMPRO",
"set",
"functional",
"genes"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L349-L388 | train | 29,134 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.build_strain_specific_models | def build_strain_specific_models(self, joblib=False, cores=1, force_rerun=False):
"""Wrapper function for _build_strain_specific_model"""
if len(self.df_orthology_matrix) == 0:
raise RuntimeError('Empty orthology matrix, please calculate first!')
ref_functional_genes = [g.id for g in... | python | def build_strain_specific_models(self, joblib=False, cores=1, force_rerun=False):
"""Wrapper function for _build_strain_specific_model"""
if len(self.df_orthology_matrix) == 0:
raise RuntimeError('Empty orthology matrix, please calculate first!')
ref_functional_genes = [g.id for g in... | [
"def",
"build_strain_specific_models",
"(",
"self",
",",
"joblib",
"=",
"False",
",",
"cores",
"=",
"1",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"len",
"(",
"self",
".",
"df_orthology_matrix",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
... | Wrapper function for _build_strain_specific_model | [
"Wrapper",
"function",
"for",
"_build_strain_specific_model"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L390-L407 | train | 29,135 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2._load_sequences_to_strain | def _load_sequences_to_strain(self, strain_id, force_rerun=False):
"""Load strain GEMPRO with functional genes defined, load sequences to it, save as new GEMPRO"""
gp_seqs_path = op.join(self.model_dir, '{}_gp_withseqs.pckl'.format(strain_id))
if ssbio.utils.force_rerun(flag=force_rerun, outfil... | python | def _load_sequences_to_strain(self, strain_id, force_rerun=False):
"""Load strain GEMPRO with functional genes defined, load sequences to it, save as new GEMPRO"""
gp_seqs_path = op.join(self.model_dir, '{}_gp_withseqs.pckl'.format(strain_id))
if ssbio.utils.force_rerun(flag=force_rerun, outfil... | [
"def",
"_load_sequences_to_strain",
"(",
"self",
",",
"strain_id",
",",
"force_rerun",
"=",
"False",
")",
":",
"gp_seqs_path",
"=",
"op",
".",
"join",
"(",
"self",
".",
"model_dir",
",",
"'{}_gp_withseqs.pckl'",
".",
"format",
"(",
"strain_id",
")",
")",
"if... | Load strain GEMPRO with functional genes defined, load sequences to it, save as new GEMPRO | [
"Load",
"strain",
"GEMPRO",
"with",
"functional",
"genes",
"defined",
"load",
"sequences",
"to",
"it",
"save",
"as",
"new",
"GEMPRO"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L409-L427 | train | 29,136 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.load_sequences_to_strains | def load_sequences_to_strains(self, joblib=False, cores=1, force_rerun=False):
"""Wrapper function for _load_sequences_to_strain"""
log.info('Loading sequences to strain GEM-PROs...')
if joblib:
result = DictList(Parallel(n_jobs=cores)(delayed(self._load_sequences_to_strain)(s, force... | python | def load_sequences_to_strains(self, joblib=False, cores=1, force_rerun=False):
"""Wrapper function for _load_sequences_to_strain"""
log.info('Loading sequences to strain GEM-PROs...')
if joblib:
result = DictList(Parallel(n_jobs=cores)(delayed(self._load_sequences_to_strain)(s, force... | [
"def",
"load_sequences_to_strains",
"(",
"self",
",",
"joblib",
"=",
"False",
",",
"cores",
"=",
"1",
",",
"force_rerun",
"=",
"False",
")",
":",
"log",
".",
"info",
"(",
"'Loading sequences to strain GEM-PROs...'",
")",
"if",
"joblib",
":",
"result",
"=",
"... | Wrapper function for _load_sequences_to_strain | [
"Wrapper",
"function",
"for",
"_load_sequences_to_strain"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L429-L440 | train | 29,137 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2._load_sequences_to_reference_gene | def _load_sequences_to_reference_gene(self, g_id, force_rerun=False):
"""Load orthologous strain sequences to reference Protein object, save as new pickle"""
protein_seqs_pickle_path = op.join(self.sequences_by_gene_dir, '{}_protein_withseqs.pckl'.format(g_id))
if ssbio.utils.force_rerun(flag=f... | python | def _load_sequences_to_reference_gene(self, g_id, force_rerun=False):
"""Load orthologous strain sequences to reference Protein object, save as new pickle"""
protein_seqs_pickle_path = op.join(self.sequences_by_gene_dir, '{}_protein_withseqs.pckl'.format(g_id))
if ssbio.utils.force_rerun(flag=f... | [
"def",
"_load_sequences_to_reference_gene",
"(",
"self",
",",
"g_id",
",",
"force_rerun",
"=",
"False",
")",
":",
"protein_seqs_pickle_path",
"=",
"op",
".",
"join",
"(",
"self",
".",
"sequences_by_gene_dir",
",",
"'{}_protein_withseqs.pckl'",
".",
"format",
"(",
... | Load orthologous strain sequences to reference Protein object, save as new pickle | [
"Load",
"orthologous",
"strain",
"sequences",
"to",
"reference",
"Protein",
"object",
"save",
"as",
"new",
"pickle"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L442-L464 | train | 29,138 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.load_sequences_to_reference | def load_sequences_to_reference(self, sc=None, force_rerun=False):
"""Wrapper for _load_sequences_to_reference_gene"""
log.info('Loading sequences to reference GEM-PRO...')
from random import shuffle
g_ids = [g.id for g in self.reference_gempro.functional_genes]
shuffle(g_ids)
... | python | def load_sequences_to_reference(self, sc=None, force_rerun=False):
"""Wrapper for _load_sequences_to_reference_gene"""
log.info('Loading sequences to reference GEM-PRO...')
from random import shuffle
g_ids = [g.id for g in self.reference_gempro.functional_genes]
shuffle(g_ids)
... | [
"def",
"load_sequences_to_reference",
"(",
"self",
",",
"sc",
"=",
"None",
",",
"force_rerun",
"=",
"False",
")",
":",
"log",
".",
"info",
"(",
"'Loading sequences to reference GEM-PRO...'",
")",
"from",
"random",
"import",
"shuffle",
"g_ids",
"=",
"[",
"g",
"... | Wrapper for _load_sequences_to_reference_gene | [
"Wrapper",
"for",
"_load_sequences_to_reference_gene"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L466-L522 | train | 29,139 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.store_disorder | def store_disorder(self, sc=None, force_rerun=False):
"""Wrapper for _store_disorder"""
log.info('Loading sequences to reference GEM-PRO...')
from random import shuffle
g_ids = [g.id for g in self.reference_gempro.functional_genes]
shuffle(g_ids)
def _store_disorder_sc(g... | python | def store_disorder(self, sc=None, force_rerun=False):
"""Wrapper for _store_disorder"""
log.info('Loading sequences to reference GEM-PRO...')
from random import shuffle
g_ids = [g.id for g in self.reference_gempro.functional_genes]
shuffle(g_ids)
def _store_disorder_sc(g... | [
"def",
"store_disorder",
"(",
"self",
",",
"sc",
"=",
"None",
",",
"force_rerun",
"=",
"False",
")",
":",
"log",
".",
"info",
"(",
"'Loading sequences to reference GEM-PRO...'",
")",
"from",
"random",
"import",
"shuffle",
"g_ids",
"=",
"[",
"g",
".",
"id",
... | Wrapper for _store_disorder | [
"Wrapper",
"for",
"_store_disorder"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L524-L558 | train | 29,140 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2._align_orthologous_gene_pairwise | def _align_orthologous_gene_pairwise(self, g_id, gapopen=10, gapextend=0.5, engine='needle', parse=True, force_rerun=False):
"""Align orthologous strain sequences to representative Protein sequence, save as new pickle"""
protein_seqs_aln_pickle_path = op.join(self.sequences_by_gene_dir, '{}_protein_with... | python | def _align_orthologous_gene_pairwise(self, g_id, gapopen=10, gapextend=0.5, engine='needle', parse=True, force_rerun=False):
"""Align orthologous strain sequences to representative Protein sequence, save as new pickle"""
protein_seqs_aln_pickle_path = op.join(self.sequences_by_gene_dir, '{}_protein_with... | [
"def",
"_align_orthologous_gene_pairwise",
"(",
"self",
",",
"g_id",
",",
"gapopen",
"=",
"10",
",",
"gapextend",
"=",
"0.5",
",",
"engine",
"=",
"'needle'",
",",
"parse",
"=",
"True",
",",
"force_rerun",
"=",
"False",
")",
":",
"protein_seqs_aln_pickle_path",... | Align orthologous strain sequences to representative Protein sequence, save as new pickle | [
"Align",
"orthologous",
"strain",
"sequences",
"to",
"representative",
"Protein",
"sequence",
"save",
"as",
"new",
"pickle"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L560-L583 | train | 29,141 |
SBRG/ssbio | ssbio/pipeline/atlas2.py | ATLAS2.align_orthologous_genes_pairwise | def align_orthologous_genes_pairwise(self, sc=None, joblib=False, cores=1, gapopen=10, gapextend=0.5,
engine='needle', parse=True, force_rerun=False):
"""Wrapper for _align_orthologous_gene_pairwise"""
log.info('Aligning sequences to reference GEM-PRO...')
... | python | def align_orthologous_genes_pairwise(self, sc=None, joblib=False, cores=1, gapopen=10, gapextend=0.5,
engine='needle', parse=True, force_rerun=False):
"""Wrapper for _align_orthologous_gene_pairwise"""
log.info('Aligning sequences to reference GEM-PRO...')
... | [
"def",
"align_orthologous_genes_pairwise",
"(",
"self",
",",
"sc",
"=",
"None",
",",
"joblib",
"=",
"False",
",",
"cores",
"=",
"1",
",",
"gapopen",
"=",
"10",
",",
"gapextend",
"=",
"0.5",
",",
"engine",
"=",
"'needle'",
",",
"parse",
"=",
"True",
","... | Wrapper for _align_orthologous_gene_pairwise | [
"Wrapper",
"for",
"_align_orthologous_gene_pairwise"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/atlas2.py#L585-L636 | train | 29,142 |
SBRG/ssbio | ssbio/protein/sequence/utils/utils.py | cast_to_str | def cast_to_str(obj):
"""Return a string representation of a Seq or SeqRecord.
Args:
obj (str, Seq, SeqRecord): Biopython Seq or SeqRecord
Returns:
str: String representation of the sequence
"""
if isinstance(obj, str):
return obj
if isinstance(obj, Seq):
retu... | python | def cast_to_str(obj):
"""Return a string representation of a Seq or SeqRecord.
Args:
obj (str, Seq, SeqRecord): Biopython Seq or SeqRecord
Returns:
str: String representation of the sequence
"""
if isinstance(obj, str):
return obj
if isinstance(obj, Seq):
retu... | [
"def",
"cast_to_str",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"str",
")",
":",
"return",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"Seq",
")",
":",
"return",
"str",
"(",
"obj",
")",
"if",
"isinstance",
"(",
"obj",
",",
"SeqReco... | Return a string representation of a Seq or SeqRecord.
Args:
obj (str, Seq, SeqRecord): Biopython Seq or SeqRecord
Returns:
str: String representation of the sequence | [
"Return",
"a",
"string",
"representation",
"of",
"a",
"Seq",
"or",
"SeqRecord",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/utils.py#L6-L24 | train | 29,143 |
SBRG/ssbio | ssbio/protein/sequence/utils/utils.py | cast_to_seq | def cast_to_seq(obj, alphabet=IUPAC.extended_protein):
"""Return a Seq representation of a string or SeqRecord object.
Args:
obj (str, Seq, SeqRecord): Sequence string or Biopython SeqRecord object
alphabet: See Biopython SeqRecord docs
Returns:
Seq: Seq representation of the seque... | python | def cast_to_seq(obj, alphabet=IUPAC.extended_protein):
"""Return a Seq representation of a string or SeqRecord object.
Args:
obj (str, Seq, SeqRecord): Sequence string or Biopython SeqRecord object
alphabet: See Biopython SeqRecord docs
Returns:
Seq: Seq representation of the seque... | [
"def",
"cast_to_seq",
"(",
"obj",
",",
"alphabet",
"=",
"IUPAC",
".",
"extended_protein",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Seq",
")",
":",
"return",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"SeqRecord",
")",
":",
"return",
"obj",
".",... | Return a Seq representation of a string or SeqRecord object.
Args:
obj (str, Seq, SeqRecord): Sequence string or Biopython SeqRecord object
alphabet: See Biopython SeqRecord docs
Returns:
Seq: Seq representation of the sequence | [
"Return",
"a",
"Seq",
"representation",
"of",
"a",
"string",
"or",
"SeqRecord",
"object",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/utils.py#L27-L47 | train | 29,144 |
SBRG/ssbio | ssbio/protein/sequence/utils/utils.py | cast_to_seq_record | def cast_to_seq_record(obj, alphabet=IUPAC.extended_protein, id="<unknown id>", name="<unknown name>",
description="<unknown description>", dbxrefs=None,
features=None, annotations=None,
letter_annotations=None):
"""Return a SeqRecord representati... | python | def cast_to_seq_record(obj, alphabet=IUPAC.extended_protein, id="<unknown id>", name="<unknown name>",
description="<unknown description>", dbxrefs=None,
features=None, annotations=None,
letter_annotations=None):
"""Return a SeqRecord representati... | [
"def",
"cast_to_seq_record",
"(",
"obj",
",",
"alphabet",
"=",
"IUPAC",
".",
"extended_protein",
",",
"id",
"=",
"\"<unknown id>\"",
",",
"name",
"=",
"\"<unknown name>\"",
",",
"description",
"=",
"\"<unknown description>\"",
",",
"dbxrefs",
"=",
"None",
",",
"... | Return a SeqRecord representation of a string or Seq object.
Args:
obj (str, Seq, SeqRecord): Sequence string or Biopython Seq object
alphabet: See Biopython SeqRecord docs
id: See Biopython SeqRecord docs
name: See Biopython SeqRecord docs
description: See Biopython SeqReco... | [
"Return",
"a",
"SeqRecord",
"representation",
"of",
"a",
"string",
"or",
"Seq",
"object",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/utils.py#L50-L80 | train | 29,145 |
SBRG/ssbio | ssbio/protein/sequence/utils/fasta.py | write_fasta_file | def write_fasta_file(seq_records, outname, outdir=None, outext='.faa', force_rerun=False):
"""Write a FASTA file for a SeqRecord or a list of SeqRecord objects.
Args:
seq_records (SeqRecord, list): SeqRecord or a list of SeqRecord objects
outname: Name of the output file which will have outext ... | python | def write_fasta_file(seq_records, outname, outdir=None, outext='.faa', force_rerun=False):
"""Write a FASTA file for a SeqRecord or a list of SeqRecord objects.
Args:
seq_records (SeqRecord, list): SeqRecord or a list of SeqRecord objects
outname: Name of the output file which will have outext ... | [
"def",
"write_fasta_file",
"(",
"seq_records",
",",
"outname",
",",
"outdir",
"=",
"None",
",",
"outext",
"=",
"'.faa'",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"not",
"outdir",
":",
"outdir",
"=",
"''",
"outfile",
"=",
"ssbio",
".",
"utils",
... | Write a FASTA file for a SeqRecord or a list of SeqRecord objects.
Args:
seq_records (SeqRecord, list): SeqRecord or a list of SeqRecord objects
outname: Name of the output file which will have outext appended to it
outdir: Path to directory to output sequences to
outext: Extension ... | [
"Write",
"a",
"FASTA",
"file",
"for",
"a",
"SeqRecord",
"or",
"a",
"list",
"of",
"SeqRecord",
"objects",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/fasta.py#L9-L31 | train | 29,146 |
SBRG/ssbio | ssbio/protein/sequence/utils/fasta.py | write_fasta_file_from_dict | def write_fasta_file_from_dict(indict, outname, outdir=None, outext='.faa', force_rerun=False):
"""Write a FASTA file for a dictionary of IDs and their sequence strings.
Args:
indict: Input dictionary with keys as IDs and values as sequence strings
outname: Name of the output file which will ha... | python | def write_fasta_file_from_dict(indict, outname, outdir=None, outext='.faa', force_rerun=False):
"""Write a FASTA file for a dictionary of IDs and their sequence strings.
Args:
indict: Input dictionary with keys as IDs and values as sequence strings
outname: Name of the output file which will ha... | [
"def",
"write_fasta_file_from_dict",
"(",
"indict",
",",
"outname",
",",
"outdir",
"=",
"None",
",",
"outext",
"=",
"'.faa'",
",",
"force_rerun",
"=",
"False",
")",
":",
"if",
"not",
"outdir",
":",
"outdir",
"=",
"''",
"outfile",
"=",
"ssbio",
".",
"util... | Write a FASTA file for a dictionary of IDs and their sequence strings.
Args:
indict: Input dictionary with keys as IDs and values as sequence strings
outname: Name of the output file which will have outext appended to it
outdir: Path to directory to output sequences to
outext: Exten... | [
"Write",
"a",
"FASTA",
"file",
"for",
"a",
"dictionary",
"of",
"IDs",
"and",
"their",
"sequence",
"strings",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/fasta.py#L34-L60 | train | 29,147 |
SBRG/ssbio | ssbio/protein/sequence/utils/fasta.py | write_seq_as_temp_fasta | def write_seq_as_temp_fasta(seq):
"""Write a sequence as a temporary FASTA file
Args:
seq (str, Seq, SeqRecord): Sequence string, Biopython Seq or SeqRecord object
Returns:
str: Path to temporary FASTA file (located in system temporary files directory)
"""
sr = ssbio.protein.seque... | python | def write_seq_as_temp_fasta(seq):
"""Write a sequence as a temporary FASTA file
Args:
seq (str, Seq, SeqRecord): Sequence string, Biopython Seq or SeqRecord object
Returns:
str: Path to temporary FASTA file (located in system temporary files directory)
"""
sr = ssbio.protein.seque... | [
"def",
"write_seq_as_temp_fasta",
"(",
"seq",
")",
":",
"sr",
"=",
"ssbio",
".",
"protein",
".",
"sequence",
".",
"utils",
".",
"cast_to_seq_record",
"(",
"seq",
",",
"id",
"=",
"'tempfasta'",
")",
"return",
"write_fasta_file",
"(",
"seq_records",
"=",
"sr",... | Write a sequence as a temporary FASTA file
Args:
seq (str, Seq, SeqRecord): Sequence string, Biopython Seq or SeqRecord object
Returns:
str: Path to temporary FASTA file (located in system temporary files directory) | [
"Write",
"a",
"sequence",
"as",
"a",
"temporary",
"FASTA",
"file"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/fasta.py#L63-L74 | train | 29,148 |
SBRG/ssbio | ssbio/protein/sequence/utils/fasta.py | load_fasta_file | def load_fasta_file(filename):
"""Load a FASTA file and return the sequences as a list of SeqRecords
Args:
filename (str): Path to the FASTA file to load
Returns:
list: list of all sequences in the FASTA file as Biopython SeqRecord objects
"""
with open(filename, "r") as handle:
... | python | def load_fasta_file(filename):
"""Load a FASTA file and return the sequences as a list of SeqRecords
Args:
filename (str): Path to the FASTA file to load
Returns:
list: list of all sequences in the FASTA file as Biopython SeqRecord objects
"""
with open(filename, "r") as handle:
... | [
"def",
"load_fasta_file",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"handle",
":",
"records",
"=",
"list",
"(",
"SeqIO",
".",
"parse",
"(",
"handle",
",",
"\"fasta\"",
")",
")",
"return",
"records"
] | Load a FASTA file and return the sequences as a list of SeqRecords
Args:
filename (str): Path to the FASTA file to load
Returns:
list: list of all sequences in the FASTA file as Biopython SeqRecord objects | [
"Load",
"a",
"FASTA",
"file",
"and",
"return",
"the",
"sequences",
"as",
"a",
"list",
"of",
"SeqRecords"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/fasta.py#L77-L90 | train | 29,149 |
SBRG/ssbio | ssbio/protein/sequence/utils/fasta.py | fasta_files_equal | def fasta_files_equal(seq_file1, seq_file2):
"""Check equality of a FASTA file to another FASTA file
Args:
seq_file1: Path to a FASTA file
seq_file2: Path to another FASTA file
Returns:
bool: If the sequences are the same
"""
# Load already set representative sequence
... | python | def fasta_files_equal(seq_file1, seq_file2):
"""Check equality of a FASTA file to another FASTA file
Args:
seq_file1: Path to a FASTA file
seq_file2: Path to another FASTA file
Returns:
bool: If the sequences are the same
"""
# Load already set representative sequence
... | [
"def",
"fasta_files_equal",
"(",
"seq_file1",
",",
"seq_file2",
")",
":",
"# Load already set representative sequence",
"seq1",
"=",
"SeqIO",
".",
"read",
"(",
"open",
"(",
"seq_file1",
")",
",",
"'fasta'",
")",
"# Load kegg sequence",
"seq2",
"=",
"SeqIO",
".",
... | Check equality of a FASTA file to another FASTA file
Args:
seq_file1: Path to a FASTA file
seq_file2: Path to another FASTA file
Returns:
bool: If the sequences are the same | [
"Check",
"equality",
"of",
"a",
"FASTA",
"file",
"to",
"another",
"FASTA",
"file"
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/fasta.py#L131-L153 | train | 29,150 |
SBRG/ssbio | ssbio/biopython/Bio/Struct/Protein.py | Protein.from_structure | def from_structure(cls, original, filter_residues):
"""
Loads structure as a protein, exposing
protein-specific methods.
"""
P = cls(original.id)
P.full_id = original.full_id
for child in original.child_dict.values():
copycat = deepcopy(child)... | python | def from_structure(cls, original, filter_residues):
"""
Loads structure as a protein, exposing
protein-specific methods.
"""
P = cls(original.id)
P.full_id = original.full_id
for child in original.child_dict.values():
copycat = deepcopy(child)... | [
"def",
"from_structure",
"(",
"cls",
",",
"original",
",",
"filter_residues",
")",
":",
"P",
"=",
"cls",
"(",
"original",
".",
"id",
")",
"P",
".",
"full_id",
"=",
"original",
".",
"full_id",
"for",
"child",
"in",
"original",
".",
"child_dict",
".",
"v... | Loads structure as a protein, exposing
protein-specific methods. | [
"Loads",
"structure",
"as",
"a",
"protein",
"exposing",
"protein",
"-",
"specific",
"methods",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/Protein.py#L18-L49 | train | 29,151 |
SBRG/ssbio | ssbio/protein/sequence/properties/aggregation_propensity.py | AMYLPRED.get_aggregation_propensity | def get_aggregation_propensity(self, seq, outdir, cutoff_v=5, cutoff_n=5, run_amylmuts=False):
"""Run the AMYLPRED2 web server for a protein sequence and get the consensus result for aggregation propensity.
Args:
seq (str, Seq, SeqRecord): Amino acid sequence
outdir (str): Direc... | python | def get_aggregation_propensity(self, seq, outdir, cutoff_v=5, cutoff_n=5, run_amylmuts=False):
"""Run the AMYLPRED2 web server for a protein sequence and get the consensus result for aggregation propensity.
Args:
seq (str, Seq, SeqRecord): Amino acid sequence
outdir (str): Direc... | [
"def",
"get_aggregation_propensity",
"(",
"self",
",",
"seq",
",",
"outdir",
",",
"cutoff_v",
"=",
"5",
",",
"cutoff_n",
"=",
"5",
",",
"run_amylmuts",
"=",
"False",
")",
":",
"seq",
"=",
"ssbio",
".",
"protein",
".",
"sequence",
".",
"utils",
".",
"ca... | Run the AMYLPRED2 web server for a protein sequence and get the consensus result for aggregation propensity.
Args:
seq (str, Seq, SeqRecord): Amino acid sequence
outdir (str): Directory to where output files should be saved
cutoff_v (int): The minimal number of methods that ... | [
"Run",
"the",
"AMYLPRED2",
"web",
"server",
"for",
"a",
"protein",
"sequence",
"and",
"get",
"the",
"consensus",
"result",
"for",
"aggregation",
"propensity",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/aggregation_propensity.py#L66-L88 | train | 29,152 |
SBRG/ssbio | ssbio/protein/sequence/properties/aggregation_propensity.py | AMYLPRED.run_amylpred2 | def run_amylpred2(self, seq, outdir, run_amylmuts=False):
"""Run all methods on the AMYLPRED2 web server for an amino acid sequence and gather results.
Result files are cached in ``/path/to/outdir/AMYLPRED2_results``.
Args:
seq (str): Amino acid sequence as a string
out... | python | def run_amylpred2(self, seq, outdir, run_amylmuts=False):
"""Run all methods on the AMYLPRED2 web server for an amino acid sequence and gather results.
Result files are cached in ``/path/to/outdir/AMYLPRED2_results``.
Args:
seq (str): Amino acid sequence as a string
out... | [
"def",
"run_amylpred2",
"(",
"self",
",",
"seq",
",",
"outdir",
",",
"run_amylmuts",
"=",
"False",
")",
":",
"outdir_amylpred",
"=",
"op",
".",
"join",
"(",
"outdir",
",",
"'AMYLPRED2_results'",
")",
"if",
"not",
"op",
".",
"exists",
"(",
"outdir_amylpred"... | Run all methods on the AMYLPRED2 web server for an amino acid sequence and gather results.
Result files are cached in ``/path/to/outdir/AMYLPRED2_results``.
Args:
seq (str): Amino acid sequence as a string
outdir (str): Directory to where output files should be saved
... | [
"Run",
"all",
"methods",
"on",
"the",
"AMYLPRED2",
"web",
"server",
"for",
"an",
"amino",
"acid",
"sequence",
"and",
"gather",
"results",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/aggregation_propensity.py#L90-L171 | train | 29,153 |
SBRG/ssbio | ssbio/protein/sequence/properties/aggregation_propensity.py | AMYLPRED.parse_method_results | def parse_method_results(self, results_file, met):
"""Parse the output of a AMYLPRED2 result file."""
result = str(open(results_file).read())
ind_s = str.find(result, 'HITS')
ind_e = str.find(result, '**NOTE')
tmp = result[ind_s + 10:ind_e].strip(" ")
hits_resid = []
... | python | def parse_method_results(self, results_file, met):
"""Parse the output of a AMYLPRED2 result file."""
result = str(open(results_file).read())
ind_s = str.find(result, 'HITS')
ind_e = str.find(result, '**NOTE')
tmp = result[ind_s + 10:ind_e].strip(" ")
hits_resid = []
... | [
"def",
"parse_method_results",
"(",
"self",
",",
"results_file",
",",
"met",
")",
":",
"result",
"=",
"str",
"(",
"open",
"(",
"results_file",
")",
".",
"read",
"(",
")",
")",
"ind_s",
"=",
"str",
".",
"find",
"(",
"result",
",",
"'HITS'",
")",
"ind_... | Parse the output of a AMYLPRED2 result file. | [
"Parse",
"the",
"output",
"of",
"a",
"AMYLPRED2",
"result",
"file",
"."
] | e9449e64ffc1a1f5ad07e5849aa12a650095f8a2 | https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/aggregation_propensity.py#L173-L195 | train | 29,154 |
brycedrennan/eulerian-magnification | eulerian_magnification/io.py | _load_video | def _load_video(video_filename):
"""Load a video into a numpy array"""
video_filename = str(video_filename)
print("Loading " + video_filename)
if not os.path.isfile(video_filename):
raise Exception("File Not Found: %s" % video_filename)
# noinspection PyArgumentList
capture = cv2.VideoCa... | python | def _load_video(video_filename):
"""Load a video into a numpy array"""
video_filename = str(video_filename)
print("Loading " + video_filename)
if not os.path.isfile(video_filename):
raise Exception("File Not Found: %s" % video_filename)
# noinspection PyArgumentList
capture = cv2.VideoCa... | [
"def",
"_load_video",
"(",
"video_filename",
")",
":",
"video_filename",
"=",
"str",
"(",
"video_filename",
")",
"print",
"(",
"\"Loading \"",
"+",
"video_filename",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"video_filename",
")",
":",
"raise"... | Load a video into a numpy array | [
"Load",
"a",
"video",
"into",
"a",
"numpy",
"array"
] | 9ae0651fe3334176300d183f8240ad36d77759a9 | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/io.py#L15-L37 | train | 29,155 |
brycedrennan/eulerian-magnification | eulerian_magnification/io.py | get_capture_dimensions | def get_capture_dimensions(capture):
"""Get the dimensions of a capture"""
width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
return width, height | python | def get_capture_dimensions(capture):
"""Get the dimensions of a capture"""
width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
return width, height | [
"def",
"get_capture_dimensions",
"(",
"capture",
")",
":",
"width",
"=",
"int",
"(",
"capture",
".",
"get",
"(",
"cv2",
".",
"CAP_PROP_FRAME_WIDTH",
")",
")",
"height",
"=",
"int",
"(",
"capture",
".",
"get",
"(",
"cv2",
".",
"CAP_PROP_FRAME_HEIGHT",
")",
... | Get the dimensions of a capture | [
"Get",
"the",
"dimensions",
"of",
"a",
"capture"
] | 9ae0651fe3334176300d183f8240ad36d77759a9 | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/io.py#L45-L49 | train | 29,156 |
brycedrennan/eulerian-magnification | eulerian_magnification/io.py | save_video | def save_video(video, fps, save_filename='media/output.avi'):
"""Save a video to disk"""
# fourcc = cv2.CAP_PROP_FOURCC('M', 'J', 'P', 'G')
print(save_filename)
video = float_to_uint8(video)
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
writer = cv2.VideoWriter(save_filename, fourcc, fps, (video.shap... | python | def save_video(video, fps, save_filename='media/output.avi'):
"""Save a video to disk"""
# fourcc = cv2.CAP_PROP_FOURCC('M', 'J', 'P', 'G')
print(save_filename)
video = float_to_uint8(video)
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
writer = cv2.VideoWriter(save_filename, fourcc, fps, (video.shap... | [
"def",
"save_video",
"(",
"video",
",",
"fps",
",",
"save_filename",
"=",
"'media/output.avi'",
")",
":",
"# fourcc = cv2.CAP_PROP_FOURCC('M', 'J', 'P', 'G')",
"print",
"(",
"save_filename",
")",
"video",
"=",
"float_to_uint8",
"(",
"video",
")",
"fourcc",
"=",
"cv2... | Save a video to disk | [
"Save",
"a",
"video",
"to",
"disk"
] | 9ae0651fe3334176300d183f8240ad36d77759a9 | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/io.py#L74-L83 | train | 29,157 |
brycedrennan/eulerian-magnification | eulerian_magnification/base.py | show_frequencies | def show_frequencies(vid_data, fps, bounds=None):
"""Graph the average value of the video as well as the frequency strength"""
averages = []
if bounds:
for x in range(1, vid_data.shape[0] - 1):
averages.append(vid_data[x, bounds[2]:bounds[3], bounds[0]:bounds[1], :].sum())
else:
... | python | def show_frequencies(vid_data, fps, bounds=None):
"""Graph the average value of the video as well as the frequency strength"""
averages = []
if bounds:
for x in range(1, vid_data.shape[0] - 1):
averages.append(vid_data[x, bounds[2]:bounds[3], bounds[0]:bounds[1], :].sum())
else:
... | [
"def",
"show_frequencies",
"(",
"vid_data",
",",
"fps",
",",
"bounds",
"=",
"None",
")",
":",
"averages",
"=",
"[",
"]",
"if",
"bounds",
":",
"for",
"x",
"in",
"range",
"(",
"1",
",",
"vid_data",
".",
"shape",
"[",
"0",
"]",
"-",
"1",
")",
":",
... | Graph the average value of the video as well as the frequency strength | [
"Graph",
"the",
"average",
"value",
"of",
"the",
"video",
"as",
"well",
"as",
"the",
"frequency",
"strength"
] | 9ae0651fe3334176300d183f8240ad36d77759a9 | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/base.py#L31-L69 | train | 29,158 |
brycedrennan/eulerian-magnification | eulerian_magnification/base.py | gaussian_video | def gaussian_video(video, shrink_multiple):
"""Create a gaussian representation of a video"""
vid_data = None
for x in range(0, video.shape[0]):
frame = video[x]
gauss_copy = np.ndarray(shape=frame.shape, dtype="float")
gauss_copy[:] = frame
for i in range(shrink_multiple):
... | python | def gaussian_video(video, shrink_multiple):
"""Create a gaussian representation of a video"""
vid_data = None
for x in range(0, video.shape[0]):
frame = video[x]
gauss_copy = np.ndarray(shape=frame.shape, dtype="float")
gauss_copy[:] = frame
for i in range(shrink_multiple):
... | [
"def",
"gaussian_video",
"(",
"video",
",",
"shrink_multiple",
")",
":",
"vid_data",
"=",
"None",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"video",
".",
"shape",
"[",
"0",
"]",
")",
":",
"frame",
"=",
"video",
"[",
"x",
"]",
"gauss_copy",
"=",
"np... | Create a gaussian representation of a video | [
"Create",
"a",
"gaussian",
"representation",
"of",
"a",
"video"
] | 9ae0651fe3334176300d183f8240ad36d77759a9 | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/base.py#L72-L85 | train | 29,159 |
brycedrennan/eulerian-magnification | eulerian_magnification/base.py | combine_pyramid_and_save | def combine_pyramid_and_save(g_video, orig_video, enlarge_multiple, fps, save_filename='media/output.avi'):
"""Combine a gaussian video representation with the original and save to file"""
width, height = get_frame_dimensions(orig_video[0])
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
print("Outputting to %... | python | def combine_pyramid_and_save(g_video, orig_video, enlarge_multiple, fps, save_filename='media/output.avi'):
"""Combine a gaussian video representation with the original and save to file"""
width, height = get_frame_dimensions(orig_video[0])
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
print("Outputting to %... | [
"def",
"combine_pyramid_and_save",
"(",
"g_video",
",",
"orig_video",
",",
"enlarge_multiple",
",",
"fps",
",",
"save_filename",
"=",
"'media/output.avi'",
")",
":",
"width",
",",
"height",
"=",
"get_frame_dimensions",
"(",
"orig_video",
"[",
"0",
"]",
")",
"fou... | Combine a gaussian video representation with the original and save to file | [
"Combine",
"a",
"gaussian",
"video",
"representation",
"with",
"the",
"original",
"and",
"save",
"to",
"file"
] | 9ae0651fe3334176300d183f8240ad36d77759a9 | https://github.com/brycedrennan/eulerian-magnification/blob/9ae0651fe3334176300d183f8240ad36d77759a9/eulerian_magnification/base.py#L108-L122 | train | 29,160 |
textmagic/textmagic-rest-python | textmagic/rest/models/messages.py | Messages.price | def price(self, from_=None, **kwargs):
"""
Check pricing for a new outbound message.
An useful synonym for "message" command with "dummy" parameters set to true.
:Example:
message = client.messages.price(from_="447624800500", phones="999000001", text="Hello!", lists="1909100")
... | python | def price(self, from_=None, **kwargs):
"""
Check pricing for a new outbound message.
An useful synonym for "message" command with "dummy" parameters set to true.
:Example:
message = client.messages.price(from_="447624800500", phones="999000001", text="Hello!", lists="1909100")
... | [
"def",
"price",
"(",
"self",
",",
"from_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"from_",
":",
"kwargs",
"[",
"\"from\"",
"]",
"=",
"from_",
"uri",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"uri",
",",
"\"price\"",
")",
"response",
... | Check pricing for a new outbound message.
An useful synonym for "message" command with "dummy" parameters set to true.
:Example:
message = client.messages.price(from_="447624800500", phones="999000001", text="Hello!", lists="1909100")
:param str from: One of allowed Sender ID ... | [
"Check",
"pricing",
"for",
"a",
"new",
"outbound",
"message",
".",
"An",
"useful",
"synonym",
"for",
"message",
"command",
"with",
"dummy",
"parameters",
"set",
"to",
"true",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/messages.py#L93-L124 | train | 29,161 |
textmagic/textmagic-rest-python | textmagic/rest/models/tokens.py | Tokens.refresh | def refresh(self):
"""
Refresh access token. Only non-expired tokens can be renewed.
:Example:
token = client.tokens.refresh()
"""
uri = "%s/%s" % (self.uri, "refresh")
response, instance = self.request("GET", uri)
return response.ok | python | def refresh(self):
"""
Refresh access token. Only non-expired tokens can be renewed.
:Example:
token = client.tokens.refresh()
"""
uri = "%s/%s" % (self.uri, "refresh")
response, instance = self.request("GET", uri)
return response.ok | [
"def",
"refresh",
"(",
"self",
")",
":",
"uri",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"uri",
",",
"\"refresh\"",
")",
"response",
",",
"instance",
"=",
"self",
".",
"request",
"(",
"\"GET\"",
",",
"uri",
")",
"return",
"response",
".",
"ok"
] | Refresh access token. Only non-expired tokens can be renewed.
:Example:
token = client.tokens.refresh() | [
"Refresh",
"access",
"token",
".",
"Only",
"non",
"-",
"expired",
"tokens",
"can",
"be",
"renewed",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/tokens.py#L38-L48 | train | 29,162 |
textmagic/textmagic-rest-python | textmagic/rest/models/user.py | Users.update | def update(self, **kwargs):
"""
Update an current User via a PUT request.
Returns True if success.
:Example:
client.user.update(firstName="John", lastName="Doe", company="TextMagic")
:param str firstName: User first name. Required.
:param str lastName: User la... | python | def update(self, **kwargs):
"""
Update an current User via a PUT request.
Returns True if success.
:Example:
client.user.update(firstName="John", lastName="Doe", company="TextMagic")
:param str firstName: User first name. Required.
:param str lastName: User la... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
",",
"instance",
"=",
"self",
".",
"request",
"(",
"\"PUT\"",
",",
"self",
".",
"uri",
",",
"data",
"=",
"kwargs",
")",
"return",
"response",
".",
"status",
"==",
"201"
] | Update an current User via a PUT request.
Returns True if success.
:Example:
client.user.update(firstName="John", lastName="Doe", company="TextMagic")
:param str firstName: User first name. Required.
:param str lastName: User last name. Required.
:param str company: ... | [
"Update",
"an",
"current",
"User",
"via",
"a",
"PUT",
"request",
".",
"Returns",
"True",
"if",
"success",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/user.py#L61-L75 | train | 29,163 |
textmagic/textmagic-rest-python | textmagic/rest/models/user.py | Subaccounts.send_invite | def send_invite(self, **kwargs):
"""
Invite new subaccount.
Returns True if success.
:Example:
s = client.subaccounts.create(email="johndoe@yahoo.com", role="A")
:param str email: Subaccount email. Required.
:param str role: Subaccount role: `A` for administra... | python | def send_invite(self, **kwargs):
"""
Invite new subaccount.
Returns True if success.
:Example:
s = client.subaccounts.create(email="johndoe@yahoo.com", role="A")
:param str email: Subaccount email. Required.
:param str role: Subaccount role: `A` for administra... | [
"def",
"send_invite",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"resp",
",",
"_",
"=",
"self",
".",
"request",
"(",
"\"POST\"",
",",
"self",
".",
"uri",
",",
"data",
"=",
"kwargs",
")",
"return",
"resp",
".",
"status",
"==",
"204"
] | Invite new subaccount.
Returns True if success.
:Example:
s = client.subaccounts.create(email="johndoe@yahoo.com", role="A")
:param str email: Subaccount email. Required.
:param str role: Subaccount role: `A` for administrator or `U` for regular user. Required. | [
"Invite",
"new",
"subaccount",
".",
"Returns",
"True",
"if",
"success",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/user.py#L97-L110 | train | 29,164 |
textmagic/textmagic-rest-python | textmagic/rest/models/chats.py | Chats.by_phone | def by_phone(self, phone, **kwargs):
"""
Fetch messages from chat with specified phone number.
:Example:
chat = client.chats.by_phone(phone="447624800500")
:param str phone: Phone number in E.164 format.
:param int page: Fetch specified results page. Default=1
... | python | def by_phone(self, phone, **kwargs):
"""
Fetch messages from chat with specified phone number.
:Example:
chat = client.chats.by_phone(phone="447624800500")
:param str phone: Phone number in E.164 format.
:param int page: Fetch specified results page. Default=1
... | [
"def",
"by_phone",
"(",
"self",
",",
"phone",
",",
"*",
"*",
"kwargs",
")",
":",
"chat_messages",
"=",
"ChatMessages",
"(",
"self",
".",
"base_uri",
",",
"self",
".",
"auth",
")",
"return",
"self",
".",
"get_subresource_instances",
"(",
"uid",
"=",
"phon... | Fetch messages from chat with specified phone number.
:Example:
chat = client.chats.by_phone(phone="447624800500")
:param str phone: Phone number in E.164 format.
:param int page: Fetch specified results page. Default=1
:param int limit: How many results on page. Default=10 | [
"Fetch",
"messages",
"from",
"chat",
"with",
"specified",
"phone",
"number",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/chats.py#L98-L111 | train | 29,165 |
textmagic/textmagic-rest-python | textmagic/rest/client.py | get_credentials | def get_credentials(env=None):
"""
Gets the TextMagic credentials from current environment
:param env: environment
:return: username, token
"""
environ = env or os.environ
try:
username = environ["TEXTMAGIC_USERNAME"]
token = environ["TEXTMAGIC_AUTH_TOKEN"]
return us... | python | def get_credentials(env=None):
"""
Gets the TextMagic credentials from current environment
:param env: environment
:return: username, token
"""
environ = env or os.environ
try:
username = environ["TEXTMAGIC_USERNAME"]
token = environ["TEXTMAGIC_AUTH_TOKEN"]
return us... | [
"def",
"get_credentials",
"(",
"env",
"=",
"None",
")",
":",
"environ",
"=",
"env",
"or",
"os",
".",
"environ",
"try",
":",
"username",
"=",
"environ",
"[",
"\"TEXTMAGIC_USERNAME\"",
"]",
"token",
"=",
"environ",
"[",
"\"TEXTMAGIC_AUTH_TOKEN\"",
"]",
"return... | Gets the TextMagic credentials from current environment
:param env: environment
:return: username, token | [
"Gets",
"the",
"TextMagic",
"credentials",
"from",
"current",
"environment"
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/client.py#L52-L65 | train | 29,166 |
textmagic/textmagic-rest-python | textmagic/rest/models/contacts.py | Lists.put_contacts | def put_contacts(self, uid, **kwargs):
"""
Assign contacts to the specified list.
:Example:
client.lists.put_contacts(uid=1901010, contacts="1723812,1239912")
:param int uid: The unique id of the List. Required.
:param str contacts: Contact ID(s), separated by com... | python | def put_contacts(self, uid, **kwargs):
"""
Assign contacts to the specified list.
:Example:
client.lists.put_contacts(uid=1901010, contacts="1723812,1239912")
:param int uid: The unique id of the List. Required.
:param str contacts: Contact ID(s), separated by com... | [
"def",
"put_contacts",
"(",
"self",
",",
"uid",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"update_subresource_instance",
"(",
"uid",
",",
"body",
"=",
"kwargs",
",",
"subresource",
"=",
"None",
",",
"slug",
"=",
"\"contacts\"",
")"
] | Assign contacts to the specified list.
:Example:
client.lists.put_contacts(uid=1901010, contacts="1723812,1239912")
:param int uid: The unique id of the List. Required.
:param str contacts: Contact ID(s), separated by comma. Required. | [
"Assign",
"contacts",
"to",
"the",
"specified",
"list",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/contacts.py#L231-L245 | train | 29,167 |
textmagic/textmagic-rest-python | textmagic/rest/models/contacts.py | Lists.delete_contacts | def delete_contacts(self, uid, **kwargs):
"""
Unassign contacts from the specified list.
If contacts assign only to the specified list, then delete permanently.
Returns True if success.
:Example:
client.lists.delete_contacts(uid=1901010, contacts="1723812,1239912")
... | python | def delete_contacts(self, uid, **kwargs):
"""
Unassign contacts from the specified list.
If contacts assign only to the specified list, then delete permanently.
Returns True if success.
:Example:
client.lists.delete_contacts(uid=1901010, contacts="1723812,1239912")
... | [
"def",
"delete_contacts",
"(",
"self",
",",
"uid",
",",
"*",
"*",
"kwargs",
")",
":",
"uri",
"=",
"\"%s/%s/contacts\"",
"%",
"(",
"self",
".",
"uri",
",",
"uid",
")",
"response",
",",
"instance",
"=",
"self",
".",
"request",
"(",
"\"DELETE\"",
",",
"... | Unassign contacts from the specified list.
If contacts assign only to the specified list, then delete permanently.
Returns True if success.
:Example:
client.lists.delete_contacts(uid=1901010, contacts="1723812,1239912")
:param int uid: The unique id of the List. Required.... | [
"Unassign",
"contacts",
"from",
"the",
"specified",
"list",
".",
"If",
"contacts",
"assign",
"only",
"to",
"the",
"specified",
"list",
"then",
"delete",
"permanently",
".",
"Returns",
"True",
"if",
"success",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/contacts.py#L247-L262 | train | 29,168 |
textmagic/textmagic-rest-python | textmagic/rest/models/base.py | get_cert_file | def get_cert_file():
""" Get the certificates file for https"""
try:
current_path = os.path.realpath(__file__)
ca_cert_path = os.path.join(current_path, "..", "..", "..",
"conf", "cacert.pem")
return os.path.abspath(ca_cert_path)
except Exception:
... | python | def get_cert_file():
""" Get the certificates file for https"""
try:
current_path = os.path.realpath(__file__)
ca_cert_path = os.path.join(current_path, "..", "..", "..",
"conf", "cacert.pem")
return os.path.abspath(ca_cert_path)
except Exception:
... | [
"def",
"get_cert_file",
"(",
")",
":",
"try",
":",
"current_path",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
"ca_cert_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"current_path",
",",
"\"..\"",
",",
"\"..\"",
",",
"\"..\"",
","... | Get the certificates file for https | [
"Get",
"the",
"certificates",
"file",
"for",
"https"
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/base.py#L25-L33 | train | 29,169 |
textmagic/textmagic-rest-python | textmagic/rest/models/base.py | make_tm_request | def make_tm_request(method, uri, **kwargs):
"""
Make a request to TextMagic REST APIv2.
:param str method: "POST", "GET", "PUT" or "DELETE"
:param str uri: URI to process request.
:return: :class:`Response`
"""
headers = kwargs.get("headers", {})
user_agent = "textmagic-python/%s (P... | python | def make_tm_request(method, uri, **kwargs):
"""
Make a request to TextMagic REST APIv2.
:param str method: "POST", "GET", "PUT" or "DELETE"
:param str uri: URI to process request.
:return: :class:`Response`
"""
headers = kwargs.get("headers", {})
user_agent = "textmagic-python/%s (P... | [
"def",
"make_tm_request",
"(",
"method",
",",
"uri",
",",
"*",
"*",
"kwargs",
")",
":",
"headers",
"=",
"kwargs",
".",
"get",
"(",
"\"headers\"",
",",
"{",
"}",
")",
"user_agent",
"=",
"\"textmagic-python/%s (Python %s)\"",
"%",
"(",
"__version__",
",",
"p... | Make a request to TextMagic REST APIv2.
:param str method: "POST", "GET", "PUT" or "DELETE"
:param str uri: URI to process request.
:return: :class:`Response` | [
"Make",
"a",
"request",
"to",
"TextMagic",
"REST",
"APIv2",
"."
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/base.py#L92-L135 | train | 29,170 |
textmagic/textmagic-rest-python | textmagic/rest/models/base.py | CollectionModel.update_instance | def update_instance(self, uid, body):
"""
Update an Model via a PUT request
:param str uid: String identifier for the list resource
:param dict body: Dictionary of items to PUT
"""
uri = "%s/%s" % (self.uri, uid)
response, instance = self.request("PUT", uri, da... | python | def update_instance(self, uid, body):
"""
Update an Model via a PUT request
:param str uid: String identifier for the list resource
:param dict body: Dictionary of items to PUT
"""
uri = "%s/%s" % (self.uri, uid)
response, instance = self.request("PUT", uri, da... | [
"def",
"update_instance",
"(",
"self",
",",
"uid",
",",
"body",
")",
":",
"uri",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"uri",
",",
"uid",
")",
"response",
",",
"instance",
"=",
"self",
".",
"request",
"(",
"\"PUT\"",
",",
"uri",
",",
"data",
"="... | Update an Model via a PUT request
:param str uid: String identifier for the list resource
:param dict body: Dictionary of items to PUT | [
"Update",
"an",
"Model",
"via",
"a",
"PUT",
"request"
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/base.py#L217-L226 | train | 29,171 |
textmagic/textmagic-rest-python | textmagic/rest/models/base.py | CollectionModel.delete_instance | def delete_instance(self, uid):
"""
Delete an ObjectModel via a DELETE request
:param int uid: Unique id for the Model resource
"""
uri = "%s/%s" % (self.uri, uid)
response, instance = self.request("DELETE", uri)
return response.status == 204 | python | def delete_instance(self, uid):
"""
Delete an ObjectModel via a DELETE request
:param int uid: Unique id for the Model resource
"""
uri = "%s/%s" % (self.uri, uid)
response, instance = self.request("DELETE", uri)
return response.status == 204 | [
"def",
"delete_instance",
"(",
"self",
",",
"uid",
")",
":",
"uri",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"uri",
",",
"uid",
")",
"response",
",",
"instance",
"=",
"self",
".",
"request",
"(",
"\"DELETE\"",
",",
"uri",
")",
"return",
"response",
"... | Delete an ObjectModel via a DELETE request
:param int uid: Unique id for the Model resource | [
"Delete",
"an",
"ObjectModel",
"via",
"a",
"DELETE",
"request"
] | 15d679cb985b88b1cb2153ef2ba80d9749f9e281 | https://github.com/textmagic/textmagic-rest-python/blob/15d679cb985b88b1cb2153ef2ba80d9749f9e281/textmagic/rest/models/base.py#L237-L245 | train | 29,172 |
adafruit/Adafruit_CircuitPython_Register | adafruit_register/i2c_struct_array.py | _BoundStructArray._get_buffer | def _get_buffer(self, index):
"""Shared bounds checking and buffer creation."""
if not 0 <= index < self.count:
raise IndexError()
size = struct.calcsize(self.format)
# We create the buffer every time instead of keeping the buffer (which is 32 bytes at least)
# around... | python | def _get_buffer(self, index):
"""Shared bounds checking and buffer creation."""
if not 0 <= index < self.count:
raise IndexError()
size = struct.calcsize(self.format)
# We create the buffer every time instead of keeping the buffer (which is 32 bytes at least)
# around... | [
"def",
"_get_buffer",
"(",
"self",
",",
"index",
")",
":",
"if",
"not",
"0",
"<=",
"index",
"<",
"self",
".",
"count",
":",
"raise",
"IndexError",
"(",
")",
"size",
"=",
"struct",
".",
"calcsize",
"(",
"self",
".",
"format",
")",
"# We create the buffe... | Shared bounds checking and buffer creation. | [
"Shared",
"bounds",
"checking",
"and",
"buffer",
"creation",
"."
] | 51f53825061630a3d50e2208096656e5ffdd5caa | https://github.com/adafruit/Adafruit_CircuitPython_Register/blob/51f53825061630a3d50e2208096656e5ffdd5caa/adafruit_register/i2c_struct_array.py#L55-L64 | train | 29,173 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI._unzip_file | def _unzip_file(self, src_path, dest_path, filename):
"""unzips file located at src_path into destination_path"""
self.logger.info("unzipping file...")
# construct full path (including file name) for unzipping
unzip_path = os.path.join(dest_path, filename)
utils.ensure_directory... | python | def _unzip_file(self, src_path, dest_path, filename):
"""unzips file located at src_path into destination_path"""
self.logger.info("unzipping file...")
# construct full path (including file name) for unzipping
unzip_path = os.path.join(dest_path, filename)
utils.ensure_directory... | [
"def",
"_unzip_file",
"(",
"self",
",",
"src_path",
",",
"dest_path",
",",
"filename",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"unzipping file...\"",
")",
"# construct full path (including file name) for unzipping",
"unzip_path",
"=",
"os",
".",
"path",... | unzips file located at src_path into destination_path | [
"unzips",
"file",
"located",
"at",
"src_path",
"into",
"destination_path"
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L76-L88 | train | 29,174 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_dataset_url | def get_dataset_url(self, tournament=1):
"""Fetch url of the current dataset.
Args:
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
str: url of the current dataset
Example:
>>> NumerAPI().get_dataset_url()
https:... | python | def get_dataset_url(self, tournament=1):
"""Fetch url of the current dataset.
Args:
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
str: url of the current dataset
Example:
>>> NumerAPI().get_dataset_url()
https:... | [
"def",
"get_dataset_url",
"(",
"self",
",",
"tournament",
"=",
"1",
")",
":",
"query",
"=",
"\"\"\"\n query($tournament: Int!) {\n dataset(tournament: $tournament)\n }\"\"\"",
"arguments",
"=",
"{",
"'tournament'",
":",
"tournament",
"}",
... | Fetch url of the current dataset.
Args:
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
str: url of the current dataset
Example:
>>> NumerAPI().get_dataset_url()
https://numerai-datasets.s3.amazonaws.com/t1/104/numerai_d... | [
"Fetch",
"url",
"of",
"the",
"current",
"dataset",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L90-L109 | train | 29,175 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.raw_query | def raw_query(self, query, variables=None, authorization=False):
"""Send a raw request to the Numerai's GraphQL API.
This function allows to build your own queries and fetch results from
Numerai's GraphQL API. Checkout
https://medium.com/numerai/getting-started-with-numerais-new-tournam... | python | def raw_query(self, query, variables=None, authorization=False):
"""Send a raw request to the Numerai's GraphQL API.
This function allows to build your own queries and fetch results from
Numerai's GraphQL API. Checkout
https://medium.com/numerai/getting-started-with-numerais-new-tournam... | [
"def",
"raw_query",
"(",
"self",
",",
"query",
",",
"variables",
"=",
"None",
",",
"authorization",
"=",
"False",
")",
":",
"body",
"=",
"{",
"'query'",
":",
"query",
",",
"'variables'",
":",
"variables",
"}",
"headers",
"=",
"{",
"'Content-type'",
":",
... | Send a raw request to the Numerai's GraphQL API.
This function allows to build your own queries and fetch results from
Numerai's GraphQL API. Checkout
https://medium.com/numerai/getting-started-with-numerais-new-tournament-api-77396e895e72
for an introduction and https://api-tournament.... | [
"Send",
"a",
"raw",
"request",
"to",
"the",
"Numerai",
"s",
"GraphQL",
"API",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L170-L222 | train | 29,176 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_staking_leaderboard | def get_staking_leaderboard(self, round_num=0, tournament=1):
"""Retrieves the leaderboard of the staking competition for the given
round.
Args:
round_num (int, optional): The round you are interested in,
defaults to current round.
tournament (int, option... | python | def get_staking_leaderboard(self, round_num=0, tournament=1):
"""Retrieves the leaderboard of the staking competition for the given
round.
Args:
round_num (int, optional): The round you are interested in,
defaults to current round.
tournament (int, option... | [
"def",
"get_staking_leaderboard",
"(",
"self",
",",
"round_num",
"=",
"0",
",",
"tournament",
"=",
"1",
")",
":",
"msg",
"=",
"\"getting stakes for tournament {} round {}\"",
"self",
".",
"logger",
".",
"info",
"(",
"msg",
".",
"format",
"(",
"tournament",
","... | Retrieves the leaderboard of the staking competition for the given
round.
Args:
round_num (int, optional): The round you are interested in,
defaults to current round.
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
li... | [
"Retrieves",
"the",
"leaderboard",
"of",
"the",
"staking",
"competition",
"for",
"the",
"given",
"round",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L328-L410 | train | 29,177 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_nmr_prize_pool | def get_nmr_prize_pool(self, round_num=0, tournament=1):
"""Get NMR prize pool for the given round and tournament.
Args:
round_num (int, optional): The round you are interested in,
defaults to current round.
tournament (int, optional): ID of the tournament, defau... | python | def get_nmr_prize_pool(self, round_num=0, tournament=1):
"""Get NMR prize pool for the given round and tournament.
Args:
round_num (int, optional): The round you are interested in,
defaults to current round.
tournament (int, optional): ID of the tournament, defau... | [
"def",
"get_nmr_prize_pool",
"(",
"self",
",",
"round_num",
"=",
"0",
",",
"tournament",
"=",
"1",
")",
":",
"tournaments",
"=",
"self",
".",
"get_competitions",
"(",
"tournament",
")",
"tournaments",
".",
"sort",
"(",
"key",
"=",
"lambda",
"t",
":",
"t"... | Get NMR prize pool for the given round and tournament.
Args:
round_num (int, optional): The round you are interested in,
defaults to current round.
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
decimal.Decimal: prize pool i... | [
"Get",
"NMR",
"prize",
"pool",
"for",
"the",
"given",
"round",
"and",
"tournament",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L412-L435 | train | 29,178 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_competitions | def get_competitions(self, tournament=1):
"""Retrieves information about all competitions
Args:
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
list of dicts: list of rounds
Each round's dict contains the following items:
... | python | def get_competitions(self, tournament=1):
"""Retrieves information about all competitions
Args:
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
list of dicts: list of rounds
Each round's dict contains the following items:
... | [
"def",
"get_competitions",
"(",
"self",
",",
"tournament",
"=",
"1",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"getting rounds...\"",
")",
"query",
"=",
"'''\n query($tournament: Int!) {\n rounds(tournament: $tournament) {\n n... | Retrieves information about all competitions
Args:
tournament (int, optional): ID of the tournament, defaults to 1
Returns:
list of dicts: list of rounds
Each round's dict contains the following items:
* datasetId (`str`)
* number (... | [
"Retrieves",
"information",
"about",
"all",
"competitions"
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L470-L536 | train | 29,179 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_current_round | def get_current_round(self, tournament=1):
"""Get number of the current active round.
Args:
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
int: number of the current active round
Example:
>>> NumerAPI().get_current_round()... | python | def get_current_round(self, tournament=1):
"""Get number of the current active round.
Args:
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
int: number of the current active round
Example:
>>> NumerAPI().get_current_round()... | [
"def",
"get_current_round",
"(",
"self",
",",
"tournament",
"=",
"1",
")",
":",
"# zero is an alias for the current round!",
"query",
"=",
"'''\n query($tournament: Int!) {\n rounds(tournament: $tournament\n number: 0) {\n number\n... | Get number of the current active round.
Args:
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
int: number of the current active round
Example:
>>> NumerAPI().get_current_round()
104 | [
"Get",
"number",
"of",
"the",
"current",
"active",
"round",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L538-L565 | train | 29,180 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_tournaments | def get_tournaments(self, only_active=True):
"""Get all tournaments
Args:
only_active (bool): Flag to indicate of only active tournaments
should be returned or all of them. Defaults
to True.
Returns:
list o... | python | def get_tournaments(self, only_active=True):
"""Get all tournaments
Args:
only_active (bool): Flag to indicate of only active tournaments
should be returned or all of them. Defaults
to True.
Returns:
list o... | [
"def",
"get_tournaments",
"(",
"self",
",",
"only_active",
"=",
"True",
")",
":",
"query",
"=",
"\"\"\"\n query {\n tournaments {\n id\n name\n tournament\n active\n }\n }\n \"\"\"",
... | Get all tournaments
Args:
only_active (bool): Flag to indicate of only active tournaments
should be returned or all of them. Defaults
to True.
Returns:
list of dicts: list of tournaments
Each tournamen... | [
"Get",
"all",
"tournaments"
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L567-L617 | train | 29,181 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_submission_filenames | def get_submission_filenames(self, tournament=None, round_num=None):
"""Get filenames of the submission of the user.
Args:
tournament (int): optionally filter by ID of the tournament
round_num (int): optionally filter round number
Returns:
list: list of user... | python | def get_submission_filenames(self, tournament=None, round_num=None):
"""Get filenames of the submission of the user.
Args:
tournament (int): optionally filter by ID of the tournament
round_num (int): optionally filter round number
Returns:
list: list of user... | [
"def",
"get_submission_filenames",
"(",
"self",
",",
"tournament",
"=",
"None",
",",
"round_num",
"=",
"None",
")",
":",
"query",
"=",
"'''\n query {\n user {\n submissions {\n filename\n selected\n round {... | Get filenames of the submission of the user.
Args:
tournament (int): optionally filter by ID of the tournament
round_num (int): optionally filter round number
Returns:
list: list of user filenames (`dict`)
Each filenames in the list as the following str... | [
"Get",
"filenames",
"of",
"the",
"submission",
"of",
"the",
"user",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L728-L777 | train | 29,182 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_rankings | def get_rankings(self, limit=50, offset=0):
"""Get the overall ranking
Args:
limit (int): number of items to return (optional, defaults to 50)
offset (int): number of items to skip (optional, defaults to 0)
Returns:
list of dicts: list of ranking items
... | python | def get_rankings(self, limit=50, offset=0):
"""Get the overall ranking
Args:
limit (int): number of items to return (optional, defaults to 50)
offset (int): number of items to skip (optional, defaults to 0)
Returns:
list of dicts: list of ranking items
... | [
"def",
"get_rankings",
"(",
"self",
",",
"limit",
"=",
"50",
",",
"offset",
"=",
"0",
")",
":",
"query",
"=",
"'''\n query($limit: Int!\n $offset: Int!) {\n rankings(limit: $limit\n offset: $offset) {\n use... | Get the overall ranking
Args:
limit (int): number of items to return (optional, defaults to 50)
offset (int): number of items to skip (optional, defaults to 0)
Returns:
list of dicts: list of ranking items
Each dict contains the following items:
... | [
"Get",
"the",
"overall",
"ranking"
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L779-L832 | train | 29,183 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_submission_ids | def get_submission_ids(self, tournament=1):
"""Get dict with username->submission_id mapping.
Args:
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
dict: username->submission_id mapping, string->string
Example:
>>> NumerAPI... | python | def get_submission_ids(self, tournament=1):
"""Get dict with username->submission_id mapping.
Args:
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
dict: username->submission_id mapping, string->string
Example:
>>> NumerAPI... | [
"def",
"get_submission_ids",
"(",
"self",
",",
"tournament",
"=",
"1",
")",
":",
"query",
"=",
"\"\"\"\n query($tournament: Int!) {\n rounds(tournament: $tournament\n number: 0) {\n leaderboard {\n username\n ... | Get dict with username->submission_id mapping.
Args:
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
dict: username->submission_id mapping, string->string
Example:
>>> NumerAPI().get_submission_ids()
{'1337ai': '93c4685... | [
"Get",
"dict",
"with",
"username",
"-",
">",
"submission_id",
"mapping",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L834-L867 | train | 29,184 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_user | def get_user(self):
"""Get all information about you!
Returns:
dict: user information including the following fields:
* assignedEthAddress (`str`)
* availableNmr (`decimal.Decimal`)
* availableUsd (`decimal.Decimal`)
* banned ... | python | def get_user(self):
"""Get all information about you!
Returns:
dict: user information including the following fields:
* assignedEthAddress (`str`)
* availableNmr (`decimal.Decimal`)
* availableUsd (`decimal.Decimal`)
* banned ... | [
"def",
"get_user",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n query {\n user {\n username\n banned\n assignedEthAddress\n availableNmr\n availableUsd\n email\n id\n mfaEnab... | Get all information about you!
Returns:
dict: user information including the following fields:
* assignedEthAddress (`str`)
* availableNmr (`decimal.Decimal`)
* availableUsd (`decimal.Decimal`)
* banned (`bool`)
* emai... | [
"Get",
"all",
"information",
"about",
"you!"
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L869-L942 | train | 29,185 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_payments | def get_payments(self):
"""Get all your payments.
Returns:
list of dicts: payments
For each payout in the list, a dict contains the following items:
* nmrAmount (`decimal.Decimal`)
* usdAmount (`decimal.Decimal`)
* tournament (`s... | python | def get_payments(self):
"""Get all your payments.
Returns:
list of dicts: payments
For each payout in the list, a dict contains the following items:
* nmrAmount (`decimal.Decimal`)
* usdAmount (`decimal.Decimal`)
* tournament (`s... | [
"def",
"get_payments",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n query {\n user {\n payments {\n nmrAmount\n round {\n number\n openTime\n resolveTime\n resolvedGen... | Get all your payments.
Returns:
list of dicts: payments
For each payout in the list, a dict contains the following items:
* nmrAmount (`decimal.Decimal`)
* usdAmount (`decimal.Decimal`)
* tournament (`str`)
* round (`dict... | [
"Get",
"all",
"your",
"payments",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L944-L1003 | train | 29,186 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_transactions | def get_transactions(self):
"""Get all your deposits and withdrawals.
Returns:
dict: lists of your NMR and USD transactions
The returned dict has the following structure:
* nmrDeposits (`list`) contains items with fields:
* from (`str`)
... | python | def get_transactions(self):
"""Get all your deposits and withdrawals.
Returns:
dict: lists of your NMR and USD transactions
The returned dict has the following structure:
* nmrDeposits (`list`) contains items with fields:
* from (`str`)
... | [
"def",
"get_transactions",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n query {\n user {\n nmrDeposits {\n from\n posted\n status\n to\n txHash\n value\n }\n ... | Get all your deposits and withdrawals.
Returns:
dict: lists of your NMR and USD transactions
The returned dict has the following structure:
* nmrDeposits (`list`) contains items with fields:
* from (`str`)
* posted (`bool`)
... | [
"Get",
"all",
"your",
"deposits",
"and",
"withdrawals",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1005-L1112 | train | 29,187 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.get_stakes | def get_stakes(self):
"""List all your stakes.
Returns:
list of dicts: stakes
Each stake is a dict with the following fields:
* confidence (`decimal.Decimal`)
* roundNumber (`int`)
* tournamentId (`int`)
* soc (`d... | python | def get_stakes(self):
"""List all your stakes.
Returns:
list of dicts: stakes
Each stake is a dict with the following fields:
* confidence (`decimal.Decimal`)
* roundNumber (`int`)
* tournamentId (`int`)
* soc (`d... | [
"def",
"get_stakes",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n query {\n user {\n stakeTxs {\n confidence\n insertedAt\n roundNumber\n tournamentId\n soc\n staker\n ... | List all your stakes.
Returns:
list of dicts: stakes
Each stake is a dict with the following fields:
* confidence (`decimal.Decimal`)
* roundNumber (`int`)
* tournamentId (`int`)
* soc (`decimal.Decimal`)
... | [
"List",
"all",
"your",
"stakes",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1114-L1173 | train | 29,188 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.submission_status | def submission_status(self, submission_id=None):
"""submission status of the last submission associated with the account.
Args:
submission_id (str): submission of interest, defaults to the last
submission done with the account
Returns:
dict: submission s... | python | def submission_status(self, submission_id=None):
"""submission status of the last submission associated with the account.
Args:
submission_id (str): submission of interest, defaults to the last
submission done with the account
Returns:
dict: submission s... | [
"def",
"submission_status",
"(",
"self",
",",
"submission_id",
"=",
"None",
")",
":",
"if",
"submission_id",
"is",
"None",
":",
"submission_id",
"=",
"self",
".",
"submission_id",
"if",
"submission_id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'You need... | submission status of the last submission associated with the account.
Args:
submission_id (str): submission of interest, defaults to the last
submission done with the account
Returns:
dict: submission status with the following content:
* concord... | [
"submission",
"status",
"of",
"the",
"last",
"submission",
"associated",
"with",
"the",
"account",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1175-L1224 | train | 29,189 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.upload_predictions | def upload_predictions(self, file_path, tournament=1):
"""Upload predictions from file.
Args:
file_path (str): CSV file with predictions that will get uploaded
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
str: submission_id
... | python | def upload_predictions(self, file_path, tournament=1):
"""Upload predictions from file.
Args:
file_path (str): CSV file with predictions that will get uploaded
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
str: submission_id
... | [
"def",
"upload_predictions",
"(",
"self",
",",
"file_path",
",",
"tournament",
"=",
"1",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"uploading predictions...\"",
")",
"auth_query",
"=",
"'''\n query($filename: String!\n $tournament: I... | Upload predictions from file.
Args:
file_path (str): CSV file with predictions that will get uploaded
tournament (int): ID of the tournament (optional, defaults to 1)
Returns:
str: submission_id
Example:
>>> api = NumerAPI(secret_key="..", publi... | [
"Upload",
"predictions",
"from",
"file",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1226-L1273 | train | 29,190 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.check_submission_successful | def check_submission_successful(self, submission_id=None):
"""Check if the last submission passes submission criteria.
Args:
submission_id (str, optional): submission of interest, defaults to
the last submission done with the account
Return:
bool: True i... | python | def check_submission_successful(self, submission_id=None):
"""Check if the last submission passes submission criteria.
Args:
submission_id (str, optional): submission of interest, defaults to
the last submission done with the account
Return:
bool: True i... | [
"def",
"check_submission_successful",
"(",
"self",
",",
"submission_id",
"=",
"None",
")",
":",
"status",
"=",
"self",
".",
"submission_status",
"(",
"submission_id",
")",
"# need to cast to bool to not return None in some cases.",
"success",
"=",
"bool",
"(",
"status",... | Check if the last submission passes submission criteria.
Args:
submission_id (str, optional): submission of interest, defaults to
the last submission done with the account
Return:
bool: True if the submission passed all checks, False otherwise.
Example:... | [
"Check",
"if",
"the",
"last",
"submission",
"passes",
"submission",
"criteria",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1369-L1388 | train | 29,191 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.tournament_number2name | def tournament_number2name(self, number):
"""Translate tournament number to tournament name.
Args:
number (int): tournament number to translate
Returns:
name (str): name of the tournament or `None` if unknown.
Examples:
>>> NumerAPI().tournament_num... | python | def tournament_number2name(self, number):
"""Translate tournament number to tournament name.
Args:
number (int): tournament number to translate
Returns:
name (str): name of the tournament or `None` if unknown.
Examples:
>>> NumerAPI().tournament_num... | [
"def",
"tournament_number2name",
"(",
"self",
",",
"number",
")",
":",
"tournaments",
"=",
"self",
".",
"get_tournaments",
"(",
")",
"d",
"=",
"{",
"t",
"[",
"'tournament'",
"]",
":",
"t",
"[",
"'name'",
"]",
"for",
"t",
"in",
"tournaments",
"}",
"retu... | Translate tournament number to tournament name.
Args:
number (int): tournament number to translate
Returns:
name (str): name of the tournament or `None` if unknown.
Examples:
>>> NumerAPI().tournament_number2name(4)
'delta'
>>> Numer... | [
"Translate",
"tournament",
"number",
"to",
"tournament",
"name",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1390-L1407 | train | 29,192 |
uuazed/numerapi | numerapi/numerapi.py | NumerAPI.tournament_name2number | def tournament_name2number(self, name):
"""Translate tournament name to tournament number.
Args:
name (str): tournament name to translate
Returns:
number (int): number of the tournament or `None` if unknown.
Examples:
>>> NumerAPI().tournament_name2... | python | def tournament_name2number(self, name):
"""Translate tournament name to tournament number.
Args:
name (str): tournament name to translate
Returns:
number (int): number of the tournament or `None` if unknown.
Examples:
>>> NumerAPI().tournament_name2... | [
"def",
"tournament_name2number",
"(",
"self",
",",
"name",
")",
":",
"tournaments",
"=",
"self",
".",
"get_tournaments",
"(",
")",
"d",
"=",
"{",
"t",
"[",
"'name'",
"]",
":",
"t",
"[",
"'tournament'",
"]",
"for",
"t",
"in",
"tournaments",
"}",
"return... | Translate tournament name to tournament number.
Args:
name (str): tournament name to translate
Returns:
number (int): number of the tournament or `None` if unknown.
Examples:
>>> NumerAPI().tournament_name2number('delta')
4
>>> Numer... | [
"Translate",
"tournament",
"name",
"to",
"tournament",
"number",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L1409-L1426 | train | 29,193 |
uuazed/numerapi | numerapi/cli.py | staking_leaderboard | def staking_leaderboard(round_num=0, tournament=1):
"""Retrieves the staking competition leaderboard for the given round."""
click.echo(prettify(napi.get_staking_leaderboard(tournament=tournament,
round_num=round_num))) | python | def staking_leaderboard(round_num=0, tournament=1):
"""Retrieves the staking competition leaderboard for the given round."""
click.echo(prettify(napi.get_staking_leaderboard(tournament=tournament,
round_num=round_num))) | [
"def",
"staking_leaderboard",
"(",
"round_num",
"=",
"0",
",",
"tournament",
"=",
"1",
")",
":",
"click",
".",
"echo",
"(",
"prettify",
"(",
"napi",
".",
"get_staking_leaderboard",
"(",
"tournament",
"=",
"tournament",
",",
"round_num",
"=",
"round_num",
")"... | Retrieves the staking competition leaderboard for the given round. | [
"Retrieves",
"the",
"staking",
"competition",
"leaderboard",
"for",
"the",
"given",
"round",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/cli.py#L56-L59 | train | 29,194 |
uuazed/numerapi | numerapi/cli.py | rankings | def rankings(limit=20, offset=0):
"""Get the overall rankings."""
click.echo(prettify(napi.get_rankings(limit=limit, offset=offset))) | python | def rankings(limit=20, offset=0):
"""Get the overall rankings."""
click.echo(prettify(napi.get_rankings(limit=limit, offset=offset))) | [
"def",
"rankings",
"(",
"limit",
"=",
"20",
",",
"offset",
"=",
"0",
")",
":",
"click",
".",
"echo",
"(",
"prettify",
"(",
"napi",
".",
"get_rankings",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
")",
")",
")"
] | Get the overall rankings. | [
"Get",
"the",
"overall",
"rankings",
"."
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/cli.py#L91-L93 | train | 29,195 |
uuazed/numerapi | numerapi/cli.py | submission_filenames | def submission_filenames(round_num=None, tournament=None):
"""Get filenames of your submissions"""
click.echo(prettify(
napi.get_submission_filenames(tournament, round_num))) | python | def submission_filenames(round_num=None, tournament=None):
"""Get filenames of your submissions"""
click.echo(prettify(
napi.get_submission_filenames(tournament, round_num))) | [
"def",
"submission_filenames",
"(",
"round_num",
"=",
"None",
",",
"tournament",
"=",
"None",
")",
":",
"click",
".",
"echo",
"(",
"prettify",
"(",
"napi",
".",
"get_submission_filenames",
"(",
"tournament",
",",
"round_num",
")",
")",
")"
] | Get filenames of your submissions | [
"Get",
"filenames",
"of",
"your",
"submissions"
] | fc9dcc53b32ede95bfda1ceeb62aec1d67d26697 | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/cli.py#L110-L113 | train | 29,196 |
kirbs-/hide_code | hide_code/hide_code.py | install_bootstrapped_files | def install_bootstrapped_files(nb_path=None, server_config=True, DEBUG=False):
"""
Installs javascript and exporting server extensions in Jupyter notebook.
Args:
nb_path (string): Path to notebook module.
server_config (boolean): Install exporting server extensions.
DEBUG (boolean):... | python | def install_bootstrapped_files(nb_path=None, server_config=True, DEBUG=False):
"""
Installs javascript and exporting server extensions in Jupyter notebook.
Args:
nb_path (string): Path to notebook module.
server_config (boolean): Install exporting server extensions.
DEBUG (boolean):... | [
"def",
"install_bootstrapped_files",
"(",
"nb_path",
"=",
"None",
",",
"server_config",
"=",
"True",
",",
"DEBUG",
"=",
"False",
")",
":",
"install_path",
"=",
"None",
"print",
"(",
"'Starting hide_code.js install...'",
")",
"current_dir",
"=",
"path",
".",
"abs... | Installs javascript and exporting server extensions in Jupyter notebook.
Args:
nb_path (string): Path to notebook module.
server_config (boolean): Install exporting server extensions.
DEBUG (boolean): Verbose mode. | [
"Installs",
"javascript",
"and",
"exporting",
"server",
"extensions",
"in",
"Jupyter",
"notebook",
"."
] | 351cc4146c9c111c39725e068690a0e4853f9876 | https://github.com/kirbs-/hide_code/blob/351cc4146c9c111c39725e068690a0e4853f9876/hide_code/hide_code.py#L213-L295 | train | 29,197 |
kirbs-/hide_code | hide_code/hide_code.py | ipynb_file_name | def ipynb_file_name(params):
"""
Returns OS path to notebook based on route parameters.
"""
global notebook_dir
p = notebook_dir + [param.replace('/', '') for param in params if param is not None]
return path.join(*p) | python | def ipynb_file_name(params):
"""
Returns OS path to notebook based on route parameters.
"""
global notebook_dir
p = notebook_dir + [param.replace('/', '') for param in params if param is not None]
return path.join(*p) | [
"def",
"ipynb_file_name",
"(",
"params",
")",
":",
"global",
"notebook_dir",
"p",
"=",
"notebook_dir",
"+",
"[",
"param",
".",
"replace",
"(",
"'/'",
",",
"''",
")",
"for",
"param",
"in",
"params",
"if",
"param",
"is",
"not",
"None",
"]",
"return",
"pa... | Returns OS path to notebook based on route parameters. | [
"Returns",
"OS",
"path",
"to",
"notebook",
"based",
"on",
"route",
"parameters",
"."
] | 351cc4146c9c111c39725e068690a0e4853f9876 | https://github.com/kirbs-/hide_code/blob/351cc4146c9c111c39725e068690a0e4853f9876/hide_code/hide_code.py#L314-L320 | train | 29,198 |
pytroll/pyspectral | pyspectral/radiance_tb_conversion.py | radiance2tb | def radiance2tb(rad, wavelength):
"""
Get the Tb from the radiance using the Planck function
rad:
Radiance in SI units
wavelength:
Wavelength in SI units (meter)
"""
from pyspectral.blackbody import blackbody_rad2temp as rad2temp
return rad2temp(wavelength, rad) | python | def radiance2tb(rad, wavelength):
"""
Get the Tb from the radiance using the Planck function
rad:
Radiance in SI units
wavelength:
Wavelength in SI units (meter)
"""
from pyspectral.blackbody import blackbody_rad2temp as rad2temp
return rad2temp(wavelength, rad) | [
"def",
"radiance2tb",
"(",
"rad",
",",
"wavelength",
")",
":",
"from",
"pyspectral",
".",
"blackbody",
"import",
"blackbody_rad2temp",
"as",
"rad2temp",
"return",
"rad2temp",
"(",
"wavelength",
",",
"rad",
")"
] | Get the Tb from the radiance using the Planck function
rad:
Radiance in SI units
wavelength:
Wavelength in SI units (meter) | [
"Get",
"the",
"Tb",
"from",
"the",
"radiance",
"using",
"the",
"Planck",
"function"
] | fd296c0e0bdf5364fa180134a1292665d6bc50a3 | https://github.com/pytroll/pyspectral/blob/fd296c0e0bdf5364fa180134a1292665d6bc50a3/pyspectral/radiance_tb_conversion.py#L249-L259 | train | 29,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.