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
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
spacetelescope/pysynphot
pysynphot/locations.py
get_data_filename
def get_data_filename(filename): """Map filename to its actual path. Parameters ---------- filename : str Filename to search. Returns ------- path : str Full path to the file in data directory. """ global _data_map if _data_map is None: _data_map = {} ...
python
def get_data_filename(filename): """Map filename to its actual path. Parameters ---------- filename : str Filename to search. Returns ------- path : str Full path to the file in data directory. """ global _data_map if _data_map is None: _data_map = {} ...
[ "def", "get_data_filename", "(", "filename", ")", ":", "global", "_data_map", "if", "_data_map", "is", "None", ":", "_data_map", "=", "{", "}", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "specdir", ")", ":", "for", "fname",...
Map filename to its actual path. Parameters ---------- filename : str Filename to search. Returns ------- path : str Full path to the file in data directory.
[ "Map", "filename", "to", "its", "actual", "path", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/locations.py#L190-L214
train
spacetelescope/pysynphot
pysynphot/renorm.py
StdRenorm
def StdRenorm(spectrum, band, RNval, RNunitstring, force=False): """This is used by `~pysynphot.spectrum.SourceSpectrum` for renormalization. Parameters ---------- spectrum : `~pysynphot.spectrum.SourceSpectrum` Spectrum to renormalize. band, RNval, RNunitstring, force See :met...
python
def StdRenorm(spectrum, band, RNval, RNunitstring, force=False): """This is used by `~pysynphot.spectrum.SourceSpectrum` for renormalization. Parameters ---------- spectrum : `~pysynphot.spectrum.SourceSpectrum` Spectrum to renormalize. band, RNval, RNunitstring, force See :met...
[ "def", "StdRenorm", "(", "spectrum", ",", "band", ",", "RNval", ",", "RNunitstring", ",", "force", "=", "False", ")", ":", "if", "not", "force", ":", "stat", "=", "band", ".", "check_overlap", "(", "spectrum", ")", "if", "stat", "==", "'full'", ":", ...
This is used by `~pysynphot.spectrum.SourceSpectrum` for renormalization. Parameters ---------- spectrum : `~pysynphot.spectrum.SourceSpectrum` Spectrum to renormalize. band, RNval, RNunitstring, force See :meth:`~pysynphot.spectrum.SourceSpectrum.renorm`. Returns ------- ...
[ "This", "is", "used", "by", "~pysynphot", ".", "spectrum", ".", "SourceSpectrum", "for", "renormalization", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/renorm.py#L58-L127
train
spacetelescope/pysynphot
commissioning/convert/convertcases.py
setdirs
def setdirs(outfiles): """Create the directories if need be""" for k in outfiles: fname=outfiles[k] dname= os.path.dirname(fname) if not os.path.isdir(dname): os.mkdir(dname)
python
def setdirs(outfiles): """Create the directories if need be""" for k in outfiles: fname=outfiles[k] dname= os.path.dirname(fname) if not os.path.isdir(dname): os.mkdir(dname)
[ "def", "setdirs", "(", "outfiles", ")", ":", "for", "k", "in", "outfiles", ":", "fname", "=", "outfiles", "[", "k", "]", "dname", "=", "os", ".", "path", ".", "dirname", "(", "fname", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "dname...
Create the directories if need be
[ "Create", "the", "directories", "if", "need", "be" ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/convert/convertcases.py#L76-L82
train
spacetelescope/pysynphot
pysynphot/planck.py
bb_photlam_arcsec
def bb_photlam_arcsec(wave, temperature): """Evaluate Planck's law in ``photlam`` per square arcsec. .. note:: Uses :func:`llam_SI` for calculation, and then converts SI units back to CGS. Parameters ---------- wave : array_like Wavelength values in Angstrom. temperat...
python
def bb_photlam_arcsec(wave, temperature): """Evaluate Planck's law in ``photlam`` per square arcsec. .. note:: Uses :func:`llam_SI` for calculation, and then converts SI units back to CGS. Parameters ---------- wave : array_like Wavelength values in Angstrom. temperat...
[ "def", "bb_photlam_arcsec", "(", "wave", ",", "temperature", ")", ":", "lam", "=", "wave", "*", "1.0E-10", "return", "F", "*", "llam_SI", "(", "lam", ",", "temperature", ")", "/", "(", "HS", "*", "C", "/", "lam", ")" ]
Evaluate Planck's law in ``photlam`` per square arcsec. .. note:: Uses :func:`llam_SI` for calculation, and then converts SI units back to CGS. Parameters ---------- wave : array_like Wavelength values in Angstrom. temperature : float Blackbody temperature in Kelv...
[ "Evaluate", "Planck", "s", "law", "in", "photlam", "per", "square", "arcsec", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/planck.py#L142-L166
train
spacetelescope/pysynphot
pysynphot/units.py
Units
def Units(uname): """Generate a unit object. Parameters ---------- uname : str Wavelength or flux unit name. Returns ------- unit : `BaseUnit` or `None` Unit object. `None` means unitless. Raises ------ ValueError Unknown unit name. """ if isin...
python
def Units(uname): """Generate a unit object. Parameters ---------- uname : str Wavelength or flux unit name. Returns ------- unit : `BaseUnit` or `None` Unit object. `None` means unitless. Raises ------ ValueError Unknown unit name. """ if isin...
[ "def", "Units", "(", "uname", ")", ":", "if", "isinstance", "(", "uname", ",", "BaseUnit", ")", ":", "return", "uname", "else", ":", "try", ":", "if", "issubclass", "(", "uname", ",", "BaseUnit", ")", ":", "return", "uname", "(", ")", "except", "Type...
Generate a unit object. Parameters ---------- uname : str Wavelength or flux unit name. Returns ------- unit : `BaseUnit` or `None` Unit object. `None` means unitless. Raises ------ ValueError Unknown unit name.
[ "Generate", "a", "unit", "object", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/units.py#L27-L60
train
spacetelescope/pysynphot
pysynphot/units.py
ismatch
def ismatch(a,b): """Method to allow smart comparisons between classes, instances, and string representations of units and give the right answer. For internal use only.""" #Try the easy case if a == b: return True else: #Try isinstance in both orders try: if i...
python
def ismatch(a,b): """Method to allow smart comparisons between classes, instances, and string representations of units and give the right answer. For internal use only.""" #Try the easy case if a == b: return True else: #Try isinstance in both orders try: if i...
[ "def", "ismatch", "(", "a", ",", "b", ")", ":", "if", "a", "==", "b", ":", "return", "True", "else", ":", "try", ":", "if", "isinstance", "(", "a", ",", "b", ")", ":", "return", "True", "except", "TypeError", ":", "try", ":", "if", "isinstance", ...
Method to allow smart comparisons between classes, instances, and string representations of units and give the right answer. For internal use only.
[ "Method", "to", "allow", "smart", "comparisons", "between", "classes", "instances", "and", "string", "representations", "of", "units", "and", "give", "the", "right", "answer", ".", "For", "internal", "use", "only", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/units.py#L63-L93
train
spacetelescope/pysynphot
pysynphot/units.py
Photlam.ToABMag
def ToABMag(self, wave, flux, **kwargs): """Convert to ``abmag``. .. math:: \\textnormal{AB}_{\\nu} = -2.5 \\; \\log(h \\lambda \\; \\textnormal{photlam}) - 48.6 where :math:`h` is as defined in :ref:`pysynphot-constants`. Parameters ---------- wave, flux ...
python
def ToABMag(self, wave, flux, **kwargs): """Convert to ``abmag``. .. math:: \\textnormal{AB}_{\\nu} = -2.5 \\; \\log(h \\lambda \\; \\textnormal{photlam}) - 48.6 where :math:`h` is as defined in :ref:`pysynphot-constants`. Parameters ---------- wave, flux ...
[ "def", "ToABMag", "(", "self", ",", "wave", ",", "flux", ",", "**", "kwargs", ")", ":", "arg", "=", "H", "*", "flux", "*", "wave", "return", "-", "1.085736", "*", "N", ".", "log", "(", "arg", ")", "+", "ABZERO" ]
Convert to ``abmag``. .. math:: \\textnormal{AB}_{\\nu} = -2.5 \\; \\log(h \\lambda \\; \\textnormal{photlam}) - 48.6 where :math:`h` is as defined in :ref:`pysynphot-constants`. Parameters ---------- wave, flux : number or array_like Wavelength and fl...
[ "Convert", "to", "abmag", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/units.py#L800-L824
train
spacetelescope/pysynphot
pysynphot/units.py
Photlam.ToSTMag
def ToSTMag(self, wave, flux, **kwargs): """Convert to ``stmag``. .. math:: \\textnormal{ST}_{\\lambda} = -2.5 \\; \\log(\\frac{hc}{\\lambda} \\; \\textnormal{photlam}) - 21.1 where :math:`h` and :math:`c` are as defined in :ref:`pysynphot-constants`. Parameters ...
python
def ToSTMag(self, wave, flux, **kwargs): """Convert to ``stmag``. .. math:: \\textnormal{ST}_{\\lambda} = -2.5 \\; \\log(\\frac{hc}{\\lambda} \\; \\textnormal{photlam}) - 21.1 where :math:`h` and :math:`c` are as defined in :ref:`pysynphot-constants`. Parameters ...
[ "def", "ToSTMag", "(", "self", ",", "wave", ",", "flux", ",", "**", "kwargs", ")", ":", "arg", "=", "H", "*", "C", "*", "flux", "/", "wave", "return", "-", "1.085736", "*", "N", ".", "log", "(", "arg", ")", "+", "STZERO" ]
Convert to ``stmag``. .. math:: \\textnormal{ST}_{\\lambda} = -2.5 \\; \\log(\\frac{hc}{\\lambda} \\; \\textnormal{photlam}) - 21.1 where :math:`h` and :math:`c` are as defined in :ref:`pysynphot-constants`. Parameters ---------- wave, flux : number or arr...
[ "Convert", "to", "stmag", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/units.py#L826-L851
train
spacetelescope/pysynphot
pysynphot/units.py
Photlam.ToOBMag
def ToOBMag(self, wave, flux, area=None): """Convert to ``obmag``. .. math:: \\textnormal{obmag} = -2.5 \\; \\log(\\delta \\lambda \\; \\times \\; \\textnormal{area} \\; \\times \\; \\textnormal{photlam}) where :math:`\\delta \\lambda` represent bin widths derived from :f...
python
def ToOBMag(self, wave, flux, area=None): """Convert to ``obmag``. .. math:: \\textnormal{obmag} = -2.5 \\; \\log(\\delta \\lambda \\; \\times \\; \\textnormal{area} \\; \\times \\; \\textnormal{photlam}) where :math:`\\delta \\lambda` represent bin widths derived from :f...
[ "def", "ToOBMag", "(", "self", ",", "wave", ",", "flux", ",", "area", "=", "None", ")", ":", "area", "=", "area", "if", "area", "else", "refs", ".", "PRIMARY_AREA", "bin_widths", "=", "binning", ".", "calculate_bin_widths", "(", "binning", ".", "calculat...
Convert to ``obmag``. .. math:: \\textnormal{obmag} = -2.5 \\; \\log(\\delta \\lambda \\; \\times \\; \\textnormal{area} \\; \\times \\; \\textnormal{photlam}) where :math:`\\delta \\lambda` represent bin widths derived from :func:`~pysynphot.binning.calculate_bin_edges` and ...
[ "Convert", "to", "obmag", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/units.py#L853-L884
train
spacetelescope/pysynphot
pysynphot/units.py
Photlam.ToVegaMag
def ToVegaMag(self, wave, flux, **kwargs): """Convert to ``vegamag``. .. math:: \\textnormal{vegamag} = -2.5 \\; \\log(\\frac{\\textnormal{photlam}}{f_{\\textnormal{Vega}}}) where :math:`f_{\\textnormal{Vega}}` is the flux of :ref:`pysynphot-vega-spec` resampled at given w...
python
def ToVegaMag(self, wave, flux, **kwargs): """Convert to ``vegamag``. .. math:: \\textnormal{vegamag} = -2.5 \\; \\log(\\frac{\\textnormal{photlam}}{f_{\\textnormal{Vega}}}) where :math:`f_{\\textnormal{Vega}}` is the flux of :ref:`pysynphot-vega-spec` resampled at given w...
[ "def", "ToVegaMag", "(", "self", ",", "wave", ",", "flux", ",", "**", "kwargs", ")", ":", "from", ".", "import", "spectrum", "resampled", "=", "spectrum", ".", "Vega", ".", "resample", "(", "wave", ")", "normalized", "=", "flux", "/", "resampled", ".",...
Convert to ``vegamag``. .. math:: \\textnormal{vegamag} = -2.5 \\; \\log(\\frac{\\textnormal{photlam}}{f_{\\textnormal{Vega}}}) where :math:`f_{\\textnormal{Vega}}` is the flux of :ref:`pysynphot-vega-spec` resampled at given wavelength values and converted to ``photlam``....
[ "Convert", "to", "vegamag", "." ]
a125ff956f4d94beb157bd51899747a13234bb97
https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/units.py#L886-L914
train
geronimp/graftM
graftm/graftm_package.py
GraftMPackage.acquire
def acquire(graftm_package_path): '''Acquire a new graftm Package Parameters ---------- graftm_output_path: str path to base directory of graftm ''' contents_hash = json.load( open( ...
python
def acquire(graftm_package_path): '''Acquire a new graftm Package Parameters ---------- graftm_output_path: str path to base directory of graftm ''' contents_hash = json.load( open( ...
[ "def", "acquire", "(", "graftm_package_path", ")", ":", "contents_hash", "=", "json", ".", "load", "(", "open", "(", "os", ".", "path", ".", "join", "(", "graftm_package_path", ",", "GraftMPackage", ".", "_CONTENTS_FILE_NAME", ")", ",", ")", ")", "v", "=",...
Acquire a new graftm Package Parameters ---------- graftm_output_path: str path to base directory of graftm
[ "Acquire", "a", "new", "graftm", "Package" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/graftm_package.py#L59-L92
train
geronimp/graftM
graftm/graftm_package.py
GraftMPackage.check_required_keys
def check_required_keys(self, required_keys): '''raise InsufficientGraftMPackageException if this package does not conform to the standard of the given package''' h = self._contents_hash for key in required_keys: if key not in h: raise InsufficientGraftMPackag...
python
def check_required_keys(self, required_keys): '''raise InsufficientGraftMPackageException if this package does not conform to the standard of the given package''' h = self._contents_hash for key in required_keys: if key not in h: raise InsufficientGraftMPackag...
[ "def", "check_required_keys", "(", "self", ",", "required_keys", ")", ":", "h", "=", "self", ".", "_contents_hash", "for", "key", "in", "required_keys", ":", "if", "key", "not", "in", "h", ":", "raise", "InsufficientGraftMPackageException", "(", "\"Package missi...
raise InsufficientGraftMPackageException if this package does not conform to the standard of the given package
[ "raise", "InsufficientGraftMPackageException", "if", "this", "package", "does", "not", "conform", "to", "the", "standard", "of", "the", "given", "package" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/graftm_package.py#L103-L109
train
geronimp/graftM
graftm/graftm_package.py
GraftMPackageVersion2.compile
def compile(output_package_path, refpkg_path, hmm_path, diamond_database_file, max_range, trusted_cutoff=False, search_hmm_files=None): '''Create a new GraftM package with the given inputs. Any files specified as parameters are copied into the final package so can be removed aft...
python
def compile(output_package_path, refpkg_path, hmm_path, diamond_database_file, max_range, trusted_cutoff=False, search_hmm_files=None): '''Create a new GraftM package with the given inputs. Any files specified as parameters are copied into the final package so can be removed aft...
[ "def", "compile", "(", "output_package_path", ",", "refpkg_path", ",", "hmm_path", ",", "diamond_database_file", ",", "max_range", ",", "trusted_cutoff", "=", "False", ",", "search_hmm_files", "=", "None", ")", ":", "if", "os", ".", "path", ".", "exists", "(",...
Create a new GraftM package with the given inputs. Any files specified as parameters are copied into the final package so can be removed after calling this function. Parameters ---------- output_package_path: str path to the package being created (must not exist) ...
[ "Create", "a", "new", "GraftM", "package", "with", "the", "given", "inputs", ".", "Any", "files", "specified", "as", "parameters", "are", "copied", "into", "the", "final", "package", "so", "can", "be", "removed", "after", "calling", "this", "function", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/graftm_package.py#L166-L234
train
geronimp/graftM
graftm/graftm_package.py
GraftMPackageVersion3.create_diamond_db
def create_diamond_db(self): '''Create a diamond database from the unaligned sequences in this package. Returns ------- path to the created diamond db e.g. 'my_sequences.dmnd' ''' base = self.unaligned_sequence_database_path() cmd = "diamond makedb --in '%s' -d '...
python
def create_diamond_db(self): '''Create a diamond database from the unaligned sequences in this package. Returns ------- path to the created diamond db e.g. 'my_sequences.dmnd' ''' base = self.unaligned_sequence_database_path() cmd = "diamond makedb --in '%s' -d '...
[ "def", "create_diamond_db", "(", "self", ")", ":", "base", "=", "self", ".", "unaligned_sequence_database_path", "(", ")", "cmd", "=", "\"diamond makedb --in '%s' -d '%s'\"", "%", "(", "self", ".", "unaligned_sequence_database_path", "(", ")", ",", "base", ")", "e...
Create a diamond database from the unaligned sequences in this package. Returns ------- path to the created diamond db e.g. 'my_sequences.dmnd'
[ "Create", "a", "diamond", "database", "from", "the", "unaligned", "sequences", "in", "this", "package", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/graftm_package.py#L248-L263
train
geronimp/graftM
graftm/graftm_package.py
GraftMPackageVersion3.graftm_package_is_protein
def graftm_package_is_protein(graftm_package): '''Return true if this package is an Amino Acid alignment package, otherwise False i.e. it is a nucleotide package. In general it is best to use 'is_protein_package' instead. ''' found = None with open(graftm_package.alignme...
python
def graftm_package_is_protein(graftm_package): '''Return true if this package is an Amino Acid alignment package, otherwise False i.e. it is a nucleotide package. In general it is best to use 'is_protein_package' instead. ''' found = None with open(graftm_package.alignme...
[ "def", "graftm_package_is_protein", "(", "graftm_package", ")", ":", "found", "=", "None", "with", "open", "(", "graftm_package", ".", "alignment_hmm_path", "(", ")", ")", "as", "f", ":", "r", "=", "f", ".", "read", "(", ")", ".", "split", "(", "\"\\n\""...
Return true if this package is an Amino Acid alignment package, otherwise False i.e. it is a nucleotide package. In general it is best to use 'is_protein_package' instead.
[ "Return", "true", "if", "this", "package", "is", "an", "Amino", "Acid", "alignment", "package", "otherwise", "False", "i", ".", "e", ".", "it", "is", "a", "nucleotide", "package", ".", "In", "general", "it", "is", "best", "to", "use", "is_protein_package",...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/graftm_package.py#L275-L293
train
geronimp/graftM
graftm/graftm_package.py
GraftMPackageVersion3.is_protein_package
def is_protein_package(self): '''Return true if this package is an Amino Acid alignment package, otherwise False i.e. it is a nucleotide package. Cache the result for speed. ''' if not hasattr(self, '_is_protein_package'): self._is_protein_package = GraftMPackageVersion3.gra...
python
def is_protein_package(self): '''Return true if this package is an Amino Acid alignment package, otherwise False i.e. it is a nucleotide package. Cache the result for speed. ''' if not hasattr(self, '_is_protein_package'): self._is_protein_package = GraftMPackageVersion3.gra...
[ "def", "is_protein_package", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_is_protein_package'", ")", ":", "self", ".", "_is_protein_package", "=", "GraftMPackageVersion3", ".", "graftm_package_is_protein", "(", "self", ")", "return", "self",...
Return true if this package is an Amino Acid alignment package, otherwise False i.e. it is a nucleotide package. Cache the result for speed.
[ "Return", "true", "if", "this", "package", "is", "an", "Amino", "Acid", "alignment", "package", "otherwise", "False", "i", ".", "e", ".", "it", "is", "a", "nucleotide", "package", ".", "Cache", "the", "result", "for", "speed", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/graftm_package.py#L295-L302
train
geronimp/graftM
graftm/unpack_sequences.py
UnpackRawReads.basename
def basename(self): '''Return the name of the file with the '.fasta' or 'fq.gz' etc removed''' return os.path.basename(self.read_file)[:-len(self._get_extension(self.read_file))]
python
def basename(self): '''Return the name of the file with the '.fasta' or 'fq.gz' etc removed''' return os.path.basename(self.read_file)[:-len(self._get_extension(self.read_file))]
[ "def", "basename", "(", "self", ")", ":", "return", "os", ".", "path", ".", "basename", "(", "self", ".", "read_file", ")", "[", ":", "-", "len", "(", "self", ".", "_get_extension", "(", "self", ".", "read_file", ")", ")", "]" ]
Return the name of the file with the '.fasta' or 'fq.gz' etc removed
[ "Return", "the", "name", "of", "the", "file", "with", "the", ".", "fasta", "or", "fq", ".", "gz", "etc", "removed" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/unpack_sequences.py#L108-L111
train
geronimp/graftM
graftm/dendropy_tree_cleaner.py
DendropyTreeCleaner.match_alignment_and_tree_sequence_ids
def match_alignment_and_tree_sequence_ids(self, sequence_names, tree): '''Check to make sure that the sequences specified in the alignment and the tree are the same, otherwise raise an Exception detailing the problem for the user to fix Parameters ---------- sequence_nam...
python
def match_alignment_and_tree_sequence_ids(self, sequence_names, tree): '''Check to make sure that the sequences specified in the alignment and the tree are the same, otherwise raise an Exception detailing the problem for the user to fix Parameters ---------- sequence_nam...
[ "def", "match_alignment_and_tree_sequence_ids", "(", "self", ",", "sequence_names", ",", "tree", ")", ":", "tip_names_count", "=", "{", "}", "for", "t", "in", "tree", ".", "leaf_node_iter", "(", ")", ":", "name", "=", "t", ".", "taxon", ".", "label", ".", ...
Check to make sure that the sequences specified in the alignment and the tree are the same, otherwise raise an Exception detailing the problem for the user to fix Parameters ---------- sequence_names: list of str names of sequences to ensure are in the tree t...
[ "Check", "to", "make", "sure", "that", "the", "sequences", "specified", "in", "the", "alignment", "and", "the", "tree", "are", "the", "same", "otherwise", "raise", "an", "Exception", "detailing", "the", "problem", "for", "the", "user", "to", "fix" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/dendropy_tree_cleaner.py#L22-L53
train
geronimp/graftM
graftm/dendropy_tree_cleaner.py
DendropyTreeCleaner.remove_sequences
def remove_sequences(self, tree, sequence_names): '''Remove sequences with in the given sequence_names array from the tree in place. Assumes the sequences are found in the tree, and that they are all unique. Parameters ---------- tree: dendropy.Tree tree to r...
python
def remove_sequences(self, tree, sequence_names): '''Remove sequences with in the given sequence_names array from the tree in place. Assumes the sequences are found in the tree, and that they are all unique. Parameters ---------- tree: dendropy.Tree tree to r...
[ "def", "remove_sequences", "(", "self", ",", "tree", ",", "sequence_names", ")", ":", "tree", ".", "prune_taxa_with_labels", "(", "sequence_names", ")", "tree", ".", "prune_taxa_with_labels", "(", "[", "s", ".", "replace", "(", "'_'", ",", "' '", ")", "for",...
Remove sequences with in the given sequence_names array from the tree in place. Assumes the sequences are found in the tree, and that they are all unique. Parameters ---------- tree: dendropy.Tree tree to remove from sequence_names: list of str li...
[ "Remove", "sequences", "with", "in", "the", "given", "sequence_names", "array", "from", "the", "tree", "in", "place", ".", "Assumes", "the", "sequences", "are", "found", "in", "the", "tree", "and", "that", "they", "are", "all", "unique", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/dendropy_tree_cleaner.py#L55-L69
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher._hmmalign
def _hmmalign(self, input_path, directions, pipeline, forward_reads_output_path, reverse_reads_output_path): ''' Align reads to the aln_hmm. Receives unaligned sequences and aligns them. Parameters ---------- input_path : str Filename of una...
python
def _hmmalign(self, input_path, directions, pipeline, forward_reads_output_path, reverse_reads_output_path): ''' Align reads to the aln_hmm. Receives unaligned sequences and aligns them. Parameters ---------- input_path : str Filename of una...
[ "def", "_hmmalign", "(", "self", ",", "input_path", ",", "directions", ",", "pipeline", ",", "forward_reads_output_path", ",", "reverse_reads_output_path", ")", ":", "if", "pipeline", "==", "PIPELINE_AA", ":", "reverse_direction_reads_present", "=", "False", "else", ...
Align reads to the aln_hmm. Receives unaligned sequences and aligns them. Parameters ---------- input_path : str Filename of unaligned hits to be aligned directions : dict dictionary containing read names as keys, and complement as the entry (...
[ "Align", "reads", "to", "the", "aln_hmm", ".", "Receives", "unaligned", "sequences", "and", "aligns", "them", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L47-L127
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.hmmalign_sequences
def hmmalign_sequences(self, hmm, sequences, output_file): '''Run hmmalign and convert output to aligned fasta format Parameters ---------- hmm: str path to hmm file sequences: str path to file of sequences to be aligned output_file: str ...
python
def hmmalign_sequences(self, hmm, sequences, output_file): '''Run hmmalign and convert output to aligned fasta format Parameters ---------- hmm: str path to hmm file sequences: str path to file of sequences to be aligned output_file: str ...
[ "def", "hmmalign_sequences", "(", "self", ",", "hmm", ",", "sequences", ",", "output_file", ")", ":", "cmd", "=", "'hmmalign --trim %s %s'", "%", "(", "hmm", ",", "sequences", ")", "output", "=", "extern", ".", "run", "(", "cmd", ")", "with", "open", "("...
Run hmmalign and convert output to aligned fasta format Parameters ---------- hmm: str path to hmm file sequences: str path to file of sequences to be aligned output_file: str write sequences to this file Returns ------- ...
[ "Run", "hmmalign", "and", "convert", "output", "to", "aligned", "fasta", "format" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L129-L149
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.hmmsearch
def hmmsearch(self, output_path, input_path, unpack, seq_type, threads, cutoff, orfm): ''' hmmsearch - Search raw reads for hits using search_hmm list Parameters ---------- output_path : str path to output domtblout table input_path : str path to ...
python
def hmmsearch(self, output_path, input_path, unpack, seq_type, threads, cutoff, orfm): ''' hmmsearch - Search raw reads for hits using search_hmm list Parameters ---------- output_path : str path to output domtblout table input_path : str path to ...
[ "def", "hmmsearch", "(", "self", ",", "output_path", ",", "input_path", ",", "unpack", ",", "seq_type", ",", "threads", ",", "cutoff", ",", "orfm", ")", ":", "logging", ".", "debug", "(", "\"Using %i HMMs to search\"", "%", "(", "len", "(", "self", ".", ...
hmmsearch - Search raw reads for hits using search_hmm list Parameters ---------- output_path : str path to output domtblout table input_path : str path to input sequences to search unpack : UnpackRawReads UnpackRawReads object, returns string...
[ "hmmsearch", "-", "Search", "raw", "reads", "for", "hits", "using", "search_hmm", "list" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L155-L223
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.merge_forev_aln
def merge_forev_aln(self, forward_aln_list, reverse_aln_list, outputs): ''' merge_forev_aln - Merges forward and reverse alignments for a given run Parameters ---------- aln_list : array List of the forward and reverse alignments for each of the runs give...
python
def merge_forev_aln(self, forward_aln_list, reverse_aln_list, outputs): ''' merge_forev_aln - Merges forward and reverse alignments for a given run Parameters ---------- aln_list : array List of the forward and reverse alignments for each of the runs give...
[ "def", "merge_forev_aln", "(", "self", ",", "forward_aln_list", ",", "reverse_aln_list", ",", "outputs", ")", ":", "orfm_regex", "=", "OrfM", ".", "regular_expression", "(", ")", "def", "remove_orfm_end", "(", "records", ")", ":", "new_dict", "=", "{", "}", ...
merge_forev_aln - Merges forward and reverse alignments for a given run Parameters ---------- aln_list : array List of the forward and reverse alignments for each of the runs given to graftM. **MUST** be the following pattern: [forward_run1, reverse_run1, for...
[ "merge_forev_aln", "-", "Merges", "forward", "and", "reverse", "alignments", "for", "a", "given", "run" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L225-L300
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.nhmmer
def nhmmer(self, output_path, unpack, threads, evalue): ''' nhmmer - Search input path using nhmmer Parameters ---------- output_path : str A string containing the path to the input sequences unpack : obj UnpackRawReads object, returns string comm...
python
def nhmmer(self, output_path, unpack, threads, evalue): ''' nhmmer - Search input path using nhmmer Parameters ---------- output_path : str A string containing the path to the input sequences unpack : obj UnpackRawReads object, returns string comm...
[ "def", "nhmmer", "(", "self", ",", "output_path", ",", "unpack", ",", "threads", ",", "evalue", ")", ":", "logging", ".", "debug", "(", "\"Using %i HMMs to search\"", "%", "(", "len", "(", "self", ".", "search_hmm", ")", ")", ")", "output_table_list", "=",...
nhmmer - Search input path using nhmmer Parameters ---------- output_path : str A string containing the path to the input sequences unpack : obj UnpackRawReads object, returns string command that will output sequences to stdout when called on command ...
[ "nhmmer", "-", "Search", "input", "path", "using", "nhmmer" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L302-L341
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher._check_euk_contamination
def _check_euk_contamination(self, hmm_hit_tables): ''' check_euk_contamination - Check output HMM tables hits reads that hit the 18S HMM with a higher bit score. Parameters ---------- hmm_hit_tables : array Array of paths to the out...
python
def _check_euk_contamination(self, hmm_hit_tables): ''' check_euk_contamination - Check output HMM tables hits reads that hit the 18S HMM with a higher bit score. Parameters ---------- hmm_hit_tables : array Array of paths to the out...
[ "def", "_check_euk_contamination", "(", "self", ",", "hmm_hit_tables", ")", ":", "euk_hit_table", "=", "HMMreader", "(", "hmm_hit_tables", ".", "pop", "(", "-", "1", ")", ")", "other_hit_tables", "=", "[", "HMMreader", "(", "x", ")", "for", "x", "in", "hmm...
check_euk_contamination - Check output HMM tables hits reads that hit the 18S HMM with a higher bit score. Parameters ---------- hmm_hit_tables : array Array of paths to the output files produced by hmmsearch or nhmmer. run_stats...
[ "check_euk_contamination", "-", "Check", "output", "HMM", "tables", "hits", "reads", "that", "hit", "the", "18S", "HMM", "with", "a", "higher", "bit", "score", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L343-L390
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher._extract_multiple_hits
def _extract_multiple_hits(self, hits, reads_path, output_path): ''' splits out regions of a read that hit the HMM. For example when two of same gene are identified within the same contig, The regions mapping to the HMM will be split out and written out to a new file as a new record. ...
python
def _extract_multiple_hits(self, hits, reads_path, output_path): ''' splits out regions of a read that hit the HMM. For example when two of same gene are identified within the same contig, The regions mapping to the HMM will be split out and written out to a new file as a new record. ...
[ "def", "_extract_multiple_hits", "(", "self", ",", "hits", ",", "reads_path", ",", "output_path", ")", ":", "complement_information", "=", "{", "}", "try", ":", "reads", "=", "SeqIO", ".", "to_dict", "(", "SeqIO", ".", "parse", "(", "reads_path", ",", "\"f...
splits out regions of a read that hit the HMM. For example when two of same gene are identified within the same contig, The regions mapping to the HMM will be split out and written out to a new file as a new record. Parameters ---------- hits : dict A dictionary wher...
[ "splits", "out", "regions", "of", "a", "read", "that", "hit", "the", "HMM", ".", "For", "example", "when", "two", "of", "same", "gene", "are", "identified", "within", "the", "same", "contig", "The", "regions", "mapping", "to", "the", "HMM", "will", "be",...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L393-L449
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.alignment_correcter
def alignment_correcter(self, alignment_file_list, output_file_name, filter_minimum=None): ''' Remove lower case insertions in alignment outputs from HMM align. Give a list of alignments, and an output file name, and each alignment will be corrected, and writt...
python
def alignment_correcter(self, alignment_file_list, output_file_name, filter_minimum=None): ''' Remove lower case insertions in alignment outputs from HMM align. Give a list of alignments, and an output file name, and each alignment will be corrected, and writt...
[ "def", "alignment_correcter", "(", "self", ",", "alignment_file_list", ",", "output_file_name", ",", "filter_minimum", "=", "None", ")", ":", "corrected_sequences", "=", "{", "}", "for", "alignment_file", "in", "alignment_file_list", ":", "insert_list", "=", "[", ...
Remove lower case insertions in alignment outputs from HMM align. Give a list of alignments, and an output file name, and each alignment will be corrected, and written to a single file, ready to be placed together using pplacer. Parameters ---------- alignment_file_list ...
[ "Remove", "lower", "case", "insertions", "in", "alignment", "outputs", "from", "HMM", "align", ".", "Give", "a", "list", "of", "alignments", "and", "an", "output", "file", "name", "and", "each", "alignment", "will", "be", "corrected", "and", "written", "to",...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L509-L567
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher._extract_orfs
def _extract_orfs(self, input_path, orfm, hit_readnames, output_path, search_method, sequence_frame_info_list=None): ''' Call ORFs on a file with nucleotide sequences and extract the proteins whose name is in `hit_readnames`. Parameters ---------- input_path : str ...
python
def _extract_orfs(self, input_path, orfm, hit_readnames, output_path, search_method, sequence_frame_info_list=None): ''' Call ORFs on a file with nucleotide sequences and extract the proteins whose name is in `hit_readnames`. Parameters ---------- input_path : str ...
[ "def", "_extract_orfs", "(", "self", ",", "input_path", ",", "orfm", ",", "hit_readnames", ",", "output_path", ",", "search_method", ",", "sequence_frame_info_list", "=", "None", ")", ":", "if", "search_method", "==", "\"hmmsearch\"", ":", "orfm_cmd", "=", "orfm...
Call ORFs on a file with nucleotide sequences and extract the proteins whose name is in `hit_readnames`. Parameters ---------- input_path : str Path to input nucleotide sequences in FASTA format. orfm: obj graftm.OrfM object with parameters already set ...
[ "Call", "ORFs", "on", "a", "file", "with", "nucleotide", "sequences", "and", "extract", "the", "proteins", "whose", "name", "is", "in", "hit_readnames", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L570-L615
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.aa_db_search
def aa_db_search(self, files, base, unpack, search_method, maximum_range, threads, evalue, min_orf_length, restrict_read_length, diamond_database): ''' Amino acid database search pipeline - pipeline where reads are searched as amino acids, and hits are i...
python
def aa_db_search(self, files, base, unpack, search_method, maximum_range, threads, evalue, min_orf_length, restrict_read_length, diamond_database): ''' Amino acid database search pipeline - pipeline where reads are searched as amino acids, and hits are i...
[ "def", "aa_db_search", "(", "self", ",", "files", ",", "base", ",", "unpack", ",", "search_method", ",", "maximum_range", ",", "threads", ",", "evalue", ",", "min_orf_length", ",", "restrict_read_length", ",", "diamond_database", ")", ":", "if", "search_method",...
Amino acid database search pipeline - pipeline where reads are searched as amino acids, and hits are identified using hmmsearch or diamond searches Parameters ---------- files : obj graftm_output_paths object. base : str The name of the input file...
[ "Amino", "acid", "database", "search", "pipeline", "-", "pipeline", "where", "reads", "are", "searched", "as", "amino", "acids", "and", "hits", "are", "identified", "using", "hmmsearch", "or", "diamond", "searches" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L760-L821
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.nt_db_search
def nt_db_search(self, files, base, unpack, euk_check, search_method, maximum_range, threads, evalue): ''' Nucleotide database search pipeline - pipeline where reads are searched as nucleotides, and hits are identified using nhmmer searches Parameters ------...
python
def nt_db_search(self, files, base, unpack, euk_check, search_method, maximum_range, threads, evalue): ''' Nucleotide database search pipeline - pipeline where reads are searched as nucleotides, and hits are identified using nhmmer searches Parameters ------...
[ "def", "nt_db_search", "(", "self", ",", "files", ",", "base", ",", "unpack", ",", "euk_check", ",", "search_method", ",", "maximum_range", ",", "threads", ",", "evalue", ")", ":", "hmmsearch_output_table", "=", "files", ".", "hmmsearch_output_path", "(", "bas...
Nucleotide database search pipeline - pipeline where reads are searched as nucleotides, and hits are identified using nhmmer searches Parameters ---------- files : obj graftm_output_paths object. base : str The name of the input file, stripped of all suff...
[ "Nucleotide", "database", "search", "pipeline", "-", "pipeline", "where", "reads", "are", "searched", "as", "nucleotides", "and", "hits", "are", "identified", "using", "nhmmer", "searches" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L964-L1013
train
geronimp/graftM
graftm/sequence_searcher.py
SequenceSearcher.align
def align(self, input_path, output_path, directions, pipeline, filter_minimum): '''align - Takes input path to fasta of unaligned reads, aligns them to a HMM, and returns the aligned reads in the output path Parameters ---------- input_path : str output_pa...
python
def align(self, input_path, output_path, directions, pipeline, filter_minimum): '''align - Takes input path to fasta of unaligned reads, aligns them to a HMM, and returns the aligned reads in the output path Parameters ---------- input_path : str output_pa...
[ "def", "align", "(", "self", ",", "input_path", ",", "output_path", ",", "directions", ",", "pipeline", ",", "filter_minimum", ")", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", "prefix", "=", "'for_conv_file'", ",", "suffix", "=", "'.fa'", ")", "...
align - Takes input path to fasta of unaligned reads, aligns them to a HMM, and returns the aligned reads in the output path Parameters ---------- input_path : str output_path : str reverse_direction : dict A dictionary of read names, with the entries being t...
[ "align", "-", "Takes", "input", "path", "to", "fasta", "of", "unaligned", "reads", "aligns", "them", "to", "a", "HMM", "and", "returns", "the", "aligned", "reads", "in", "the", "output", "path" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_searcher.py#L1111-L1147
train
geronimp/graftM
graftm/rerooter.py
Rerooter.reroot_by_tree
def reroot_by_tree(self, old_tree, new_tree): '''reroot the new tree so that it matches the old tree's root, if possible. If more than one rerooting is possible, root at the longest internal branch that is consistent with the root of the old_tree. Assumes that the tree is binary. Both ...
python
def reroot_by_tree(self, old_tree, new_tree): '''reroot the new tree so that it matches the old tree's root, if possible. If more than one rerooting is possible, root at the longest internal branch that is consistent with the root of the old_tree. Assumes that the tree is binary. Both ...
[ "def", "reroot_by_tree", "(", "self", ",", "old_tree", ",", "new_tree", ")", ":", "old_tree", ".", "is_rooted", "=", "True", "new_tree", ".", "is_rooted", "=", "True", "if", "len", "(", "old_tree", ".", "seed_node", ".", "child_nodes", "(", ")", ")", "!=...
reroot the new tree so that it matches the old tree's root, if possible. If more than one rerooting is possible, root at the longest internal branch that is consistent with the root of the old_tree. Assumes that the tree is binary. Both the old and new trees may be modified by this met...
[ "reroot", "the", "new", "tree", "so", "that", "it", "matches", "the", "old", "tree", "s", "root", "if", "possible", ".", "If", "more", "than", "one", "rerooting", "is", "possible", "root", "at", "the", "longest", "internal", "branch", "that", "is", "cons...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/rerooter.py#L89-L154
train
geronimp/graftM
graftm/run.py
Run._assign_taxonomy_with_diamond
def _assign_taxonomy_with_diamond(self, base_list, db_search_results, graftm_package, graftm_files): '''Run diamond to assign taxonomy Parameters ---------- base_list: list of str list of sequence block names db_search_results: l...
python
def _assign_taxonomy_with_diamond(self, base_list, db_search_results, graftm_package, graftm_files): '''Run diamond to assign taxonomy Parameters ---------- base_list: list of str list of sequence block names db_search_results: l...
[ "def", "_assign_taxonomy_with_diamond", "(", "self", ",", "base_list", ",", "db_search_results", ",", "graftm_package", ",", "graftm_files", ")", ":", "runner", "=", "Diamond", "(", "graftm_package", ".", "diamond_database_path", "(", ")", ",", "self", ".", "args"...
Run diamond to assign taxonomy Parameters ---------- base_list: list of str list of sequence block names db_search_results: list of DBSearchResult the result of running hmmsearches graftm_package: GraftMPackage object Diamond is run against th...
[ "Run", "diamond", "to", "assign", "taxonomy" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/run.py#L514-L573
train
geronimp/graftM
graftm/update.py
Update._concatenate_file
def _concatenate_file(self, file_list, output): ''' Call unix "cat" to concatenate a list of files Parameters ---------- file_list: list List of strings, each leading to a file. These files are the ones to be concatenate together. E.g.: ["...
python
def _concatenate_file(self, file_list, output): ''' Call unix "cat" to concatenate a list of files Parameters ---------- file_list: list List of strings, each leading to a file. These files are the ones to be concatenate together. E.g.: ["...
[ "def", "_concatenate_file", "(", "self", ",", "file_list", ",", "output", ")", ":", "to_cat", "=", "' '", ".", "join", "(", "file_list", ")", "logging", ".", "debug", "(", "\"Concatenating files: %s\"", "%", "(", "to_cat", ")", ")", "cmd", "=", "\"cat %s >...
Call unix "cat" to concatenate a list of files Parameters ---------- file_list: list List of strings, each leading to a file. These files are the ones to be concatenate together. E.g.: ["/path/to/file1", "/path/to/file2"] output: str P...
[ "Call", "unix", "cat", "to", "concatenate", "a", "list", "of", "files" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/update.py#L24-L42
train
geronimp/graftM
graftm/greengenes_taxonomy.py
GreenGenesTaxonomy.write
def write(self, output_io): '''Write a taxonomy to an open stream out in GG format. Code calling this function must open and close the io object.''' for name, tax in self.taxonomy.items(): output_io.write("%s\t%s\n" % (name, '; '.join(tax)))
python
def write(self, output_io): '''Write a taxonomy to an open stream out in GG format. Code calling this function must open and close the io object.''' for name, tax in self.taxonomy.items(): output_io.write("%s\t%s\n" % (name, '; '.join(tax)))
[ "def", "write", "(", "self", ",", "output_io", ")", ":", "for", "name", ",", "tax", "in", "self", ".", "taxonomy", ".", "items", "(", ")", ":", "output_io", ".", "write", "(", "\"%s\\t%s\\n\"", "%", "(", "name", ",", "'; '", ".", "join", "(", "tax"...
Write a taxonomy to an open stream out in GG format. Code calling this function must open and close the io object.
[ "Write", "a", "taxonomy", "to", "an", "open", "stream", "out", "in", "GG", "format", ".", "Code", "calling", "this", "function", "must", "open", "and", "close", "the", "io", "object", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/greengenes_taxonomy.py#L55-L59
train
geronimp/graftM
graftm/decorator.py
Decorator._reroot
def _reroot(self): '''Run the re-rooting algorithm in the Rerooter class.''' rerooter = Rerooter() self.tree = rerooter.reroot_by_tree(self.reference_tree, self.tree)
python
def _reroot(self): '''Run the re-rooting algorithm in the Rerooter class.''' rerooter = Rerooter() self.tree = rerooter.reroot_by_tree(self.reference_tree, self.tree)
[ "def", "_reroot", "(", "self", ")", ":", "rerooter", "=", "Rerooter", "(", ")", "self", ".", "tree", "=", "rerooter", ".", "reroot_by_tree", "(", "self", ".", "reference_tree", ",", "self", ".", "tree", ")" ]
Run the re-rooting algorithm in the Rerooter class.
[ "Run", "the", "re", "-", "rooting", "algorithm", "in", "the", "Rerooter", "class", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/decorator.py#L46-L50
train
geronimp/graftM
graftm/housekeeping.py
HouseKeeping.file_basename
def file_basename(self, file): ''' Strips the path and last extension from the file variable. If the extension is found to be valid, the basename will be returned. Otherwise an error will be raise and graftM will exit ''' valid_extensions = set(".tree", ...
python
def file_basename(self, file): ''' Strips the path and last extension from the file variable. If the extension is found to be valid, the basename will be returned. Otherwise an error will be raise and graftM will exit ''' valid_extensions = set(".tree", ...
[ "def", "file_basename", "(", "self", ",", "file", ")", ":", "valid_extensions", "=", "set", "(", "\".tree\"", ",", "\".tre\"", ")", "split_file", "=", "os", ".", "path", ".", "basename", "(", "file", ")", ".", "split", "(", "'.'", ")", "base", ",", "...
Strips the path and last extension from the file variable. If the extension is found to be valid, the basename will be returned. Otherwise an error will be raise and graftM will exit
[ "Strips", "the", "path", "and", "last", "extension", "from", "the", "file", "variable", ".", "If", "the", "extension", "is", "found", "to", "be", "valid", "the", "basename", "will", "be", "returned", ".", "Otherwise", "an", "error", "will", "be", "raise", ...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/housekeeping.py#L24-L41
train
geronimp/graftM
graftm/housekeeping.py
HouseKeeping.set_euk_hmm
def set_euk_hmm(self, args): 'Set the hmm used by graftM to cross check for euks.' if hasattr(args, 'euk_hmm_file'): pass elif not hasattr(args, 'euk_hmm_file'): # set to path based on the location of bin/graftM, which has # a more stable relative path to the ...
python
def set_euk_hmm(self, args): 'Set the hmm used by graftM to cross check for euks.' if hasattr(args, 'euk_hmm_file'): pass elif not hasattr(args, 'euk_hmm_file'): # set to path based on the location of bin/graftM, which has # a more stable relative path to the ...
[ "def", "set_euk_hmm", "(", "self", ",", "args", ")", ":", "'Set the hmm used by graftM to cross check for euks.'", "if", "hasattr", "(", "args", ",", "'euk_hmm_file'", ")", ":", "pass", "elif", "not", "hasattr", "(", "args", ",", "'euk_hmm_file'", ")", ":", "set...
Set the hmm used by graftM to cross check for euks.
[ "Set", "the", "hmm", "used", "by", "graftM", "to", "cross", "check", "for", "euks", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/housekeeping.py#L44-L54
train
geronimp/graftM
graftm/housekeeping.py
HouseKeeping.get_maximum_range
def get_maximum_range(self, hmm): ''' If no maximum range has been specified, and if using a hmm search, a maximum range can be determined by using the length of the HMM Parameters ---------- hmm : str path to hmm profile Returns ------- ...
python
def get_maximum_range(self, hmm): ''' If no maximum range has been specified, and if using a hmm search, a maximum range can be determined by using the length of the HMM Parameters ---------- hmm : str path to hmm profile Returns ------- ...
[ "def", "get_maximum_range", "(", "self", ",", "hmm", ")", ":", "length", "=", "int", "(", "[", "x", "for", "x", "in", "open", "(", "hmm", ")", "if", "x", ".", "startswith", "(", "\"LENG\"", ")", "]", "[", "0", "]", ".", "split", "(", ")", "[", ...
If no maximum range has been specified, and if using a hmm search, a maximum range can be determined by using the length of the HMM Parameters ---------- hmm : str path to hmm profile Returns ------- Length to search to when linking hits on a single ...
[ "If", "no", "maximum", "range", "has", "been", "specified", "and", "if", "using", "a", "hmm", "search", "a", "maximum", "range", "can", "be", "determined", "by", "using", "the", "length", "of", "the", "HMM" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/housekeeping.py#L128-L145
train
geronimp/graftM
graftm/pplacer.py
Pplacer.place
def place(self, reverse_pipe, seqs_list, resolve_placements, files, args, slash_endings, tax_descr, clusterer): ''' placement - This is the placement pipeline in GraftM, in aligned reads are placed into phylogenetic trees, and the results interpreted. ...
python
def place(self, reverse_pipe, seqs_list, resolve_placements, files, args, slash_endings, tax_descr, clusterer): ''' placement - This is the placement pipeline in GraftM, in aligned reads are placed into phylogenetic trees, and the results interpreted. ...
[ "def", "place", "(", "self", ",", "reverse_pipe", ",", "seqs_list", ",", "resolve_placements", ",", "files", ",", "args", ",", "slash_endings", ",", "tax_descr", ",", "clusterer", ")", ":", "trusted_placements", "=", "{", "}", "files_to_delete", "=", "[", "]...
placement - This is the placement pipeline in GraftM, in aligned reads are placed into phylogenetic trees, and the results interpreted. If reverse reads are used, this is where the comparisons are made between placements, for the summary tables to be build in ...
[ "placement", "-", "This", "is", "the", "placement", "pipeline", "in", "GraftM", "in", "aligned", "reads", "are", "placed", "into", "phylogenetic", "trees", "and", "the", "results", "interpreted", ".", "If", "reverse", "reads", "are", "used", "this", "is", "w...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/pplacer.py#L145-L244
train
geronimp/graftM
graftm/sequence_extractor.py
SequenceExtractor.extract
def extract(self, reads_to_extract, database_fasta_file, output_file): '''Extract the reads_to_extract from the database_fasta_file and put them in output_file. Parameters ---------- reads_to_extract: Iterable of str IDs of reads to be extracted database_fast...
python
def extract(self, reads_to_extract, database_fasta_file, output_file): '''Extract the reads_to_extract from the database_fasta_file and put them in output_file. Parameters ---------- reads_to_extract: Iterable of str IDs of reads to be extracted database_fast...
[ "def", "extract", "(", "self", ",", "reads_to_extract", ",", "database_fasta_file", ",", "output_file", ")", ":", "cmd", "=", "\"fxtract -XH -f /dev/stdin '%s' > %s\"", "%", "(", "database_fasta_file", ",", "output_file", ")", "extern", ".", "run", "(", "cmd", ","...
Extract the reads_to_extract from the database_fasta_file and put them in output_file. Parameters ---------- reads_to_extract: Iterable of str IDs of reads to be extracted database_fasta_file: str path the fasta file that containing the reads outp...
[ "Extract", "the", "reads_to_extract", "from", "the", "database_fasta_file", "and", "put", "them", "in", "output_file", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_extractor.py#L6-L25
train
geronimp/graftM
graftm/sequence_extractor.py
SequenceExtractor.extract_forward_and_reverse_complement
def extract_forward_and_reverse_complement( self, forward_reads_to_extract, reverse_reads_to_extract, database_fasta_file, output_file): '''As per extract except also reverse complement the sequences.''' self.extract(forward_reads_to_extract, database_fasta_file, output_file) ...
python
def extract_forward_and_reverse_complement( self, forward_reads_to_extract, reverse_reads_to_extract, database_fasta_file, output_file): '''As per extract except also reverse complement the sequences.''' self.extract(forward_reads_to_extract, database_fasta_file, output_file) ...
[ "def", "extract_forward_and_reverse_complement", "(", "self", ",", "forward_reads_to_extract", ",", "reverse_reads_to_extract", ",", "database_fasta_file", ",", "output_file", ")", ":", "self", ".", "extract", "(", "forward_reads_to_extract", ",", "database_fasta_file", ","...
As per extract except also reverse complement the sequences.
[ "As", "per", "extract", "except", "also", "reverse", "complement", "the", "sequences", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_extractor.py#L27-L39
train
geronimp/graftM
graftm/summarise.py
Stats_And_Summary.write_tabular_otu_table
def write_tabular_otu_table(self, sample_names, read_taxonomies, combined_output_otu_table_io): '''A function that takes a hash of trusted placements, and compiles them into an OTU-esque table.''' delim = u'\t' combined_output_otu_table_io.write(delim.join(['#ID', ...
python
def write_tabular_otu_table(self, sample_names, read_taxonomies, combined_output_otu_table_io): '''A function that takes a hash of trusted placements, and compiles them into an OTU-esque table.''' delim = u'\t' combined_output_otu_table_io.write(delim.join(['#ID', ...
[ "def", "write_tabular_otu_table", "(", "self", ",", "sample_names", ",", "read_taxonomies", ",", "combined_output_otu_table_io", ")", ":", "delim", "=", "u'\\t'", "combined_output_otu_table_io", ".", "write", "(", "delim", ".", "join", "(", "[", "'#ID'", ",", "del...
A function that takes a hash of trusted placements, and compiles them into an OTU-esque table.
[ "A", "function", "that", "takes", "a", "hash", "of", "trusted", "placements", "and", "compiles", "them", "into", "an", "OTU", "-", "esque", "table", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/summarise.py#L147-L159
train
geronimp/graftM
graftm/summarise.py
Stats_And_Summary.write_krona_plot
def write_krona_plot(self, sample_names, read_taxonomies, output_krona_filename): '''Creates krona plot at the given location. Assumes the krona executable ktImportText is available on the shell PATH''' tempfiles = [] for n in sample_names: tempfiles.append(tempfile.NamedTemp...
python
def write_krona_plot(self, sample_names, read_taxonomies, output_krona_filename): '''Creates krona plot at the given location. Assumes the krona executable ktImportText is available on the shell PATH''' tempfiles = [] for n in sample_names: tempfiles.append(tempfile.NamedTemp...
[ "def", "write_krona_plot", "(", "self", ",", "sample_names", ",", "read_taxonomies", ",", "output_krona_filename", ")", ":", "tempfiles", "=", "[", "]", "for", "n", "in", "sample_names", ":", "tempfiles", ".", "append", "(", "tempfile", ".", "NamedTemporaryFile"...
Creates krona plot at the given location. Assumes the krona executable ktImportText is available on the shell PATH
[ "Creates", "krona", "plot", "at", "the", "given", "location", ".", "Assumes", "the", "krona", "executable", "ktImportText", "is", "available", "on", "the", "shell", "PATH" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/summarise.py#L161-L189
train
geronimp/graftM
graftm/clusterer.py
Clusterer.uncluster_annotations
def uncluster_annotations(self, input_annotations, reverse_pipe): ''' Update the annotations hash provided by pplacer to include all representatives within each cluster Parameters ---------- input_annotations : hash Classifications for each representative seq...
python
def uncluster_annotations(self, input_annotations, reverse_pipe): ''' Update the annotations hash provided by pplacer to include all representatives within each cluster Parameters ---------- input_annotations : hash Classifications for each representative seq...
[ "def", "uncluster_annotations", "(", "self", ",", "input_annotations", ",", "reverse_pipe", ")", ":", "output_annotations", "=", "{", "}", "for", "placed_alignment_file_path", ",", "clusters", "in", "self", ".", "seq_library", ".", "iteritems", "(", ")", ":", "i...
Update the annotations hash provided by pplacer to include all representatives within each cluster Parameters ---------- input_annotations : hash Classifications for each representative sequence of the clusters. each key being the sequence name, and the entry bei...
[ "Update", "the", "annotations", "hash", "provided", "by", "pplacer", "to", "include", "all", "representatives", "within", "each", "cluster" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/clusterer.py#L16-L56
train
geronimp/graftM
graftm/clusterer.py
Clusterer.cluster
def cluster(self, input_fasta_list, reverse_pipe): ''' cluster - Clusters reads at 100% identity level and writes them to file. Resets the input_fasta variable as the FASTA file containing the clusters. Parameters ---------- input_fasta_list : list l...
python
def cluster(self, input_fasta_list, reverse_pipe): ''' cluster - Clusters reads at 100% identity level and writes them to file. Resets the input_fasta variable as the FASTA file containing the clusters. Parameters ---------- input_fasta_list : list l...
[ "def", "cluster", "(", "self", ",", "input_fasta_list", ",", "reverse_pipe", ")", ":", "output_fasta_list", "=", "[", "]", "for", "input_fasta", "in", "input_fasta_list", ":", "output_path", "=", "input_fasta", ".", "replace", "(", "'_hits.aln.fa'", ",", "'_clus...
cluster - Clusters reads at 100% identity level and writes them to file. Resets the input_fasta variable as the FASTA file containing the clusters. Parameters ---------- input_fasta_list : list list of strings, each a path to input fasta files to be clustered. ...
[ "cluster", "-", "Clusters", "reads", "at", "100%", "identity", "level", "and", "writes", "them", "to", "file", ".", "Resets", "the", "input_fasta", "variable", "as", "the", "FASTA", "file", "containing", "the", "clusters", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/clusterer.py#L58-L102
train
geronimp/graftM
graftm/archive.py
Archive.create
def create(self, input_package_path, output_package_path, **kwargs): """Create an archived GraftM package Parameters ---------- input_package_path: str path to gpkg to be archived output_pacakge_path: str output package path kwargs: fo...
python
def create(self, input_package_path, output_package_path, **kwargs): """Create an archived GraftM package Parameters ---------- input_package_path: str path to gpkg to be archived output_pacakge_path: str output package path kwargs: fo...
[ "def", "create", "(", "self", ",", "input_package_path", ",", "output_package_path", ",", "**", "kwargs", ")", ":", "force", "=", "kwargs", ".", "pop", "(", "'force'", ",", "ArchiveDefaultOptions", ".", "force", ")", "if", "len", "(", "kwargs", ")", ">", ...
Create an archived GraftM package Parameters ---------- input_package_path: str path to gpkg to be archived output_pacakge_path: str output package path kwargs: force: bool overwrite an existing directory
[ "Create", "an", "archived", "GraftM", "package" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/archive.py#L14-L51
train
geronimp/graftM
graftm/archive.py
Archive.extract
def extract(self, archive_path, output_package_path, **kwargs): '''Extract an archived GraftM package. Parameters ---------- archive_path: str path to archive output_package_path: str path to where to put the extracted file kwargs: for...
python
def extract(self, archive_path, output_package_path, **kwargs): '''Extract an archived GraftM package. Parameters ---------- archive_path: str path to archive output_package_path: str path to where to put the extracted file kwargs: for...
[ "def", "extract", "(", "self", ",", "archive_path", ",", "output_package_path", ",", "**", "kwargs", ")", ":", "force", "=", "kwargs", ".", "pop", "(", "'force'", ",", "ArchiveDefaultOptions", ".", "force", ")", "if", "len", "(", "kwargs", ")", ">", "0",...
Extract an archived GraftM package. Parameters ---------- archive_path: str path to archive output_package_path: str path to where to put the extracted file kwargs: force: bool overwrite an existing directory
[ "Extract", "an", "archived", "GraftM", "package", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/archive.py#L53-L93
train
geronimp/graftM
graftm/archive.py
Archive._setup_output
def _setup_output(self, path, force): '''Clear the way for an output to be placed at path''' # Allow for special case of output being a pipe if os.path.isdir(path) or os.path.isfile(path): if force: logging.warn("Deleting previous file/directory '%s'" % path) ...
python
def _setup_output(self, path, force): '''Clear the way for an output to be placed at path''' # Allow for special case of output being a pipe if os.path.isdir(path) or os.path.isfile(path): if force: logging.warn("Deleting previous file/directory '%s'" % path) ...
[ "def", "_setup_output", "(", "self", ",", "path", ",", "force", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", "or", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "if", "force", ":", "logging", ".", "warn", "(", "...
Clear the way for an output to be placed at path
[ "Clear", "the", "way", "for", "an", "output", "to", "be", "placed", "at", "path" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/archive.py#L95-L106
train
geronimp/graftM
graftm/sequence_search_results.py
HMMSearchResult.import_from_nhmmer_table
def import_from_nhmmer_table(hmmout_path): '''Generate new results object from the output of nhmmer search''' # nhmmer format is # qseqid queryname hmmfrom hmmto alifrom alito envfrom envto sqlen strand evalue bitscore bias description # 0 2 4 5 6 7 8 ...
python
def import_from_nhmmer_table(hmmout_path): '''Generate new results object from the output of nhmmer search''' # nhmmer format is # qseqid queryname hmmfrom hmmto alifrom alito envfrom envto sqlen strand evalue bitscore bias description # 0 2 4 5 6 7 8 ...
[ "def", "import_from_nhmmer_table", "(", "hmmout_path", ")", ":", "res", "=", "HMMSearchResult", "(", ")", "res", ".", "fields", "=", "[", "SequenceSearchResult", ".", "QUERY_ID_FIELD", ",", "SequenceSearchResult", ".", "HMM_NAME_FIELD", ",", "SequenceSearchResult", ...
Generate new results object from the output of nhmmer search
[ "Generate", "new", "results", "object", "from", "the", "output", "of", "nhmmer", "search" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_search_results.py#L115-L147
train
geronimp/graftM
graftm/hmmsearcher.py
HmmSearcher.hmmsearch
def hmmsearch(self, input_pipe, hmms, output_files): r"""Run HMMsearch with all the HMMs, generating output files Parameters ---------- input_pipe: String A string which is a partial command line. When this command is run is outputs to STDOUT fasta formatted prot...
python
def hmmsearch(self, input_pipe, hmms, output_files): r"""Run HMMsearch with all the HMMs, generating output files Parameters ---------- input_pipe: String A string which is a partial command line. When this command is run is outputs to STDOUT fasta formatted prot...
[ "def", "hmmsearch", "(", "self", ",", "input_pipe", ",", "hmms", ",", "output_files", ")", ":", "r", "if", "len", "(", "hmms", ")", "!=", "len", "(", "output_files", ")", ":", "raise", "Exception", "(", "\"Programming error: number of supplied HMMs differs from ...
r"""Run HMMsearch with all the HMMs, generating output files Parameters ---------- input_pipe: String A string which is a partial command line. When this command is run is outputs to STDOUT fasta formatted protein sequences, which hmmsearch runs on. h...
[ "r", "Run", "HMMsearch", "with", "all", "the", "HMMs", "generating", "output", "files" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/hmmsearcher.py#L25-L69
train
geronimp/graftM
graftm/hmmsearcher.py
HmmSearcher._munch_off_batch
def _munch_off_batch(self, queue): r"""Take a batch of sequences off the queue, and return pairs_to_run. The queue given as a parameter is affected """ # if the number of CPUs used == 1, just pop one off (which == below) # elif the the number of things in the queue is 1, use all...
python
def _munch_off_batch(self, queue): r"""Take a batch of sequences off the queue, and return pairs_to_run. The queue given as a parameter is affected """ # if the number of CPUs used == 1, just pop one off (which == below) # elif the the number of things in the queue is 1, use all...
[ "def", "_munch_off_batch", "(", "self", ",", "queue", ")", ":", "r", "if", "len", "(", "queue", ")", "==", "1", "or", "self", ".", "_num_cpus", "==", "1", ":", "pairs_to_run", "=", "[", "[", "queue", ".", "pop", "(", "0", ")", ",", "self", ".", ...
r"""Take a batch of sequences off the queue, and return pairs_to_run. The queue given as a parameter is affected
[ "r", "Take", "a", "batch", "of", "sequences", "off", "the", "queue", "and", "return", "pairs_to_run", ".", "The", "queue", "given", "as", "a", "parameter", "is", "affected" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/hmmsearcher.py#L71-L93
train
geronimp/graftM
graftm/hmmsearcher.py
HmmSearcher._hmm_command
def _hmm_command(self, input_pipe, pairs_to_run): r"""INTERNAL method for getting cmdline for running a batch of HMMs. Parameters ---------- input_pipe: as hmmsearch pairs_to_run: list list with 2 members: (1) list of hmm and output file, (2) number of CP...
python
def _hmm_command(self, input_pipe, pairs_to_run): r"""INTERNAL method for getting cmdline for running a batch of HMMs. Parameters ---------- input_pipe: as hmmsearch pairs_to_run: list list with 2 members: (1) list of hmm and output file, (2) number of CP...
[ "def", "_hmm_command", "(", "self", ",", "input_pipe", ",", "pairs_to_run", ")", ":", "r", "element", "=", "pairs_to_run", ".", "pop", "(", ")", "hmmsearch_cmd", "=", "self", ".", "_individual_hmm_command", "(", "element", "[", "0", "]", "[", "0", "]", "...
r"""INTERNAL method for getting cmdline for running a batch of HMMs. Parameters ---------- input_pipe: as hmmsearch pairs_to_run: list list with 2 members: (1) list of hmm and output file, (2) number of CPUs to use when searching Returns ------- ...
[ "r", "INTERNAL", "method", "for", "getting", "cmdline", "for", "running", "a", "batch", "of", "HMMs", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/hmmsearcher.py#L97-L124
train
geronimp/graftM
graftm/create.py
Create._parse_contents
def _parse_contents(self, contents_file_path): ''' Parse the contents .json file and return the dictionary Parameters ---------- contents_file_path: str Path to file containing .json file to parse. Returns ------- contents_dict: dict ...
python
def _parse_contents(self, contents_file_path): ''' Parse the contents .json file and return the dictionary Parameters ---------- contents_file_path: str Path to file containing .json file to parse. Returns ------- contents_dict: dict ...
[ "def", "_parse_contents", "(", "self", ",", "contents_file_path", ")", ":", "logging", ".", "debug", "(", "\"Parsing %s\"", "%", "(", "contents_file_path", ")", ")", "contents_dict", "=", "json", ".", "load", "(", "open", "(", "contents_file_path", ")", ")", ...
Parse the contents .json file and return the dictionary Parameters ---------- contents_file_path: str Path to file containing .json file to parse. Returns ------- contents_dict: dict parsed .json file
[ "Parse", "the", "contents", ".", "json", "file", "and", "return", "the", "dictionary" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L54-L70
train
geronimp/graftM
graftm/create.py
Create._check_reads_hit
def _check_reads_hit(self, alignment_io, min_aligned_fraction): '''Given an alignment return a list of sequence names that are less than the min_aligned_fraction''' to_return = [] alignment_length = None for s in SeqIO.parse(alignment_io, "fasta"): if not alignment_le...
python
def _check_reads_hit(self, alignment_io, min_aligned_fraction): '''Given an alignment return a list of sequence names that are less than the min_aligned_fraction''' to_return = [] alignment_length = None for s in SeqIO.parse(alignment_io, "fasta"): if not alignment_le...
[ "def", "_check_reads_hit", "(", "self", ",", "alignment_io", ",", "min_aligned_fraction", ")", ":", "to_return", "=", "[", "]", "alignment_length", "=", "None", "for", "s", "in", "SeqIO", ".", "parse", "(", "alignment_io", ",", "\"fasta\"", ")", ":", "if", ...
Given an alignment return a list of sequence names that are less than the min_aligned_fraction
[ "Given", "an", "alignment", "return", "a", "list", "of", "sequence", "names", "that", "are", "less", "than", "the", "min_aligned_fraction" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L72-L90
train
geronimp/graftM
graftm/create.py
Create._align_sequences
def _align_sequences(self, input_sequences_path, output_alignment_path, threads): '''Align sequences into alignment_file Parameters ---------- input_sequences_path: str path to input sequences in fasta format output_alignment_path: str ...
python
def _align_sequences(self, input_sequences_path, output_alignment_path, threads): '''Align sequences into alignment_file Parameters ---------- input_sequences_path: str path to input sequences in fasta format output_alignment_path: str ...
[ "def", "_align_sequences", "(", "self", ",", "input_sequences_path", ",", "output_alignment_path", ",", "threads", ")", ":", "logging", ".", "debug", "(", "\"Aligning sequences using mafft\"", ")", "cmd", "=", "\"mafft --anysymbol --thread %s --auto /dev/stdin > %s\"", "%",...
Align sequences into alignment_file Parameters ---------- input_sequences_path: str path to input sequences in fasta format output_alignment_path: str path to output alignment path threads: str number of threads to use Returns ...
[ "Align", "sequences", "into", "alignment_file" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L92-L119
train
geronimp/graftM
graftm/create.py
Create._get_hmm_from_alignment
def _get_hmm_from_alignment(self, alignment, hmm_filename, output_alignment_filename): '''Return a HMM file and alignment of sequences to that HMM Parameters ---------- alignment: str path to aligned proteins hmm_filename: str write the hmm to this file p...
python
def _get_hmm_from_alignment(self, alignment, hmm_filename, output_alignment_filename): '''Return a HMM file and alignment of sequences to that HMM Parameters ---------- alignment: str path to aligned proteins hmm_filename: str write the hmm to this file p...
[ "def", "_get_hmm_from_alignment", "(", "self", ",", "alignment", ",", "hmm_filename", ",", "output_alignment_filename", ")", ":", "logging", ".", "info", "(", "\"Building HMM from alignment\"", ")", "with", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", ...
Return a HMM file and alignment of sequences to that HMM Parameters ---------- alignment: str path to aligned proteins hmm_filename: str write the hmm to this file path output_alignment_filename: str write the output alignment to this file pat...
[ "Return", "a", "HMM", "file", "and", "alignment", "of", "sequences", "to", "that", "HMM" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L121-L159
train
geronimp/graftM
graftm/create.py
Create._align_sequences_to_hmm
def _align_sequences_to_hmm(self, hmm_file, sequences_file, output_alignment_file): '''Align sequences to an HMM, and write an alignment of these proteins after cleanup so that they can be used for tree-making Parameters ---------- sequences_file: str path to file of...
python
def _align_sequences_to_hmm(self, hmm_file, sequences_file, output_alignment_file): '''Align sequences to an HMM, and write an alignment of these proteins after cleanup so that they can be used for tree-making Parameters ---------- sequences_file: str path to file of...
[ "def", "_align_sequences_to_hmm", "(", "self", ",", "hmm_file", ",", "sequences_file", ",", "output_alignment_file", ")", ":", "ss", "=", "SequenceSearcher", "(", "hmm_file", ")", "with", "tempfile", ".", "NamedTemporaryFile", "(", "prefix", "=", "'graftm'", ",", ...
Align sequences to an HMM, and write an alignment of these proteins after cleanup so that they can be used for tree-making Parameters ---------- sequences_file: str path to file of unaligned protein sequences hmm_file: str path to hmm file output_...
[ "Align", "sequences", "to", "an", "HMM", "and", "write", "an", "alignment", "of", "these", "proteins", "after", "cleanup", "so", "that", "they", "can", "be", "used", "for", "tree", "-", "making" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L161-L182
train
geronimp/graftM
graftm/create.py
Create._define_range
def _define_range(self, sequences): ''' define_range - define the maximum range within which two hits in a db search can be linked. This is defined as 1.5X the average length of all reads in the database. Parameters ---------- sequences : str A path t...
python
def _define_range(self, sequences): ''' define_range - define the maximum range within which two hits in a db search can be linked. This is defined as 1.5X the average length of all reads in the database. Parameters ---------- sequences : str A path t...
[ "def", "_define_range", "(", "self", ",", "sequences", ")", ":", "sequence_count", "=", "0", "total_sequence", "=", "0", "for", "record", "in", "SeqIO", ".", "parse", "(", "open", "(", "sequences", ")", ",", "'fasta'", ")", ":", "total_sequence", "+=", "...
define_range - define the maximum range within which two hits in a db search can be linked. This is defined as 1.5X the average length of all reads in the database. Parameters ---------- sequences : str A path to the sequences in FASTA format. This fasta file is assu...
[ "define_range", "-", "define", "the", "maximum", "range", "within", "which", "two", "hits", "in", "a", "db", "search", "can", "be", "linked", ".", "This", "is", "defined", "as", "1", ".", "5X", "the", "average", "length", "of", "all", "reads", "in", "t...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L306-L333
train
geronimp/graftM
graftm/create.py
Create._generate_tree_log_file
def _generate_tree_log_file(self, tree, alignment, output_tree_file_path, output_log_file_path, residue_type, fasttree): '''Generate the FastTree log file given a tree and the alignment that made that tree Returns ------- Nothing. The log file as p...
python
def _generate_tree_log_file(self, tree, alignment, output_tree_file_path, output_log_file_path, residue_type, fasttree): '''Generate the FastTree log file given a tree and the alignment that made that tree Returns ------- Nothing. The log file as p...
[ "def", "_generate_tree_log_file", "(", "self", ",", "tree", ",", "alignment", ",", "output_tree_file_path", ",", "output_log_file_path", ",", "residue_type", ",", "fasttree", ")", ":", "if", "residue_type", "==", "Create", ".", "_NUCLEOTIDE_PACKAGE_TYPE", ":", "cmd"...
Generate the FastTree log file given a tree and the alignment that made that tree Returns ------- Nothing. The log file as parameter is written as the log file.
[ "Generate", "the", "FastTree", "log", "file", "given", "a", "tree", "and", "the", "alignment", "that", "made", "that", "tree" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L335-L352
train
geronimp/graftM
graftm/create.py
Create._remove_sequences_from_alignment
def _remove_sequences_from_alignment(self, sequence_names, input_alignment_file, output_alignment_file): '''Remove sequences from the alignment file that have names in sequence_names Parameters ---------- sequence_names: list of str names of sequences to remove ...
python
def _remove_sequences_from_alignment(self, sequence_names, input_alignment_file, output_alignment_file): '''Remove sequences from the alignment file that have names in sequence_names Parameters ---------- sequence_names: list of str names of sequences to remove ...
[ "def", "_remove_sequences_from_alignment", "(", "self", ",", "sequence_names", ",", "input_alignment_file", ",", "output_alignment_file", ")", ":", "nameset", "=", "set", "(", "sequence_names", ")", "num_written", "=", "0", "with", "open", "(", "output_alignment_file"...
Remove sequences from the alignment file that have names in sequence_names Parameters ---------- sequence_names: list of str names of sequences to remove input_alignment_file: str path to alignment file to remove from output_alignment_file: str ...
[ "Remove", "sequences", "from", "the", "alignment", "file", "that", "have", "names", "in", "sequence_names" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L354-L378
train
geronimp/graftM
graftm/create.py
Create._create_dmnd_database
def _create_dmnd_database(self, unaligned_sequences_path, daa_output): ''' Build a diamond database using diamond makedb Parameters ---------- unaligned_sequences_path: str path to a FASTA file containing unaligned sequences daa_output: str Name o...
python
def _create_dmnd_database(self, unaligned_sequences_path, daa_output): ''' Build a diamond database using diamond makedb Parameters ---------- unaligned_sequences_path: str path to a FASTA file containing unaligned sequences daa_output: str Name o...
[ "def", "_create_dmnd_database", "(", "self", ",", "unaligned_sequences_path", ",", "daa_output", ")", ":", "logging", ".", "debug", "(", "\"Building diamond database\"", ")", "cmd", "=", "\"diamond makedb --in '%s' -d '%s'\"", "%", "(", "unaligned_sequences_path", ",", ...
Build a diamond database using diamond makedb Parameters ---------- unaligned_sequences_path: str path to a FASTA file containing unaligned sequences daa_output: str Name of output database.
[ "Build", "a", "diamond", "database", "using", "diamond", "makedb" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L425-L439
train
geronimp/graftM
graftm/create.py
Create._check_for_duplicate_sequence_names
def _check_for_duplicate_sequence_names(self, fasta_file_path): """Test if the given fasta file contains sequences with duplicate sequence names. Parameters ---------- fasta_file_path: string path to file that is to be checked Returns ------- ...
python
def _check_for_duplicate_sequence_names(self, fasta_file_path): """Test if the given fasta file contains sequences with duplicate sequence names. Parameters ---------- fasta_file_path: string path to file that is to be checked Returns ------- ...
[ "def", "_check_for_duplicate_sequence_names", "(", "self", ",", "fasta_file_path", ")", ":", "found_sequence_names", "=", "set", "(", ")", "for", "record", "in", "SeqIO", ".", "parse", "(", "fasta_file_path", ",", "'fasta'", ")", ":", "name", "=", "record", "....
Test if the given fasta file contains sequences with duplicate sequence names. Parameters ---------- fasta_file_path: string path to file that is to be checked Returns ------- The name of the first duplicate sequence found, else False.
[ "Test", "if", "the", "given", "fasta", "file", "contains", "sequences", "with", "duplicate", "sequence", "names", "." ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/create.py#L495-L515
train
geronimp/graftM
graftm/getaxnseq.py
Getaxnseq.read_taxtastic_taxonomy_and_seqinfo
def read_taxtastic_taxonomy_and_seqinfo(self, taxonomy_io, seqinfo_io): '''Read the taxonomy and seqinfo files into a dictionary of sequence_name => taxonomy, where the taxonomy is an array of lineages given to that sequence. Possibly this method is unable to handle the full de...
python
def read_taxtastic_taxonomy_and_seqinfo(self, taxonomy_io, seqinfo_io): '''Read the taxonomy and seqinfo files into a dictionary of sequence_name => taxonomy, where the taxonomy is an array of lineages given to that sequence. Possibly this method is unable to handle the full de...
[ "def", "read_taxtastic_taxonomy_and_seqinfo", "(", "self", ",", "taxonomy_io", ",", "seqinfo_io", ")", ":", "lineages", "=", "[", "]", "taxon_to_lineage_index", "=", "{", "}", "expected_number_of_fields", "=", "None", "for", "line", "in", "taxonomy_io", ":", "spli...
Read the taxonomy and seqinfo files into a dictionary of sequence_name => taxonomy, where the taxonomy is an array of lineages given to that sequence. Possibly this method is unable to handle the full definition of these files? It doesn't return what each of the ranks are, for ...
[ "Read", "the", "taxonomy", "and", "seqinfo", "files", "into", "a", "dictionary", "of", "sequence_name", "=", ">", "taxonomy", "where", "the", "taxonomy", "is", "an", "array", "of", "lineages", "given", "to", "that", "sequence", ".", "Possibly", "this", "meth...
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/getaxnseq.py#L48-L104
train
geronimp/graftM
graftm/sequence_io.py
SequenceIO.each_sequence
def each_sequence(self, fp): '''Like each except iterate over Sequence objects''' for name, seq, _ in self.each(fp): yield Sequence(name, seq)
python
def each_sequence(self, fp): '''Like each except iterate over Sequence objects''' for name, seq, _ in self.each(fp): yield Sequence(name, seq)
[ "def", "each_sequence", "(", "self", ",", "fp", ")", ":", "for", "name", ",", "seq", ",", "_", "in", "self", ".", "each", "(", "fp", ")", ":", "yield", "Sequence", "(", "name", ",", "seq", ")" ]
Like each except iterate over Sequence objects
[ "Like", "each", "except", "iterate", "over", "Sequence", "objects" ]
c82576517290167f605fd0bc4facd009cee29f48
https://github.com/geronimp/graftM/blob/c82576517290167f605fd0bc4facd009cee29f48/graftm/sequence_io.py#L42-L45
train
bitly/asyncmongo
asyncmongo/helpers.py
_fields_list_to_dict
def _fields_list_to_dict(fields): """Takes a list of field names and returns a matching dictionary. ["a", "b"] becomes {"a": 1, "b": 1} and ["a.b.c", "d", "a.c"] becomes {"a.b.c": 1, "d": 1, "a.c": 1} """ for key in fields: assert isinstance(key, (str,unicode)) return dict([[key, ...
python
def _fields_list_to_dict(fields): """Takes a list of field names and returns a matching dictionary. ["a", "b"] becomes {"a": 1, "b": 1} and ["a.b.c", "d", "a.c"] becomes {"a.b.c": 1, "d": 1, "a.c": 1} """ for key in fields: assert isinstance(key, (str,unicode)) return dict([[key, ...
[ "def", "_fields_list_to_dict", "(", "fields", ")", ":", "for", "key", "in", "fields", ":", "assert", "isinstance", "(", "key", ",", "(", "str", ",", "unicode", ")", ")", "return", "dict", "(", "[", "[", "key", ",", "1", "]", "for", "key", "in", "fi...
Takes a list of field names and returns a matching dictionary. ["a", "b"] becomes {"a": 1, "b": 1} and ["a.b.c", "d", "a.c"] becomes {"a.b.c": 1, "d": 1, "a.c": 1}
[ "Takes", "a", "list", "of", "field", "names", "and", "returns", "a", "matching", "dictionary", "." ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/helpers.py#L54-L65
train
bitly/asyncmongo
asyncmongo/connection.py
Connection._socket_connect
def _socket_connect(self): """create a socket, connect, register a stream with the async backend""" self.usage_count = 0 try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) s.connect((self._host, self._port)) self.__stream = self.__backend.register_s...
python
def _socket_connect(self): """create a socket, connect, register a stream with the async backend""" self.usage_count = 0 try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) s.connect((self._host, self._port)) self.__stream = self.__backend.register_s...
[ "def", "_socket_connect", "(", "self", ")", ":", "self", ".", "usage_count", "=", "0", "try", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ",", "0", ")", "s", ".", "connect", "(", "(", "s...
create a socket, connect, register a stream with the async backend
[ "create", "a", "socket", "connect", "register", "a", "stream", "with", "the", "async", "backend" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/connection.py#L111-L121
train
bitly/asyncmongo
asyncmongo/connection.py
Connection._socket_close
def _socket_close(self): """cleanup after the socket is closed by the other end""" callback = self.__callback self.__callback = None try: if callback: callback(None, InterfaceError('connection closed')) finally: # Flush the job queue, don't...
python
def _socket_close(self): """cleanup after the socket is closed by the other end""" callback = self.__callback self.__callback = None try: if callback: callback(None, InterfaceError('connection closed')) finally: # Flush the job queue, don't...
[ "def", "_socket_close", "(", "self", ")", ":", "callback", "=", "self", ".", "__callback", "self", ".", "__callback", "=", "None", "try", ":", "if", "callback", ":", "callback", "(", "None", ",", "InterfaceError", "(", "'connection closed'", ")", ")", "fin...
cleanup after the socket is closed by the other end
[ "cleanup", "after", "the", "socket", "is", "closed", "by", "the", "other", "end" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/connection.py#L123-L135
train
bitly/asyncmongo
asyncmongo/connection.py
Connection._close
def _close(self): """close the socket and cleanup""" callback = self.__callback self.__callback = None try: if callback: callback(None, InterfaceError('connection closed')) finally: # Flush the job queue, don't call the callbacks associated...
python
def _close(self): """close the socket and cleanup""" callback = self.__callback self.__callback = None try: if callback: callback(None, InterfaceError('connection closed')) finally: # Flush the job queue, don't call the callbacks associated...
[ "def", "_close", "(", "self", ")", ":", "callback", "=", "self", ".", "__callback", "self", ".", "__callback", "=", "None", "try", ":", "if", "callback", ":", "callback", "(", "None", ",", "InterfaceError", "(", "'connection closed'", ")", ")", "finally", ...
close the socket and cleanup
[ "close", "the", "socket", "and", "cleanup" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/connection.py#L137-L149
train
bitly/asyncmongo
asyncmongo/connection.py
Connection.send_message
def send_message(self, message, callback): """ send a message over the wire; callback=None indicates a safe=False call where we write and forget about it""" if self.__callback is not None: raise ProgrammingError('connection already in use') if callback: err_call...
python
def send_message(self, message, callback): """ send a message over the wire; callback=None indicates a safe=False call where we write and forget about it""" if self.__callback is not None: raise ProgrammingError('connection already in use') if callback: err_call...
[ "def", "send_message", "(", "self", ",", "message", ",", "callback", ")", ":", "if", "self", ".", "__callback", "is", "not", "None", ":", "raise", "ProgrammingError", "(", "'connection already in use'", ")", "if", "callback", ":", "err_callback", "=", "functoo...
send a message over the wire; callback=None indicates a safe=False call where we write and forget about it
[ "send", "a", "message", "over", "the", "wire", ";", "callback", "=", "None", "indicates", "a", "safe", "=", "False", "call", "where", "we", "write", "and", "forget", "about", "it" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/connection.py#L158-L184
train
bitly/asyncmongo
asyncmongo/connection.py
Connection._next_job
def _next_job(self): """execute the next job from the top of the queue""" if self.__job_queue: # Produce message from the top of the queue job = self.__job_queue.pop() # logging.debug("queue = %s, popped %r", self.__job_queue, job) job.process()
python
def _next_job(self): """execute the next job from the top of the queue""" if self.__job_queue: # Produce message from the top of the queue job = self.__job_queue.pop() # logging.debug("queue = %s, popped %r", self.__job_queue, job) job.process()
[ "def", "_next_job", "(", "self", ")", ":", "if", "self", ".", "__job_queue", ":", "job", "=", "self", ".", "__job_queue", ".", "pop", "(", ")", "job", ".", "process", "(", ")" ]
execute the next job from the top of the queue
[ "execute", "the", "next", "job", "from", "the", "top", "of", "the", "queue" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/connection.py#L191-L197
train
bitly/asyncmongo
asyncmongo/pool.py
ConnectionPools.get_connection_pool
def get_connection_pool(self, pool_id, *args, **kwargs): """get a connection pool, transparently creating it if it doesn't already exist :Parameters: - `pool_id`: unique id for a connection pool """ assert isinstance(pool_id, (str, unicode)) if not hasattr(self, '_po...
python
def get_connection_pool(self, pool_id, *args, **kwargs): """get a connection pool, transparently creating it if it doesn't already exist :Parameters: - `pool_id`: unique id for a connection pool """ assert isinstance(pool_id, (str, unicode)) if not hasattr(self, '_po...
[ "def", "get_connection_pool", "(", "self", ",", "pool_id", ",", "*", "args", ",", "**", "kwargs", ")", ":", "assert", "isinstance", "(", "pool_id", ",", "(", "str", ",", "unicode", ")", ")", "if", "not", "hasattr", "(", "self", ",", "'_pools'", ")", ...
get a connection pool, transparently creating it if it doesn't already exist :Parameters: - `pool_id`: unique id for a connection pool
[ "get", "a", "connection", "pool", "transparently", "creating", "it", "if", "it", "doesn", "t", "already", "exist" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/pool.py#L26-L38
train
bitly/asyncmongo
asyncmongo/pool.py
ConnectionPools.close_idle_connections
def close_idle_connections(self, pool_id=None): """close idle connections to mongo""" if not hasattr(self, '_pools'): return if pool_id: if pool_id not in self._pools: raise ProgrammingError("pool %r does not exist" % pool_id) else: ...
python
def close_idle_connections(self, pool_id=None): """close idle connections to mongo""" if not hasattr(self, '_pools'): return if pool_id: if pool_id not in self._pools: raise ProgrammingError("pool %r does not exist" % pool_id) else: ...
[ "def", "close_idle_connections", "(", "self", ",", "pool_id", "=", "None", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_pools'", ")", ":", "return", "if", "pool_id", ":", "if", "pool_id", "not", "in", "self", ".", "_pools", ":", "raise", "Pro...
close idle connections to mongo
[ "close", "idle", "connections", "to", "mongo" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/pool.py#L41-L54
train
bitly/asyncmongo
asyncmongo/pool.py
ConnectionPool.connection
def connection(self): """ get a cached connection from the pool """ self._condition.acquire() try: if (self._maxconnections and self._connections >= self._maxconnections): raise TooManyConnections("%d connections are already equal to the max: %d" % (self._con...
python
def connection(self): """ get a cached connection from the pool """ self._condition.acquire() try: if (self._maxconnections and self._connections >= self._maxconnections): raise TooManyConnections("%d connections are already equal to the max: %d" % (self._con...
[ "def", "connection", "(", "self", ")", ":", "self", ".", "_condition", ".", "acquire", "(", ")", "try", ":", "if", "(", "self", ".", "_maxconnections", "and", "self", ".", "_connections", ">=", "self", ".", "_maxconnections", ")", ":", "raise", "TooManyC...
get a cached connection from the pool
[ "get", "a", "cached", "connection", "from", "the", "pool" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/pool.py#L110-L125
train
bitly/asyncmongo
asyncmongo/cursor.py
Cursor.__query_options
def __query_options(self): """Get the query options string to use for this query.""" options = 0 if self.__tailable: options |= _QUERY_OPTIONS["tailable_cursor"] if self.__slave_okay or self.__pool._slave_okay: options |= _QUERY_OPTIONS["slave_okay"] if no...
python
def __query_options(self): """Get the query options string to use for this query.""" options = 0 if self.__tailable: options |= _QUERY_OPTIONS["tailable_cursor"] if self.__slave_okay or self.__pool._slave_okay: options |= _QUERY_OPTIONS["slave_okay"] if no...
[ "def", "__query_options", "(", "self", ")", ":", "options", "=", "0", "if", "self", ".", "__tailable", ":", "options", "|=", "_QUERY_OPTIONS", "[", "\"tailable_cursor\"", "]", "if", "self", ".", "__slave_okay", "or", "self", ".", "__pool", ".", "_slave_okay"...
Get the query options string to use for this query.
[ "Get", "the", "query", "options", "string", "to", "use", "for", "this", "query", "." ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/cursor.py#L421-L430
train
djungelorm/sphinx-tabs
sphinx_tabs/tabs.py
update_context
def update_context(app, pagename, templatename, context, doctree): """ Remove sphinx-tabs CSS and JS asset files if not used in a page """ if doctree is None: return visitor = _FindTabsDirectiveVisitor(doctree) doctree.walk(visitor) if not visitor.found_tabs_directive: paths = [posix...
python
def update_context(app, pagename, templatename, context, doctree): """ Remove sphinx-tabs CSS and JS asset files if not used in a page """ if doctree is None: return visitor = _FindTabsDirectiveVisitor(doctree) doctree.walk(visitor) if not visitor.found_tabs_directive: paths = [posix...
[ "def", "update_context", "(", "app", ",", "pagename", ",", "templatename", ",", "context", ",", "doctree", ")", ":", "if", "doctree", "is", "None", ":", "return", "visitor", "=", "_FindTabsDirectiveVisitor", "(", "doctree", ")", "doctree", ".", "walk", "(", ...
Remove sphinx-tabs CSS and JS asset files if not used in a page
[ "Remove", "sphinx", "-", "tabs", "CSS", "and", "JS", "asset", "files", "if", "not", "used", "in", "a", "page" ]
2f17b5ca82a91613b42d58d01aafbd484525915c
https://github.com/djungelorm/sphinx-tabs/blob/2f17b5ca82a91613b42d58d01aafbd484525915c/sphinx_tabs/tabs.py#L269-L286
train
djungelorm/sphinx-tabs
sphinx_tabs/tabs.py
copy_assets
def copy_assets(app, exception): """ Copy asset files to the output """ if 'getLogger' in dir(logging): log = logging.getLogger(__name__).info # pylint: disable=no-member else: log = app.info builders = get_compatible_builders(app) if exception: return if app.builder.nam...
python
def copy_assets(app, exception): """ Copy asset files to the output """ if 'getLogger' in dir(logging): log = logging.getLogger(__name__).info # pylint: disable=no-member else: log = app.info builders = get_compatible_builders(app) if exception: return if app.builder.nam...
[ "def", "copy_assets", "(", "app", ",", "exception", ")", ":", "if", "'getLogger'", "in", "dir", "(", "logging", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", ".", "info", "else", ":", "log", "=", "app", ".", "info", "builde...
Copy asset files to the output
[ "Copy", "asset", "files", "to", "the", "output" ]
2f17b5ca82a91613b42d58d01aafbd484525915c
https://github.com/djungelorm/sphinx-tabs/blob/2f17b5ca82a91613b42d58d01aafbd484525915c/sphinx_tabs/tabs.py#L290-L318
train
djungelorm/sphinx-tabs
sphinx_tabs/tabs.py
setup
def setup(app): """ Set up the plugin """ app.add_config_value('sphinx_tabs_nowarn', False, '') app.add_config_value('sphinx_tabs_valid_builders', [], '') app.add_directive('tabs', TabsDirective) app.add_directive('tab', TabDirective) app.add_directive('group-tab', GroupTabDirective) app.add...
python
def setup(app): """ Set up the plugin """ app.add_config_value('sphinx_tabs_nowarn', False, '') app.add_config_value('sphinx_tabs_valid_builders', [], '') app.add_directive('tabs', TabsDirective) app.add_directive('tab', TabDirective) app.add_directive('group-tab', GroupTabDirective) app.add...
[ "def", "setup", "(", "app", ")", ":", "app", ".", "add_config_value", "(", "'sphinx_tabs_nowarn'", ",", "False", ",", "''", ")", "app", ".", "add_config_value", "(", "'sphinx_tabs_valid_builders'", ",", "[", "]", ",", "''", ")", "app", ".", "add_directive", ...
Set up the plugin
[ "Set", "up", "the", "plugin" ]
2f17b5ca82a91613b42d58d01aafbd484525915c
https://github.com/djungelorm/sphinx-tabs/blob/2f17b5ca82a91613b42d58d01aafbd484525915c/sphinx_tabs/tabs.py#L321-L341
train
djungelorm/sphinx-tabs
sphinx_tabs/tabs.py
TabsDirective.run
def run(self): """ Parse a tabs directive """ self.assert_has_content() env = self.state.document.settings.env node = nodes.container() node['classes'] = ['sphinx-tabs'] if 'next_tabs_id' not in env.temp_data: env.temp_data['next_tabs_id'] = 0 if 'ta...
python
def run(self): """ Parse a tabs directive """ self.assert_has_content() env = self.state.document.settings.env node = nodes.container() node['classes'] = ['sphinx-tabs'] if 'next_tabs_id' not in env.temp_data: env.temp_data['next_tabs_id'] = 0 if 'ta...
[ "def", "run", "(", "self", ")", ":", "self", ".", "assert_has_content", "(", ")", "env", "=", "self", ".", "state", ".", "document", ".", "settings", ".", "env", "node", "=", "nodes", ".", "container", "(", ")", "node", "[", "'classes'", "]", "=", ...
Parse a tabs directive
[ "Parse", "a", "tabs", "directive" ]
2f17b5ca82a91613b42d58d01aafbd484525915c
https://github.com/djungelorm/sphinx-tabs/blob/2f17b5ca82a91613b42d58d01aafbd484525915c/sphinx_tabs/tabs.py#L45-L89
train
bitly/asyncmongo
asyncmongo/client.py
Client.connection
def connection(self, collectionname, dbname=None): """Get a cursor to a collection by name. raises `DataError` on names with unallowable characters. :Parameters: - `collectionname`: the name of the collection - `dbname`: (optional) overide the default db for a connection ...
python
def connection(self, collectionname, dbname=None): """Get a cursor to a collection by name. raises `DataError` on names with unallowable characters. :Parameters: - `collectionname`: the name of the collection - `dbname`: (optional) overide the default db for a connection ...
[ "def", "connection", "(", "self", ",", "collectionname", ",", "dbname", "=", "None", ")", ":", "if", "not", "collectionname", "or", "\"..\"", "in", "collectionname", ":", "raise", "DataError", "(", "\"collection names cannot be empty\"", ")", "if", "\"$\"", "in"...
Get a cursor to a collection by name. raises `DataError` on names with unallowable characters. :Parameters: - `collectionname`: the name of the collection - `dbname`: (optional) overide the default db for a connection
[ "Get", "a", "cursor", "to", "a", "collection", "by", "name", "." ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/client.py#L69-L91
train
bitly/asyncmongo
asyncmongo/client.py
Client.collection_names
def collection_names(self, callback): """Get a list of all the collection names in selected database""" callback = partial(self._collection_names_result, callback) self["system.namespaces"].find(_must_use_master=True, callback=callback)
python
def collection_names(self, callback): """Get a list of all the collection names in selected database""" callback = partial(self._collection_names_result, callback) self["system.namespaces"].find(_must_use_master=True, callback=callback)
[ "def", "collection_names", "(", "self", ",", "callback", ")", ":", "callback", "=", "partial", "(", "self", ".", "_collection_names_result", ",", "callback", ")", "self", "[", "\"system.namespaces\"", "]", ".", "find", "(", "_must_use_master", "=", "True", ","...
Get a list of all the collection names in selected database
[ "Get", "a", "list", "of", "all", "the", "collection", "names", "in", "selected", "database" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/client.py#L93-L96
train
bitly/asyncmongo
asyncmongo/client.py
Client._collection_names_result
def _collection_names_result(self, callback, results, error=None): """callback to for collection names query, filters out collection names""" names = [r['name'] for r in results if r['name'].count('.') == 1] assert error == None, repr(error) strip = len(self._pool._dbname) + 1 ca...
python
def _collection_names_result(self, callback, results, error=None): """callback to for collection names query, filters out collection names""" names = [r['name'] for r in results if r['name'].count('.') == 1] assert error == None, repr(error) strip = len(self._pool._dbname) + 1 ca...
[ "def", "_collection_names_result", "(", "self", ",", "callback", ",", "results", ",", "error", "=", "None", ")", ":", "names", "=", "[", "r", "[", "'name'", "]", "for", "r", "in", "results", "if", "r", "[", "'name'", "]", ".", "count", "(", "'.'", ...
callback to for collection names query, filters out collection names
[ "callback", "to", "for", "collection", "names", "query", "filters", "out", "collection", "names" ]
3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b
https://github.com/bitly/asyncmongo/blob/3da47c96d4592ec9e8b3ef5cf1b7d5b439ab3a5b/asyncmongo/client.py#L98-L103
train
DBuildService/dockerfile-parse
dockerfile_parse/parser.py
DockerfileParser.parent_images
def parent_images(self, parents): """ setter for images in 'FROM' instructions. Images are updated per build stage with the given parents in the order they appear. Raises RuntimeError if a different number of parents are given than there are stages as that is likely to be a mista...
python
def parent_images(self, parents): """ setter for images in 'FROM' instructions. Images are updated per build stage with the given parents in the order they appear. Raises RuntimeError if a different number of parents are given than there are stages as that is likely to be a mista...
[ "def", "parent_images", "(", "self", ",", "parents", ")", ":", "parents", "=", "list", "(", "parents", ")", "change_instrs", "=", "[", "]", "for", "instr", "in", "self", ".", "structure", ":", "if", "instr", "[", "'instruction'", "]", "!=", "'FROM'", "...
setter for images in 'FROM' instructions. Images are updated per build stage with the given parents in the order they appear. Raises RuntimeError if a different number of parents are given than there are stages as that is likely to be a mistake. :param parents: list of image strings
[ "setter", "for", "images", "in", "FROM", "instructions", ".", "Images", "are", "updated", "per", "build", "stage", "with", "the", "given", "parents", "in", "the", "order", "they", "appear", ".", "Raises", "RuntimeError", "if", "a", "different", "number", "of...
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L285-L319
train
DBuildService/dockerfile-parse
dockerfile_parse/parser.py
DockerfileParser.baseimage
def baseimage(self, new_image): """ change image of final stage FROM instruction """ images = self.parent_images or [None] images[-1] = new_image self.parent_images = images
python
def baseimage(self, new_image): """ change image of final stage FROM instruction """ images = self.parent_images or [None] images[-1] = new_image self.parent_images = images
[ "def", "baseimage", "(", "self", ",", "new_image", ")", ":", "images", "=", "self", ".", "parent_images", "or", "[", "None", "]", "images", "[", "-", "1", "]", "=", "new_image", "self", ".", "parent_images", "=", "images" ]
change image of final stage FROM instruction
[ "change", "image", "of", "final", "stage", "FROM", "instruction" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L333-L339
train
DBuildService/dockerfile-parse
dockerfile_parse/parser.py
DockerfileParser.cmd
def cmd(self, value): """ setter for final 'CMD' instruction in final build stage """ cmd = None for insndesc in self.structure: if insndesc['instruction'] == 'FROM': # new stage, reset cmd = None elif insndesc['instruction'] == 'CMD': ...
python
def cmd(self, value): """ setter for final 'CMD' instruction in final build stage """ cmd = None for insndesc in self.structure: if insndesc['instruction'] == 'FROM': # new stage, reset cmd = None elif insndesc['instruction'] == 'CMD': ...
[ "def", "cmd", "(", "self", ",", "value", ")", ":", "cmd", "=", "None", "for", "insndesc", "in", "self", ".", "structure", ":", "if", "insndesc", "[", "'instruction'", "]", "==", "'FROM'", ":", "cmd", "=", "None", "elif", "insndesc", "[", "'instruction'...
setter for final 'CMD' instruction in final build stage
[ "setter", "for", "final", "CMD", "instruction", "in", "final", "build", "stage" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L357-L373
train
DBuildService/dockerfile-parse
dockerfile_parse/parser.py
DockerfileParser._instruction_getter
def _instruction_getter(self, name, env_replace): """ Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance """ if name...
python
def _instruction_getter(self, name, env_replace): """ Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance """ if name...
[ "def", "_instruction_getter", "(", "self", ",", "name", ",", "env_replace", ")", ":", "if", "name", "!=", "'LABEL'", "and", "name", "!=", "'ENV'", ":", "raise", "ValueError", "(", "\"Unsupported instruction '%s'\"", ",", "name", ")", "instructions", "=", "{", ...
Get LABEL or ENV instructions with environment replacement :param name: e.g. 'LABEL' or 'ENV' :param env_replace: bool, whether to perform ENV substitution :return: Labels instance or Envs instance
[ "Get", "LABEL", "or", "ENV", "instructions", "with", "environment", "replacement" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L391-L422
train
DBuildService/dockerfile-parse
dockerfile_parse/util.py
b2u
def b2u(string): """ bytes to unicode """ if (isinstance(string, bytes) or (PY2 and isinstance(string, str))): return string.decode('utf-8') return string
python
def b2u(string): """ bytes to unicode """ if (isinstance(string, bytes) or (PY2 and isinstance(string, str))): return string.decode('utf-8') return string
[ "def", "b2u", "(", "string", ")", ":", "if", "(", "isinstance", "(", "string", ",", "bytes", ")", "or", "(", "PY2", "and", "isinstance", "(", "string", ",", "str", ")", ")", ")", ":", "return", "string", ".", "decode", "(", "'utf-8'", ")", "return"...
bytes to unicode
[ "bytes", "to", "unicode" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/util.py#L18-L23
train
DBuildService/dockerfile-parse
dockerfile_parse/util.py
u2b
def u2b(string): """ unicode to bytes""" if ((PY2 and isinstance(string, unicode)) or ((not PY2) and isinstance(string, str))): return string.encode('utf-8') return string
python
def u2b(string): """ unicode to bytes""" if ((PY2 and isinstance(string, unicode)) or ((not PY2) and isinstance(string, str))): return string.encode('utf-8') return string
[ "def", "u2b", "(", "string", ")", ":", "if", "(", "(", "PY2", "and", "isinstance", "(", "string", ",", "unicode", ")", ")", "or", "(", "(", "not", "PY2", ")", "and", "isinstance", "(", "string", ",", "str", ")", ")", ")", ":", "return", "string",...
unicode to bytes
[ "unicode", "to", "bytes" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/util.py#L26-L31
train
DBuildService/dockerfile-parse
dockerfile_parse/util.py
WordSplitter._update_quoting_state
def _update_quoting_state(self, ch): """ Update self.quotes and self.escaped :param ch: str, current character :return: ch if it was not used to update quoting state, else '' """ # Set whether the next character is escaped # Unquoted: # a backslash esc...
python
def _update_quoting_state(self, ch): """ Update self.quotes and self.escaped :param ch: str, current character :return: ch if it was not used to update quoting state, else '' """ # Set whether the next character is escaped # Unquoted: # a backslash esc...
[ "def", "_update_quoting_state", "(", "self", ",", "ch", ")", ":", "is_escaped", "=", "self", ".", "escaped", "self", ".", "escaped", "=", "(", "not", "self", ".", "escaped", "and", "ch", "==", "'\\\\'", "and", "self", ".", "quotes", "!=", "self", ".", ...
Update self.quotes and self.escaped :param ch: str, current character :return: ch if it was not used to update quoting state, else ''
[ "Update", "self", ".", "quotes", "and", "self", ".", "escaped" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/util.py#L63-L102
train
DBuildService/dockerfile-parse
dockerfile_parse/util.py
WordSplitter.split
def split(self, maxsplit=None, dequote=True): """ Generator for the words of the string :param maxsplit: perform at most maxsplit splits; if None, do not limit the number of splits :param dequote: remove quotes and escape characters once consumed """ class W...
python
def split(self, maxsplit=None, dequote=True): """ Generator for the words of the string :param maxsplit: perform at most maxsplit splits; if None, do not limit the number of splits :param dequote: remove quotes and escape characters once consumed """ class W...
[ "def", "split", "(", "self", ",", "maxsplit", "=", "None", ",", "dequote", "=", "True", ")", ":", "class", "Word", "(", "object", ")", ":", "def", "__init__", "(", "self", ")", ":", "self", ".", "value", "=", "None", "@", "property", "def", "valid"...
Generator for the words of the string :param maxsplit: perform at most maxsplit splits; if None, do not limit the number of splits :param dequote: remove quotes and escape characters once consumed
[ "Generator", "for", "the", "words", "of", "the", "string" ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/util.py#L107-L211
train
DBuildService/dockerfile-parse
dockerfile_parse/util.py
Context.get_line_value
def get_line_value(self, context_type): """ Get the values defined on this line. :param context_type: "ENV" or "LABEL" :return: values of given type defined on this line """ if context_type.upper() == "ENV": return self.line_envs elif context_type.upp...
python
def get_line_value(self, context_type): """ Get the values defined on this line. :param context_type: "ENV" or "LABEL" :return: values of given type defined on this line """ if context_type.upper() == "ENV": return self.line_envs elif context_type.upp...
[ "def", "get_line_value", "(", "self", ",", "context_type", ")", ":", "if", "context_type", ".", "upper", "(", ")", "==", "\"ENV\"", ":", "return", "self", ".", "line_envs", "elif", "context_type", ".", "upper", "(", ")", "==", "\"LABEL\"", ":", "return", ...
Get the values defined on this line. :param context_type: "ENV" or "LABEL" :return: values of given type defined on this line
[ "Get", "the", "values", "defined", "on", "this", "line", "." ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/util.py#L287-L297
train
DBuildService/dockerfile-parse
dockerfile_parse/util.py
Context.get_values
def get_values(self, context_type): """ Get the values valid on this line. :param context_type: "ENV" or "LABEL" :return: values of given type valid on this line """ if context_type.upper() == "ENV": return self.envs elif context_type.upper() == "LABE...
python
def get_values(self, context_type): """ Get the values valid on this line. :param context_type: "ENV" or "LABEL" :return: values of given type valid on this line """ if context_type.upper() == "ENV": return self.envs elif context_type.upper() == "LABE...
[ "def", "get_values", "(", "self", ",", "context_type", ")", ":", "if", "context_type", ".", "upper", "(", ")", "==", "\"ENV\"", ":", "return", "self", ".", "envs", "elif", "context_type", ".", "upper", "(", ")", "==", "\"LABEL\"", ":", "return", "self", ...
Get the values valid on this line. :param context_type: "ENV" or "LABEL" :return: values of given type valid on this line
[ "Get", "the", "values", "valid", "on", "this", "line", "." ]
3d7b514d8b8eded1b33529cf0f6a0770a573aee0
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/util.py#L299-L309
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/usefulFunctions.py
uniqueStates
def uniqueStates(states,rates): """ Returns unique states and sums up the corresponding rates. States should be a 2d numpy array with on each row a state, and rates a 1d numpy array with length equal to the number of rows in states. This may be helpful in the transition function for summing u...
python
def uniqueStates(states,rates): """ Returns unique states and sums up the corresponding rates. States should be a 2d numpy array with on each row a state, and rates a 1d numpy array with length equal to the number of rows in states. This may be helpful in the transition function for summing u...
[ "def", "uniqueStates", "(", "states", ",", "rates", ")", ":", "order", "=", "np", ".", "lexsort", "(", "states", ".", "T", ")", "states", "=", "states", "[", "order", "]", "diff", "=", "np", ".", "ones", "(", "len", "(", "states", ")", ",", "'boo...
Returns unique states and sums up the corresponding rates. States should be a 2d numpy array with on each row a state, and rates a 1d numpy array with length equal to the number of rows in states. This may be helpful in the transition function for summing up the rates of different transitions that le...
[ "Returns", "unique", "states", "and", "sums", "up", "the", "corresponding", "rates", ".", "States", "should", "be", "a", "2d", "numpy", "array", "with", "on", "each", "row", "a", "state", "and", "rates", "a", "1d", "numpy", "array", "with", "length", "eq...
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/usefulFunctions.py#L4-L16
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.checkInitialState
def checkInitialState(self,initialState): """ Check whether the initial state is of the correct type. The state should be either an int, list, tuple or np.array and all its elements must be integer. Returns an int if the state is an integer, otherwise a tuple. """ assert ...
python
def checkInitialState(self,initialState): """ Check whether the initial state is of the correct type. The state should be either an int, list, tuple or np.array and all its elements must be integer. Returns an int if the state is an integer, otherwise a tuple. """ assert ...
[ "def", "checkInitialState", "(", "self", ",", "initialState", ")", ":", "assert", "initialState", "is", "not", "None", ",", "\"Initial state has not been specified.\"", "assert", "isinstance", "(", "initialState", ",", "(", "int", ",", "list", ",", "tuple", ",", ...
Check whether the initial state is of the correct type. The state should be either an int, list, tuple or np.array and all its elements must be integer. Returns an int if the state is an integer, otherwise a tuple.
[ "Check", "whether", "the", "initial", "state", "is", "of", "the", "correct", "type", ".", "The", "state", "should", "be", "either", "an", "int", "list", "tuple", "or", "np", ".", "array", "and", "all", "its", "elements", "must", "be", "integer", ".", "...
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L122-L155
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.indirectInitialMatrix
def indirectInitialMatrix(self, initialState): """ Given some initial state, this iteratively determines new states. We repeatedly call the transition function on unvisited states in the frontier set. Each newly visited state is put in a dictionary called 'mapping' and the rates are stor...
python
def indirectInitialMatrix(self, initialState): """ Given some initial state, this iteratively determines new states. We repeatedly call the transition function on unvisited states in the frontier set. Each newly visited state is put in a dictionary called 'mapping' and the rates are stor...
[ "def", "indirectInitialMatrix", "(", "self", ",", "initialState", ")", ":", "mapping", "=", "{", "}", "rates", "=", "OrderedDict", "(", ")", "convertedState", "=", "self", ".", "checkInitialState", "(", "initialState", ")", "if", "isinstance", "(", "convertedS...
Given some initial state, this iteratively determines new states. We repeatedly call the transition function on unvisited states in the frontier set. Each newly visited state is put in a dictionary called 'mapping' and the rates are stored in a dictionary.
[ "Given", "some", "initial", "state", "this", "iteratively", "determines", "new", "states", ".", "We", "repeatedly", "call", "the", "transition", "function", "on", "unvisited", "states", "in", "the", "frontier", "set", ".", "Each", "newly", "visited", "state", ...
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L194-L243
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.getStateCode
def getStateCode(self,state): """ Calculates the state code for a specific state or set of states. We transform the states so that they are nonnegative and take an inner product. The resulting number is unique because we use numeral system with a large enough base. ...
python
def getStateCode(self,state): """ Calculates the state code for a specific state or set of states. We transform the states so that they are nonnegative and take an inner product. The resulting number is unique because we use numeral system with a large enough base. ...
[ "def", "getStateCode", "(", "self", ",", "state", ")", ":", "return", "np", ".", "dot", "(", "state", "-", "self", ".", "minvalues", ",", "self", ".", "statecode", ")" ]
Calculates the state code for a specific state or set of states. We transform the states so that they are nonnegative and take an inner product. The resulting number is unique because we use numeral system with a large enough base.
[ "Calculates", "the", "state", "code", "for", "a", "specific", "state", "or", "set", "of", "states", ".", "We", "transform", "the", "states", "so", "that", "they", "are", "nonnegative", "and", "take", "an", "inner", "product", ".", "The", "resulting", "numb...
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L246-L252
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.getStateIndex
def getStateIndex(self,state): """ Returns the index of a state by calculating the state code and searching for this code a sorted list. Can be called on multiple states at once. """ statecodes = self.getStateCode(state) return np.searchsorted(self.codes,statecodes).astyp...
python
def getStateIndex(self,state): """ Returns the index of a state by calculating the state code and searching for this code a sorted list. Can be called on multiple states at once. """ statecodes = self.getStateCode(state) return np.searchsorted(self.codes,statecodes).astyp...
[ "def", "getStateIndex", "(", "self", ",", "state", ")", ":", "statecodes", "=", "self", ".", "getStateCode", "(", "state", ")", "return", "np", ".", "searchsorted", "(", "self", ".", "codes", ",", "statecodes", ")", ".", "astype", "(", "int", ")" ]
Returns the index of a state by calculating the state code and searching for this code a sorted list. Can be called on multiple states at once.
[ "Returns", "the", "index", "of", "a", "state", "by", "calculating", "the", "state", "code", "and", "searching", "for", "this", "code", "a", "sorted", "list", ".", "Can", "be", "called", "on", "multiple", "states", "at", "once", "." ]
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L284-L290
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.transitionStates
def transitionStates(self,state): """ Return the indices of new states and their rates. """ newstates,rates = self.transition(state) newindices = self.getStateIndex(newstates) return newindices,rates
python
def transitionStates(self,state): """ Return the indices of new states and their rates. """ newstates,rates = self.transition(state) newindices = self.getStateIndex(newstates) return newindices,rates
[ "def", "transitionStates", "(", "self", ",", "state", ")", ":", "newstates", ",", "rates", "=", "self", ".", "transition", "(", "state", ")", "newindices", "=", "self", ".", "getStateIndex", "(", "newstates", ")", "return", "newindices", ",", "rates" ]
Return the indices of new states and their rates.
[ "Return", "the", "indices", "of", "new", "states", "and", "their", "rates", "." ]
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L292-L298
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.convertToRateMatrix
def convertToRateMatrix(self, Q): """ Converts the initial matrix to a rate matrix. We make all rows in Q sum to zero by subtracting the row sums from the diagonal. """ rowSums = Q.sum(axis=1).getA1() idxRange = np.arange(Q.shape[0]) Qdiag ...
python
def convertToRateMatrix(self, Q): """ Converts the initial matrix to a rate matrix. We make all rows in Q sum to zero by subtracting the row sums from the diagonal. """ rowSums = Q.sum(axis=1).getA1() idxRange = np.arange(Q.shape[0]) Qdiag ...
[ "def", "convertToRateMatrix", "(", "self", ",", "Q", ")", ":", "rowSums", "=", "Q", ".", "sum", "(", "axis", "=", "1", ")", ".", "getA1", "(", ")", "idxRange", "=", "np", ".", "arange", "(", "Q", ".", "shape", "[", "0", "]", ")", "Qdiag", "=", ...
Converts the initial matrix to a rate matrix. We make all rows in Q sum to zero by subtracting the row sums from the diagonal.
[ "Converts", "the", "initial", "matrix", "to", "a", "rate", "matrix", ".", "We", "make", "all", "rows", "in", "Q", "sum", "to", "zero", "by", "subtracting", "the", "row", "sums", "from", "the", "diagonal", "." ]
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L341-L349
train
gvanderheide/discreteMarkovChain
discreteMarkovChain/markovChain.py
markovChain.getTransitionMatrix
def getTransitionMatrix(self,probabilities=True): """ If self.P has been given already, we will reuse it and convert it to a sparse csr matrix if needed. Otherwise, we will generate it using the direct or indirect method. Since most solution methods use a probability matrix, thi...
python
def getTransitionMatrix(self,probabilities=True): """ If self.P has been given already, we will reuse it and convert it to a sparse csr matrix if needed. Otherwise, we will generate it using the direct or indirect method. Since most solution methods use a probability matrix, thi...
[ "def", "getTransitionMatrix", "(", "self", ",", "probabilities", "=", "True", ")", ":", "if", "self", ".", "P", "is", "not", "None", ":", "if", "isspmatrix", "(", "self", ".", "P", ")", ":", "if", "not", "isspmatrix_csr", "(", "self", ".", "P", ")", ...
If self.P has been given already, we will reuse it and convert it to a sparse csr matrix if needed. Otherwise, we will generate it using the direct or indirect method. Since most solution methods use a probability matrix, this is the default setting. By setting probabilities=False we c...
[ "If", "self", ".", "P", "has", "been", "given", "already", "we", "will", "reuse", "it", "and", "convert", "it", "to", "a", "sparse", "csr", "matrix", "if", "needed", ".", "Otherwise", "we", "will", "generate", "it", "using", "the", "direct", "or", "ind...
8325ffdb791c109eee600684ee0dc9126ce80700
https://github.com/gvanderheide/discreteMarkovChain/blob/8325ffdb791c109eee600684ee0dc9126ce80700/discreteMarkovChain/markovChain.py#L373-L399
train