repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
onecodex/onecodex
onecodex/lib/upload.py
interleaved_filename
def interleaved_filename(file_path): """Return filename used to represent a set of paired-end files. Assumes Illumina-style naming conventions where each file has _R1_ or _R2_ in its name.""" if not isinstance(file_path, tuple): raise OneCodexException("Cannot get the interleaved filename without a ...
python
def interleaved_filename(file_path): """Return filename used to represent a set of paired-end files. Assumes Illumina-style naming conventions where each file has _R1_ or _R2_ in its name.""" if not isinstance(file_path, tuple): raise OneCodexException("Cannot get the interleaved filename without a ...
Return filename used to represent a set of paired-end files. Assumes Illumina-style naming conventions where each file has _R1_ or _R2_ in its name.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L213-L222
onecodex/onecodex
onecodex/lib/upload.py
_file_size
def _file_size(file_path, uncompressed=False): """Return size of a single file, compressed or uncompressed""" _, ext = os.path.splitext(file_path) if uncompressed: if ext in {".gz", ".gzip"}: with gzip.GzipFile(file_path, mode="rb") as fp: try: fp.see...
python
def _file_size(file_path, uncompressed=False): """Return size of a single file, compressed or uncompressed""" _, ext = os.path.splitext(file_path) if uncompressed: if ext in {".gz", ".gzip"}: with gzip.GzipFile(file_path, mode="rb") as fp: try: fp.see...
Return size of a single file, compressed or uncompressed
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L225-L246
onecodex/onecodex
onecodex/lib/upload.py
_file_stats
def _file_stats(file_path, enforce_fastx=True): """Return information about the file path (or paths, if paired), prior to upload. Parameters ---------- file_path : `string` or `tuple` System path to the file(s) to be uploaded Returns ------- `string` Filename, minus compres...
python
def _file_stats(file_path, enforce_fastx=True): """Return information about the file path (or paths, if paired), prior to upload. Parameters ---------- file_path : `string` or `tuple` System path to the file(s) to be uploaded Returns ------- `string` Filename, minus compres...
Return information about the file path (or paths, if paired), prior to upload. Parameters ---------- file_path : `string` or `tuple` System path to the file(s) to be uploaded Returns ------- `string` Filename, minus compressed extension (.gz or .bz2). If paired, use first path ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L249-L309
onecodex/onecodex
onecodex/lib/upload.py
_call_init_upload
def _call_init_upload(file_name, file_size, metadata, tags, project, samples_resource): """Call init_upload at the One Codex API and return data used to upload the file. Parameters ---------- file_name : `string` The file_name you wish to associate this fastx file with at One Codex. file_si...
python
def _call_init_upload(file_name, file_size, metadata, tags, project, samples_resource): """Call init_upload at the One Codex API and return data used to upload the file. Parameters ---------- file_name : `string` The file_name you wish to associate this fastx file with at One Codex. file_si...
Call init_upload at the One Codex API and return data used to upload the file. Parameters ---------- file_name : `string` The file_name you wish to associate this fastx file with at One Codex. file_size : `integer` Accurate size of file to be uploaded, in bytes. metadata : `dict`, o...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L334-L384
onecodex/onecodex
onecodex/lib/upload.py
_make_retry_fields
def _make_retry_fields(file_name, metadata, tags, project): """Generate fields to send to init_multipart_upload in the case that a Sample upload via fastx-proxy fails. Parameters ---------- file_name : `string` The file_name you wish to associate this fastx file with at One Codex. metad...
python
def _make_retry_fields(file_name, metadata, tags, project): """Generate fields to send to init_multipart_upload in the case that a Sample upload via fastx-proxy fails. Parameters ---------- file_name : `string` The file_name you wish to associate this fastx file with at One Codex. metad...
Generate fields to send to init_multipart_upload in the case that a Sample upload via fastx-proxy fails. Parameters ---------- file_name : `string` The file_name you wish to associate this fastx file with at One Codex. metadata : `dict`, optional tags : `list`, optional project : `s...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L387-L423
onecodex/onecodex
onecodex/lib/upload.py
upload_sequence
def upload_sequence( files, session, samples_resource, metadata=None, tags=None, project=None, coerce_ascii=False, progressbar=None, ): """Uploads a sequence file (or pair of files) to the One Codex server via either our proxy or directly to S3. Parameters ---------- fil...
python
def upload_sequence( files, session, samples_resource, metadata=None, tags=None, project=None, coerce_ascii=False, progressbar=None, ): """Uploads a sequence file (or pair of files) to the One Codex server via either our proxy or directly to S3. Parameters ---------- fil...
Uploads a sequence file (or pair of files) to the One Codex server via either our proxy or directly to S3. Parameters ---------- files : `list` A list of paths to files on the system, or tuples containing pairs of paths. Tuples will be interleaved as paired-end reads and both files should c...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L426-L522
onecodex/onecodex
onecodex/lib/upload.py
_direct_upload
def _direct_upload(file_obj, file_name, fields, session, samples_resource): """Uploads a single file-like object via our validating proxy. Maintains compatibility with direct upload to a user's S3 bucket as well in case we disable our validating proxy. Parameters ---------- file_obj : `FASTXInterle...
python
def _direct_upload(file_obj, file_name, fields, session, samples_resource): """Uploads a single file-like object via our validating proxy. Maintains compatibility with direct upload to a user's S3 bucket as well in case we disable our validating proxy. Parameters ---------- file_obj : `FASTXInterle...
Uploads a single file-like object via our validating proxy. Maintains compatibility with direct upload to a user's S3 bucket as well in case we disable our validating proxy. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object A wrapper around a pair of fast...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L525-L623
onecodex/onecodex
onecodex/lib/upload.py
upload_sequence_fileobj
def upload_sequence_fileobj(file_obj, file_name, fields, retry_fields, session, samples_resource): """Uploads a single file-like object to the One Codex server via either fastx-proxy or directly to S3. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object ...
python
def upload_sequence_fileobj(file_obj, file_name, fields, retry_fields, session, samples_resource): """Uploads a single file-like object to the One Codex server via either fastx-proxy or directly to S3. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object ...
Uploads a single file-like object to the One Codex server via either fastx-proxy or directly to S3. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object A wrapper around a pair of fastx files (`FASTXInterleave`) or a single fastx file. In the case of...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L626-L685
onecodex/onecodex
onecodex/lib/upload.py
upload_document
def upload_document(file_path, session, documents_resource, progressbar=None): """Uploads multiple document files to the One Codex server directly to S3 via an intermediate bucket. Parameters ---------- file_path : `str` A path to a file on the system. session : `requests.Session` ...
python
def upload_document(file_path, session, documents_resource, progressbar=None): """Uploads multiple document files to the One Codex server directly to S3 via an intermediate bucket. Parameters ---------- file_path : `str` A path to a file on the system. session : `requests.Session` ...
Uploads multiple document files to the One Codex server directly to S3 via an intermediate bucket. Parameters ---------- file_path : `str` A path to a file on the system. session : `requests.Session` Connection to One Codex API. documents_resource : `onecodex.models.Documents` ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L688-L727
onecodex/onecodex
onecodex/lib/upload.py
upload_document_fileobj
def upload_document_fileobj(file_obj, file_name, session, documents_resource, log=None): """Uploads a single file-like object to the One Codex server directly to S3. Parameters ---------- file_obj : `FilePassthru`, or a file-like object If a file-like object is given, its mime-type will be sent...
python
def upload_document_fileobj(file_obj, file_name, session, documents_resource, log=None): """Uploads a single file-like object to the One Codex server directly to S3. Parameters ---------- file_obj : `FilePassthru`, or a file-like object If a file-like object is given, its mime-type will be sent...
Uploads a single file-like object to the One Codex server directly to S3. Parameters ---------- file_obj : `FilePassthru`, or a file-like object If a file-like object is given, its mime-type will be sent as 'text/plain'. Otherwise, `FilePassthru` will send a compressed type if the file is g...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L730-L779
onecodex/onecodex
onecodex/lib/upload.py
_s3_intermediate_upload
def _s3_intermediate_upload(file_obj, file_name, fields, session, callback_url): """Uploads a single file-like object to an intermediate S3 bucket which One Codex can pull from after receiving a callback. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object ...
python
def _s3_intermediate_upload(file_obj, file_name, fields, session, callback_url): """Uploads a single file-like object to an intermediate S3 bucket which One Codex can pull from after receiving a callback. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object ...
Uploads a single file-like object to an intermediate S3 bucket which One Codex can pull from after receiving a callback. Parameters ---------- file_obj : `FASTXInterleave`, `FilePassthru`, or a file-like object A wrapper around a pair of fastx files (`FASTXInterleave`) or a single fastx file. I...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L782-L861
onecodex/onecodex
onecodex/lib/upload.py
FASTXInterleave.seek
def seek(self, loc): """Called if upload fails and must be retried.""" assert loc == 0 # rewind progress bar if self.progressbar: self.progressbar.update(-self._tell) self._fp_left.seek(loc) self._fp_right.seek(loc) self._tell = loc self._buf...
python
def seek(self, loc): """Called if upload fails and must be retried.""" assert loc == 0 # rewind progress bar if self.progressbar: self.progressbar.update(-self._tell) self._fp_left.seek(loc) self._fp_right.seek(loc) self._tell = loc self._buf...
Called if upload fails and must be retried.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L140-L151
onecodex/onecodex
onecodex/lib/upload.py
FilePassthru.seek
def seek(self, loc): """Called if upload fails and must be retried.""" assert loc == 0 # rewind progress bar if self.progressbar: self.progressbar.update(-self._fp.tell()) self._fp.seek(loc)
python
def seek(self, loc): """Called if upload fails and must be retried.""" assert loc == 0 # rewind progress bar if self.progressbar: self.progressbar.update(-self._fp.tell()) self._fp.seek(loc)
Called if upload fails and must be retried.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/upload.py#L199-L207
joytunes/JTLocalize
localization_flow/jtlocalize/core/merge_strings_files.py
merge_strings_files
def merge_strings_files(old_strings_file, new_strings_file): """ Merges the old strings file with the new one. Args: old_strings_file (str): The path to the old strings file (previously produced, and possibly altered) new_strings_file (str): The path to the new strings file (newly produced). ...
python
def merge_strings_files(old_strings_file, new_strings_file): """ Merges the old strings file with the new one. Args: old_strings_file (str): The path to the old strings file (previously produced, and possibly altered) new_strings_file (str): The path to the new strings file (newly produced). ...
Merges the old strings file with the new one. Args: old_strings_file (str): The path to the old strings file (previously produced, and possibly altered) new_strings_file (str): The path to the new strings file (newly produced).
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/merge_strings_files.py#L24-L49
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_commandline_operation.py
LocalizationCommandLineOperation.configure_parser
def configure_parser(self, parser): """ Adds the necessary supported arguments to the argument parser. Args: parser (argparse.ArgumentParser): The parser to add arguments to. """ parser.add_argument("--log_path", default="", help="The log file path") parser.a...
python
def configure_parser(self, parser): """ Adds the necessary supported arguments to the argument parser. Args: parser (argparse.ArgumentParser): The parser to add arguments to. """ parser.add_argument("--log_path", default="", help="The log file path") parser.a...
Adds the necessary supported arguments to the argument parser. Args: parser (argparse.ArgumentParser): The parser to add arguments to.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_commandline_operation.py#L25-L33
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_commandline_operation.py
LocalizationCommandLineOperation.run_with_standalone_parser
def run_with_standalone_parser(self): """ Will run the operation as standalone with a new ArgumentParser """ parser = argparse.ArgumentParser(description=self.description()) self.configure_parser(parser) self.run(parser.parse_args())
python
def run_with_standalone_parser(self): """ Will run the operation as standalone with a new ArgumentParser """ parser = argparse.ArgumentParser(description=self.description()) self.configure_parser(parser) self.run(parser.parse_args())
Will run the operation as standalone with a new ArgumentParser
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_commandline_operation.py#L45-L51
onecodex/onecodex
onecodex/distance.py
DistanceMixin.alpha_diversity
def alpha_diversity(self, metric="simpson", rank="auto"): """Caculate the diversity within a community. Parameters ---------- metric : {'simpson', 'chao1', 'shannon'} The diversity metric to calculate. rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', ...
python
def alpha_diversity(self, metric="simpson", rank="auto"): """Caculate the diversity within a community. Parameters ---------- metric : {'simpson', 'chao1', 'shannon'} The diversity metric to calculate. rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', ...
Caculate the diversity within a community. Parameters ---------- metric : {'simpson', 'chao1', 'shannon'} The diversity metric to calculate. rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analysis will be restricted...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/distance.py#L9-L42
onecodex/onecodex
onecodex/distance.py
DistanceMixin.beta_diversity
def beta_diversity(self, metric="braycurtis", rank="auto"): """Calculate the diversity between two communities. Parameters ---------- metric : {'jaccard', 'braycurtis', 'cityblock'} The distance metric to calculate. rank : {'auto', 'kingdom', 'phylum', 'class', 'orde...
python
def beta_diversity(self, metric="braycurtis", rank="auto"): """Calculate the diversity between two communities. Parameters ---------- metric : {'jaccard', 'braycurtis', 'cityblock'} The distance metric to calculate. rank : {'auto', 'kingdom', 'phylum', 'class', 'orde...
Calculate the diversity between two communities. Parameters ---------- metric : {'jaccard', 'braycurtis', 'cityblock'} The distance metric to calculate. rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analysis will b...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/distance.py#L44-L73
onecodex/onecodex
onecodex/distance.py
DistanceMixin.unifrac
def unifrac(self, weighted=True, rank="auto"): """A beta diversity metric that takes into account the relative relatedness of community members. Weighted UniFrac looks at abundances, unweighted UniFrac looks at presence. Parameters ---------- weighted : `bool` Calcul...
python
def unifrac(self, weighted=True, rank="auto"): """A beta diversity metric that takes into account the relative relatedness of community members. Weighted UniFrac looks at abundances, unweighted UniFrac looks at presence. Parameters ---------- weighted : `bool` Calcul...
A beta diversity metric that takes into account the relative relatedness of community members. Weighted UniFrac looks at abundances, unweighted UniFrac looks at presence. Parameters ---------- weighted : `bool` Calculate the weighted (True) or unweighted (False) distance met...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/distance.py#L75-L121
onecodex/onecodex
onecodex/lib/auth.py
fetch_api_key_from_uname
def fetch_api_key_from_uname(username, password, server_url): """ Retrieves an API key from the One Codex webpage given the username and password """ # TODO: Hit programmatic endpoint to fetch JWT key, not API key with requests.Session() as session: # get the login page normally text...
python
def fetch_api_key_from_uname(username, password, server_url): """ Retrieves an API key from the One Codex webpage given the username and password """ # TODO: Hit programmatic endpoint to fetch JWT key, not API key with requests.Session() as session: # get the login page normally text...
Retrieves an API key from the One Codex webpage given the username and password
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/auth.py#L16-L40
onecodex/onecodex
onecodex/lib/auth.py
check_version
def check_version(version, server): """Check if the current CLI version is supported by the One Codex backend. Parameters ---------- version : `string` Current version of the One Codex client library server : `string` Complete URL to One Codex server, e.g., https://app.onecodex.com ...
python
def check_version(version, server): """Check if the current CLI version is supported by the One Codex backend. Parameters ---------- version : `string` Current version of the One Codex client library server : `string` Complete URL to One Codex server, e.g., https://app.onecodex.com ...
Check if the current CLI version is supported by the One Codex backend. Parameters ---------- version : `string` Current version of the One Codex client library server : `string` Complete URL to One Codex server, e.g., https://app.onecodex.com Returns ------- `tuple` contai...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/lib/auth.py#L43-L88
onecodex/onecodex
onecodex/utils.py
valid_api_key
def valid_api_key(ctx, param, value): """ Ensures an API has valid length (this is a click callback) """ if value is not None and len(value) != 32: raise click.BadParameter( "API Key must be 32 characters long, not {}".format(str(len(value))) ) else: return value
python
def valid_api_key(ctx, param, value): """ Ensures an API has valid length (this is a click callback) """ if value is not None and len(value) != 32: raise click.BadParameter( "API Key must be 32 characters long, not {}".format(str(len(value))) ) else: return value
Ensures an API has valid length (this is a click callback)
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L100-L109
onecodex/onecodex
onecodex/utils.py
pprint
def pprint(j, no_pretty): """ Prints as formatted JSON """ if not no_pretty: click.echo( json.dumps(j, cls=PotionJSONEncoder, sort_keys=True, indent=4, separators=(",", ": ")) ) else: click.echo(j)
python
def pprint(j, no_pretty): """ Prints as formatted JSON """ if not no_pretty: click.echo( json.dumps(j, cls=PotionJSONEncoder, sort_keys=True, indent=4, separators=(",", ": ")) ) else: click.echo(j)
Prints as formatted JSON
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L112-L121
onecodex/onecodex
onecodex/utils.py
is_insecure_platform
def is_insecure_platform(): """ Checks if the current system is missing an SSLContext object """ v = sys.version_info if v.major == 3: return False # Python 2 issue if v.major == 2 and v.minor == 7 and v.micro >= 9: return False # >= 2.7.9 includes the new SSL updates try...
python
def is_insecure_platform(): """ Checks if the current system is missing an SSLContext object """ v = sys.version_info if v.major == 3: return False # Python 2 issue if v.major == 2 and v.minor == 7 and v.micro >= 9: return False # >= 2.7.9 includes the new SSL updates try...
Checks if the current system is missing an SSLContext object
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L188-L205
onecodex/onecodex
onecodex/utils.py
warn_if_insecure_platform
def warn_if_insecure_platform(): """ Produces a nice message if SSLContext object is not available. Also returns True -> platform is insecure False -> platform is secure """ m = ( "\n" "#################################################################################...
python
def warn_if_insecure_platform(): """ Produces a nice message if SSLContext object is not available. Also returns True -> platform is insecure False -> platform is secure """ m = ( "\n" "#################################################################################...
Produces a nice message if SSLContext object is not available. Also returns True -> platform is insecure False -> platform is secure
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L208-L233
onecodex/onecodex
onecodex/utils.py
download_file_helper
def download_file_helper(url, input_path): """ Manages the chunked downloading of a file given an url """ r = requests.get(url, stream=True) if r.status_code != 200: cli_log.error("Failed to download file: %s" % r.json()["message"]) local_full_path = get_download_dest(input_path, r.url) ...
python
def download_file_helper(url, input_path): """ Manages the chunked downloading of a file given an url """ r = requests.get(url, stream=True) if r.status_code != 200: cli_log.error("Failed to download file: %s" % r.json()["message"]) local_full_path = get_download_dest(input_path, r.url) ...
Manages the chunked downloading of a file given an url
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L245-L260
onecodex/onecodex
onecodex/utils.py
check_for_allowed_file
def check_for_allowed_file(f): """ Checks a file extension against a list of seq file exts """ for ext in SUPPORTED_EXTENSIONS: if f.endswith(ext): return True log.error("Failed upload: Not an allowed file extension: %s", f) raise SystemExit
python
def check_for_allowed_file(f): """ Checks a file extension against a list of seq file exts """ for ext in SUPPORTED_EXTENSIONS: if f.endswith(ext): return True log.error("Failed upload: Not an allowed file extension: %s", f) raise SystemExit
Checks a file extension against a list of seq file exts
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L263-L271
onecodex/onecodex
onecodex/utils.py
collapse_user
def collapse_user(fp): """ Converts a path back to ~/ from expanduser() """ home_dir = os.path.expanduser("~") abs_path = os.path.abspath(fp) return abs_path.replace(home_dir, "~")
python
def collapse_user(fp): """ Converts a path back to ~/ from expanduser() """ home_dir = os.path.expanduser("~") abs_path = os.path.abspath(fp) return abs_path.replace(home_dir, "~")
Converts a path back to ~/ from expanduser()
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L274-L280
onecodex/onecodex
onecodex/utils.py
telemetry
def telemetry(fn): """ Decorator for CLI and other functions that need special Sentry client handling. This function is only required for functions that may exit *before* we set up the ._raven_client object on the Api instance *or* that specifically catch and re-raise exceptions or call sys.exit dir...
python
def telemetry(fn): """ Decorator for CLI and other functions that need special Sentry client handling. This function is only required for functions that may exit *before* we set up the ._raven_client object on the Api instance *or* that specifically catch and re-raise exceptions or call sys.exit dir...
Decorator for CLI and other functions that need special Sentry client handling. This function is only required for functions that may exit *before* we set up the ._raven_client object on the Api instance *or* that specifically catch and re-raise exceptions or call sys.exit directly. Note that this also...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L353-L393
onecodex/onecodex
onecodex/utils.py
pretty_errors
def pretty_errors(fn): """ Decorator for the CLI for catching errors and then calling sys.exit(1). For now, this is intended for use with the CLI and scripts where we only use OneCodexExceptions (incl. ValidationError) and UploadException. """ @wraps(fn) def pretty_errors_wrapper(*args, **...
python
def pretty_errors(fn): """ Decorator for the CLI for catching errors and then calling sys.exit(1). For now, this is intended for use with the CLI and scripts where we only use OneCodexExceptions (incl. ValidationError) and UploadException. """ @wraps(fn) def pretty_errors_wrapper(*args, **...
Decorator for the CLI for catching errors and then calling sys.exit(1). For now, this is intended for use with the CLI and scripts where we only use OneCodexExceptions (incl. ValidationError) and UploadException.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L396-L413
onecodex/onecodex
onecodex/utils.py
atexit_unregister
def atexit_unregister(func, *args, **kwargs): """Python 2/3 compatible method for unregistering exit function. Python2 has no atexit.unregister function :/ """ try: atexit.unregister(func, *args, **kwargs) except AttributeError: # This code runs in Python 2.7 *only* # Only r...
python
def atexit_unregister(func, *args, **kwargs): """Python 2/3 compatible method for unregistering exit function. Python2 has no atexit.unregister function :/ """ try: atexit.unregister(func, *args, **kwargs) except AttributeError: # This code runs in Python 2.7 *only* # Only r...
Python 2/3 compatible method for unregistering exit function. Python2 has no atexit.unregister function :/
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L470-L483
onecodex/onecodex
onecodex/taxonomy.py
TaxonomyMixin.tree_build
def tree_build(self): """Build a tree from the taxonomy data present in this `ClassificationsDataFrame` or `SampleCollection`. Returns ------- `skbio.tree.TreeNode`, the root node of a tree that contains all the taxa in the current analysis and their parents leading back...
python
def tree_build(self): """Build a tree from the taxonomy data present in this `ClassificationsDataFrame` or `SampleCollection`. Returns ------- `skbio.tree.TreeNode`, the root node of a tree that contains all the taxa in the current analysis and their parents leading back...
Build a tree from the taxonomy data present in this `ClassificationsDataFrame` or `SampleCollection`. Returns ------- `skbio.tree.TreeNode`, the root node of a tree that contains all the taxa in the current analysis and their parents leading back to the root node.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/taxonomy.py#L5-L42
onecodex/onecodex
onecodex/taxonomy.py
TaxonomyMixin.tree_prune_tax_ids
def tree_prune_tax_ids(self, tree, tax_ids): """Prunes a tree back to contain only the tax_ids in the list and their parents. Parameters ---------- tree : `skbio.tree.TreeNode` The root node of the tree to perform this operation on. tax_ids : `list` A `li...
python
def tree_prune_tax_ids(self, tree, tax_ids): """Prunes a tree back to contain only the tax_ids in the list and their parents. Parameters ---------- tree : `skbio.tree.TreeNode` The root node of the tree to perform this operation on. tax_ids : `list` A `li...
Prunes a tree back to contain only the tax_ids in the list and their parents. Parameters ---------- tree : `skbio.tree.TreeNode` The root node of the tree to perform this operation on. tax_ids : `list` A `list` of taxonomic IDs to keep in the tree. Retur...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/taxonomy.py#L44-L68
onecodex/onecodex
onecodex/taxonomy.py
TaxonomyMixin.tree_prune_rank
def tree_prune_rank(self, tree, rank="species"): """Takes a TreeNode tree and prunes off any tips not at the specified rank and backwards up until all of the tips are at the specified rank. Parameters ---------- tree : `skbio.tree.TreeNode` The root node of the tree ...
python
def tree_prune_rank(self, tree, rank="species"): """Takes a TreeNode tree and prunes off any tips not at the specified rank and backwards up until all of the tips are at the specified rank. Parameters ---------- tree : `skbio.tree.TreeNode` The root node of the tree ...
Takes a TreeNode tree and prunes off any tips not at the specified rank and backwards up until all of the tips are at the specified rank. Parameters ---------- tree : `skbio.tree.TreeNode` The root node of the tree to perform this operation on. rank : {kingdom', 'phy...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/taxonomy.py#L70-L106
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
write_file_elements_to_strings_file
def write_file_elements_to_strings_file(file_path, file_elements): """ Write elements to the string file Args: file_path (str): The path to the strings file file_elements (list) : List of elements to write to the file. """ f = open_strings_file(file_path, "w") for element in file_el...
python
def write_file_elements_to_strings_file(file_path, file_elements): """ Write elements to the string file Args: file_path (str): The path to the strings file file_elements (list) : List of elements to write to the file. """ f = open_strings_file(file_path, "w") for element in file_el...
Write elements to the string file Args: file_path (str): The path to the strings file file_elements (list) : List of elements to write to the file.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L51-L63
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
setup_logging
def setup_logging(args=None): """ Setup logging module. Args: args (optional): The arguments returned by the argparse module. """ logging_level = logging.WARNING if args is not None and args.verbose: logging_level = logging.INFO config = {"level": logging_level, "format": "jtloc...
python
def setup_logging(args=None): """ Setup logging module. Args: args (optional): The arguments returned by the argparse module. """ logging_level = logging.WARNING if args is not None and args.verbose: logging_level = logging.INFO config = {"level": logging_level, "format": "jtloc...
Setup logging module. Args: args (optional): The arguments returned by the argparse module.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L66-L80
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
__generate_localization_dictionary_from_file
def __generate_localization_dictionary_from_file(file_path, localization_entry_attribute_name_for_key): """ Generates a dictionary mapping between keys (defined by the given attribute name) and localization entries. Args: file_path (str): The strings file path. localization_entry_attribute_name...
python
def __generate_localization_dictionary_from_file(file_path, localization_entry_attribute_name_for_key): """ Generates a dictionary mapping between keys (defined by the given attribute name) and localization entries. Args: file_path (str): The strings file path. localization_entry_attribute_name...
Generates a dictionary mapping between keys (defined by the given attribute name) and localization entries. Args: file_path (str): The strings file path. localization_entry_attribute_name_for_key: The name of the attribute of LocalizationEntry to use as key. Returns: dict: A dictionary...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L83-L105
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
extract_header_comment_key_value_tuples_from_file
def extract_header_comment_key_value_tuples_from_file(file_descriptor): """ Extracts tuples representing comments and localization entries from strings file. Args: file_descriptor (file): The file to read the tuples from Returns: list : List of tuples representing the headers and localizat...
python
def extract_header_comment_key_value_tuples_from_file(file_descriptor): """ Extracts tuples representing comments and localization entries from strings file. Args: file_descriptor (file): The file to read the tuples from Returns: list : List of tuples representing the headers and localizat...
Extracts tuples representing comments and localization entries from strings file. Args: file_descriptor (file): The file to read the tuples from Returns: list : List of tuples representing the headers and localization entries.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L132-L152
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
extract_jtl_string_pairs_from_text_file
def extract_jtl_string_pairs_from_text_file(results_dict, file_path): """ Extracts all string pairs matching the JTL pattern from given text file. This can be used as an "extract_func" argument in the extract_string_pairs_in_directory method. Args: results_dict (dict): The dict to add the the stri...
python
def extract_jtl_string_pairs_from_text_file(results_dict, file_path): """ Extracts all string pairs matching the JTL pattern from given text file. This can be used as an "extract_func" argument in the extract_string_pairs_in_directory method. Args: results_dict (dict): The dict to add the the stri...
Extracts all string pairs matching the JTL pattern from given text file. This can be used as an "extract_func" argument in the extract_string_pairs_in_directory method. Args: results_dict (dict): The dict to add the the string pairs to. file_path (str): The path of the file from which to extra...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L155-L168
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
extract_string_pairs_in_directory
def extract_string_pairs_in_directory(directory_path, extract_func, filter_func): """ Retrieves all string pairs in the directory Args: directory_path (str): The path of the directory containing the file to extract string pairs from. extract_func (function): Function for extracting the localiza...
python
def extract_string_pairs_in_directory(directory_path, extract_func, filter_func): """ Retrieves all string pairs in the directory Args: directory_path (str): The path of the directory containing the file to extract string pairs from. extract_func (function): Function for extracting the localiza...
Retrieves all string pairs in the directory Args: directory_path (str): The path of the directory containing the file to extract string pairs from. extract_func (function): Function for extracting the localization keys and comments from the files. The extract function receives 2 paramet...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L171-L198
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
write_entry_to_file
def write_entry_to_file(file_descriptor, entry_comment, entry_key): """ Writes a localization entry to the file Args: file_descriptor (file, instance): The file to write the entry to. entry_comment (str): The entry's comment. entry_key (str): The entry's key. """ escaped_key = r...
python
def write_entry_to_file(file_descriptor, entry_comment, entry_key): """ Writes a localization entry to the file Args: file_descriptor (file, instance): The file to write the entry to. entry_comment (str): The entry's comment. entry_key (str): The entry's key. """ escaped_key = r...
Writes a localization entry to the file Args: file_descriptor (file, instance): The file to write the entry to. entry_comment (str): The entry's comment. entry_key (str): The entry's key.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L201-L211
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
append_dictionary_to_file
def append_dictionary_to_file(localization_key_to_comment, file_path, section_name): """ Appends dictionary of localization keys and comments to a file Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_path (str): The path of the file to append to....
python
def append_dictionary_to_file(localization_key_to_comment, file_path, section_name): """ Appends dictionary of localization keys and comments to a file Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_path (str): The path of the file to append to....
Appends dictionary of localization keys and comments to a file Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_path (str): The path of the file to append to. section_name (str): The name of the section.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L224-L238
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
write_dict_to_new_file
def write_dict_to_new_file(file_name, localization_key_to_comment): """ Writes dictionary of localization keys and comments to a file. Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_name (str): The path of the file to append to. """ out...
python
def write_dict_to_new_file(file_name, localization_key_to_comment): """ Writes dictionary of localization keys and comments to a file. Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_name (str): The path of the file to append to. """ out...
Writes dictionary of localization keys and comments to a file. Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_name (str): The path of the file to append to.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L241-L253
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
find_files
def find_files(base_dir, extensions, exclude_dirs=list()): """ Find all files matching the given extensions. Args: base_dir (str): Path of base directory to search in. extensions (list): A list of file extensions to search for. exclude_dirs (list): A list of directories to exclude from ...
python
def find_files(base_dir, extensions, exclude_dirs=list()): """ Find all files matching the given extensions. Args: base_dir (str): Path of base directory to search in. extensions (list): A list of file extensions to search for. exclude_dirs (list): A list of directories to exclude from ...
Find all files matching the given extensions. Args: base_dir (str): Path of base directory to search in. extensions (list): A list of file extensions to search for. exclude_dirs (list): A list of directories to exclude from search. Returns: list of paths that match the search
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L256-L273
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
should_include_file_in_search
def should_include_file_in_search(file_name, extensions, exclude_dirs): """ Whether or not a filename matches a search criteria according to arguments. Args: file_name (str): A file path to check. extensions (list): A list of file extensions file should match. exclude_dirs (list): A lis...
python
def should_include_file_in_search(file_name, extensions, exclude_dirs): """ Whether or not a filename matches a search criteria according to arguments. Args: file_name (str): A file path to check. extensions (list): A list of file extensions file should match. exclude_dirs (list): A lis...
Whether or not a filename matches a search criteria according to arguments. Args: file_name (str): A file path to check. extensions (list): A list of file extensions file should match. exclude_dirs (list): A list of directories to exclude from search. Returns: A boolean of whet...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L276-L289
onecodex/onecodex
onecodex/analyses.py
AnalysisMixin._get_auto_rank
def _get_auto_rank(self, rank): """Tries to figure out what rank we should use for analyses""" if rank == "auto": # if we're an accessor for a ClassificationsDataFrame, use its _rank property if self.__class__.__name__ == "OneCodexAccessor": return self._rank ...
python
def _get_auto_rank(self, rank): """Tries to figure out what rank we should use for analyses""" if rank == "auto": # if we're an accessor for a ClassificationsDataFrame, use its _rank property if self.__class__.__name__ == "OneCodexAccessor": return self._rank ...
Tries to figure out what rank we should use for analyses
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/analyses.py#L27-L40
onecodex/onecodex
onecodex/analyses.py
AnalysisMixin._guess_normalized
def _guess_normalized(self): """Returns true if the collated counts in `self._results` appear to be normalized. Notes ----- It's possible that the _results df has already been normalized, which can cause some methods to fail. This method lets us guess whether that's true and act...
python
def _guess_normalized(self): """Returns true if the collated counts in `self._results` appear to be normalized. Notes ----- It's possible that the _results df has already been normalized, which can cause some methods to fail. This method lets us guess whether that's true and act...
Returns true if the collated counts in `self._results` appear to be normalized. Notes ----- It's possible that the _results df has already been normalized, which can cause some methods to fail. This method lets us guess whether that's true and act accordingly.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/analyses.py#L42-L54
onecodex/onecodex
onecodex/analyses.py
AnalysisMixin._metadata_fetch
def _metadata_fetch(self, metadata_fields, label=None): """Takes a list of metadata fields, some of which can contain taxon names or taxon IDs, and returns a DataFrame with transformed data that can be used for plotting. Parameters ---------- metadata_fields : `list` of `string`...
python
def _metadata_fetch(self, metadata_fields, label=None): """Takes a list of metadata fields, some of which can contain taxon names or taxon IDs, and returns a DataFrame with transformed data that can be used for plotting. Parameters ---------- metadata_fields : `list` of `string`...
Takes a list of metadata fields, some of which can contain taxon names or taxon IDs, and returns a DataFrame with transformed data that can be used for plotting. Parameters ---------- metadata_fields : `list` of `string` A list of metadata fields, taxon names, or taxon IDs t...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/analyses.py#L56-L224
onecodex/onecodex
onecodex/analyses.py
AnalysisMixin.to_df
def to_df( self, rank="auto", top_n=None, threshold=None, remove_zeros=True, normalize="auto", table_format="wide", ): """Takes the ClassificationsDataFrame associated with these samples, or SampleCollection, does some filtering, and returns a ...
python
def to_df( self, rank="auto", top_n=None, threshold=None, remove_zeros=True, normalize="auto", table_format="wide", ): """Takes the ClassificationsDataFrame associated with these samples, or SampleCollection, does some filtering, and returns a ...
Takes the ClassificationsDataFrame associated with these samples, or SampleCollection, does some filtering, and returns a ClassificationsDataFrame copy. Parameters ---------- rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analy...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/analyses.py#L226-L329
onecodex/onecodex
onecodex/notebooks/exporters.py
OneCodexHTMLExporter.from_notebook_node
def from_notebook_node(self, nb, resources=None, **kw): """Uses nbconvert's HTMLExporter to generate HTML, with slight modifications. Notes ----- This exporter will only save cells generated with Altair/Vega if they have an SVG image type stored with them. This data is only stor...
python
def from_notebook_node(self, nb, resources=None, **kw): """Uses nbconvert's HTMLExporter to generate HTML, with slight modifications. Notes ----- This exporter will only save cells generated with Altair/Vega if they have an SVG image type stored with them. This data is only stor...
Uses nbconvert's HTMLExporter to generate HTML, with slight modifications. Notes ----- This exporter will only save cells generated with Altair/Vega if they have an SVG image type stored with them. This data is only stored if our fork of `ipyvega` is installed or the onecodex # ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/notebooks/exporters.py#L42-L145
onecodex/onecodex
onecodex/notebooks/exporters.py
OneCodexPDFExporter.from_notebook_node
def from_notebook_node(self, nb, resources=None, **kw): """Takes output of OneCodexHTMLExporter and runs Weasyprint to get a PDF.""" from weasyprint import HTML, CSS nb = copy.deepcopy(nb) output, resources = super(OneCodexPDFExporter, self).from_notebook_node( nb, resource...
python
def from_notebook_node(self, nb, resources=None, **kw): """Takes output of OneCodexHTMLExporter and runs Weasyprint to get a PDF.""" from weasyprint import HTML, CSS nb = copy.deepcopy(nb) output, resources = super(OneCodexPDFExporter, self).from_notebook_node( nb, resource...
Takes output of OneCodexHTMLExporter and runs Weasyprint to get a PDF.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/notebooks/exporters.py#L160-L174
onecodex/onecodex
onecodex/notebooks/exporters.py
OneCodexDocumentExporter.from_notebook_node
def from_notebook_node(self, nb, resources=None, **kw): """Takes PDF output from PDFExporter and uploads to One Codex Documents portal.""" output, resources = super(OneCodexDocumentExporter, self).from_notebook_node( nb, resources=resources, **kw ) from onecodex import Api ...
python
def from_notebook_node(self, nb, resources=None, **kw): """Takes PDF output from PDFExporter and uploads to One Codex Documents portal.""" output, resources = super(OneCodexDocumentExporter, self).from_notebook_node( nb, resources=resources, **kw ) from onecodex import Api ...
Takes PDF output from PDFExporter and uploads to One Codex Documents portal.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/notebooks/exporters.py#L185-L219
joytunes/JTLocalize
localization_flow/jtlocalize/genstrings.py
generate_strings
def generate_strings(project_base_dir, localization_bundle_path, tmp_directory, exclude_dirs, include_strings_file, special_ui_components_prefix): """ Calls the builtin 'genstrings' command with JTLocalizedString as the string to search for, and adds strings extracted from UI elements i...
python
def generate_strings(project_base_dir, localization_bundle_path, tmp_directory, exclude_dirs, include_strings_file, special_ui_components_prefix): """ Calls the builtin 'genstrings' command with JTLocalizedString as the string to search for, and adds strings extracted from UI elements i...
Calls the builtin 'genstrings' command with JTLocalizedString as the string to search for, and adds strings extracted from UI elements internationalized with 'JTL' + removes duplications.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/genstrings.py#L64-L122
onecodex/onecodex
onecodex/models/collection.py
SampleCollection.filter
def filter(self, filter_func): """Return a new SampleCollection containing only samples meeting the filter criteria. Will pass any kwargs (e.g., field or skip_missing) used when instantiating the current class on to the new SampleCollection that is returned. Parameters --------...
python
def filter(self, filter_func): """Return a new SampleCollection containing only samples meeting the filter criteria. Will pass any kwargs (e.g., field or skip_missing) used when instantiating the current class on to the new SampleCollection that is returned. Parameters --------...
Return a new SampleCollection containing only samples meeting the filter criteria. Will pass any kwargs (e.g., field or skip_missing) used when instantiating the current class on to the new SampleCollection that is returned. Parameters ---------- filter_func : `callable` ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L89-L117
onecodex/onecodex
onecodex/models/collection.py
SampleCollection._classification_fetch
def _classification_fetch(self, skip_missing=None): """Turns a list of objects associated with a classification result into a list of Classifications objects. Parameters ---------- skip_missing : `bool` If an analysis was not successful, exclude it, warn, and keep go...
python
def _classification_fetch(self, skip_missing=None): """Turns a list of objects associated with a classification result into a list of Classifications objects. Parameters ---------- skip_missing : `bool` If an analysis was not successful, exclude it, warn, and keep go...
Turns a list of objects associated with a classification result into a list of Classifications objects. Parameters ---------- skip_missing : `bool` If an analysis was not successful, exclude it, warn, and keep going Returns ------- None, but stores a...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L123-L156
onecodex/onecodex
onecodex/models/collection.py
SampleCollection._collate_metadata
def _collate_metadata(self): """Turns a list of objects associated with a classification result into a DataFrame of metadata. Returns ------- None, but stores a result in self._cached. """ import pandas as pd DEFAULT_FIELDS = None metadata = [] ...
python
def _collate_metadata(self): """Turns a list of objects associated with a classification result into a DataFrame of metadata. Returns ------- None, but stores a result in self._cached. """ import pandas as pd DEFAULT_FIELDS = None metadata = [] ...
Turns a list of objects associated with a classification result into a DataFrame of metadata. Returns ------- None, but stores a result in self._cached.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L165-L203
onecodex/onecodex
onecodex/models/collection.py
SampleCollection._collate_results
def _collate_results(self, field=None): """For a list of objects associated with a classification result, return the results as a DataFrame and dict of taxa info. Parameters ---------- field : {'readcount_w_children', 'readcount', 'abundance'} Which field to use for ...
python
def _collate_results(self, field=None): """For a list of objects associated with a classification result, return the results as a DataFrame and dict of taxa info. Parameters ---------- field : {'readcount_w_children', 'readcount', 'abundance'} Which field to use for ...
For a list of objects associated with a classification result, return the results as a DataFrame and dict of taxa info. Parameters ---------- field : {'readcount_w_children', 'readcount', 'abundance'} Which field to use for the abundance/count of a particular taxon in a samp...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L212-L271
onecodex/onecodex
onecodex/models/collection.py
SampleCollection.to_otu
def to_otu(self, biom_id=None): """Converts a list of objects associated with a classification result into a `dict` resembling an OTU table. Parameters ---------- biom_id : `string`, optional Optionally specify an `id` field for the generated v1 BIOM file. R...
python
def to_otu(self, biom_id=None): """Converts a list of objects associated with a classification result into a `dict` resembling an OTU table. Parameters ---------- biom_id : `string`, optional Optionally specify an `id` field for the generated v1 BIOM file. R...
Converts a list of objects associated with a classification result into a `dict` resembling an OTU table. Parameters ---------- biom_id : `string`, optional Optionally specify an `id` field for the generated v1 BIOM file. Returns ------- otu_table : ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L294-L371
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_merge_back.py
localization_merge_back
def localization_merge_back(updated_localizable_file, old_translated_file, new_translated_file, merged_translated_file): """ Generates a file merging the old translations and the new ones. Args: updated_localizable_file (str): The path to the updated localization strings file, meaning the strings that ...
python
def localization_merge_back(updated_localizable_file, old_translated_file, new_translated_file, merged_translated_file): """ Generates a file merging the old translations and the new ones. Args: updated_localizable_file (str): The path to the updated localization strings file, meaning the strings that ...
Generates a file merging the old translations and the new ones. Args: updated_localizable_file (str): The path to the updated localization strings file, meaning the strings that require translation. old_translated_file (str): The path to the strings file containing the previously transl...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_merge_back.py#L28-L62
onecodex/onecodex
onecodex/viz/_primitives.py
boxplot
def boxplot(df, category, quantity, category_type="N", title=None, xlabel=None, ylabel=None): """Plot a simple boxplot using Altair. Parameters ---------- df : `pandas.DataFrame` Contains columns matching 'category' and 'quantity' labels, at a minimum. category : `string` The name o...
python
def boxplot(df, category, quantity, category_type="N", title=None, xlabel=None, ylabel=None): """Plot a simple boxplot using Altair. Parameters ---------- df : `pandas.DataFrame` Contains columns matching 'category' and 'quantity' labels, at a minimum. category : `string` The name o...
Plot a simple boxplot using Altair. Parameters ---------- df : `pandas.DataFrame` Contains columns matching 'category' and 'quantity' labels, at a minimum. category : `string` The name of the column in df used to group values on the horizontal axis. quantity : `string` The n...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/viz/_primitives.py#L7-L71
onecodex/onecodex
onecodex/viz/_primitives.py
dendrogram
def dendrogram(tree): """Plot a simple square dendrogram using Altair. Parameters ---------- tree : `dict` returned by `scipy.cluster.hierarchy.dendrogram` Contains, at a minimum, 'icoord', 'dcoord', and 'leaves' keys. Scipy does all the work of determining where the lines in the tree should go...
python
def dendrogram(tree): """Plot a simple square dendrogram using Altair. Parameters ---------- tree : `dict` returned by `scipy.cluster.hierarchy.dendrogram` Contains, at a minimum, 'icoord', 'dcoord', and 'leaves' keys. Scipy does all the work of determining where the lines in the tree should go...
Plot a simple square dendrogram using Altair. Parameters ---------- tree : `dict` returned by `scipy.cluster.hierarchy.dendrogram` Contains, at a minimum, 'icoord', 'dcoord', and 'leaves' keys. Scipy does all the work of determining where the lines in the tree should go. All we have to do is draw t...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/viz/_primitives.py#L74-L117
joytunes/JTLocalize
localization_flow/jtlocalize/core/add_genstrings_comments_to_file.py
add_genstrings_comments_to_file
def add_genstrings_comments_to_file(localization_file, genstrings_err): """ Adds the comments produced by the genstrings script for duplicate keys. Args: localization_file (str): The path to the strings file. """ errors_to_log = [line for line in genstrings_err.splitlines() if "used with mult...
python
def add_genstrings_comments_to_file(localization_file, genstrings_err): """ Adds the comments produced by the genstrings script for duplicate keys. Args: localization_file (str): The path to the strings file. """ errors_to_log = [line for line in genstrings_err.splitlines() if "used with mult...
Adds the comments produced by the genstrings script for duplicate keys. Args: localization_file (str): The path to the strings file.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/add_genstrings_comments_to_file.py#L26-L57
onecodex/onecodex
onecodex/viz/_distance.py
VizDistanceMixin.plot_distance
def plot_distance( self, rank="auto", metric="braycurtis", title=None, xlabel=None, ylabel=None, tooltip=None, return_chart=False, linkage="average", label=None, ): """Plot beta diversity distance matrix as a heatmap and dendrog...
python
def plot_distance( self, rank="auto", metric="braycurtis", title=None, xlabel=None, ylabel=None, tooltip=None, return_chart=False, linkage="average", label=None, ): """Plot beta diversity distance matrix as a heatmap and dendrog...
Plot beta diversity distance matrix as a heatmap and dendrogram. Parameters ---------- rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analysis will be restricted to abundances of taxa at the specified level. metric : {'braycurt...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/viz/_distance.py#L76-L201
onecodex/onecodex
onecodex/viz/_distance.py
VizDistanceMixin.plot_mds
def plot_mds( self, rank="auto", metric="braycurtis", method="pcoa", title=None, xlabel=None, ylabel=None, color=None, size=None, tooltip=None, return_chart=False, label=None, ): """Plot beta diversity distance m...
python
def plot_mds( self, rank="auto", metric="braycurtis", method="pcoa", title=None, xlabel=None, ylabel=None, color=None, size=None, tooltip=None, return_chart=False, label=None, ): """Plot beta diversity distance m...
Plot beta diversity distance matrix using multidimensional scaling (MDS). Parameters ---------- rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analysis will be restricted to abundances of taxa at the specified level. metric : {...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/viz/_distance.py#L203-L371
onecodex/onecodex
onecodex/models/helpers.py
ResourceDownloadMixin.download
def download(self, path=None, file_obj=None, progressbar=False): """Downloads files from One Codex. Parameters ---------- path : `string`, optional Full path to save the file to. If omitted, defaults to the original filename in the current working directory. ...
python
def download(self, path=None, file_obj=None, progressbar=False): """Downloads files from One Codex. Parameters ---------- path : `string`, optional Full path to save the file to. If omitted, defaults to the original filename in the current working directory. ...
Downloads files from One Codex. Parameters ---------- path : `string`, optional Full path to save the file to. If omitted, defaults to the original filename in the current working directory. file_obj : file-like object, optional Rather than save the f...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/helpers.py#L93-L159
onecodex/onecodex
onecodex/models/misc.py
Documents.upload
def upload(cls, file_path, progressbar=None): """Uploads a series of files to the One Codex server. Parameters ---------- file_path : `string` A path to a file on the system. progressbar : `click.progressbar`, optional If passed, display a progress bar us...
python
def upload(cls, file_path, progressbar=None): """Uploads a series of files to the One Codex server. Parameters ---------- file_path : `string` A path to a file on the system. progressbar : `click.progressbar`, optional If passed, display a progress bar us...
Uploads a series of files to the One Codex server. Parameters ---------- file_path : `string` A path to a file on the system. progressbar : `click.progressbar`, optional If passed, display a progress bar using Click. Returns ------- A `Sa...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/misc.py#L58-L75
joytunes/JTLocalize
localization_flow/jtlocalize/prepare_for_translation.py
prepare_for_translation
def prepare_for_translation(localization_bundle_path): """ Prepares the localization bundle for translation. This means, after creating the strings files using genstrings.sh, this will produce '.pending' files, that contain the files that are yet to be translated. Args: localization_bundle_pat...
python
def prepare_for_translation(localization_bundle_path): """ Prepares the localization bundle for translation. This means, after creating the strings files using genstrings.sh, this will produce '.pending' files, that contain the files that are yet to be translated. Args: localization_bundle_pat...
Prepares the localization bundle for translation. This means, after creating the strings files using genstrings.sh, this will produce '.pending' files, that contain the files that are yet to be translated. Args: localization_bundle_path (str): The path to the localization bundle.
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/prepare_for_translation.py#L31-L60
onecodex/onecodex
onecodex/cli.py
onecodex
def onecodex(ctx, api_key, no_pprint, verbose, telemetry): """One Codex v1 API command line interface""" # set up the context for sub commands click.Context.get_usage = click.Context.get_help ctx.obj = {} ctx.obj["API_KEY"] = api_key ctx.obj["NOPPRINT"] = no_pprint ctx.obj["TELEMETRY"] = tel...
python
def onecodex(ctx, api_key, no_pprint, verbose, telemetry): """One Codex v1 API command line interface""" # set up the context for sub commands click.Context.get_usage = click.Context.get_help ctx.obj = {} ctx.obj["API_KEY"] = api_key ctx.obj["NOPPRINT"] = no_pprint ctx.obj["TELEMETRY"] = tel...
One Codex v1 API command line interface
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/cli.py#L68-L82
onecodex/onecodex
onecodex/cli.py
documents_upload
def documents_upload(ctx, max_threads, files): """Upload a document file (of any type) to One Codex""" if len(files) == 0: click.echo(ctx.get_help()) return files = list(files) bar = click.progressbar(length=sum([_file_size(x) for x in files]), label="Uploading... ") run_via_thread...
python
def documents_upload(ctx, max_threads, files): """Upload a document file (of any type) to One Codex""" if len(files) == 0: click.echo(ctx.get_help()) return files = list(files) bar = click.progressbar(length=sum([_file_size(x) for x in files]), label="Uploading... ") run_via_thread...
Upload a document file (of any type) to One Codex
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/cli.py#L176-L191
onecodex/onecodex
onecodex/cli.py
classifications
def classifications(ctx, classifications, results, readlevel, readlevel_path): """Retrieve performed metagenomic classifications""" # basic operation -- just print if not readlevel and not results: cli_resource_fetcher(ctx, "classifications", classifications) # fetch the results elif not r...
python
def classifications(ctx, classifications, results, readlevel, readlevel_path): """Retrieve performed metagenomic classifications""" # basic operation -- just print if not readlevel and not results: cli_resource_fetcher(ctx, "classifications", classifications) # fetch the results elif not r...
Retrieve performed metagenomic classifications
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/cli.py#L252-L290
onecodex/onecodex
onecodex/cli.py
upload
def upload( ctx, files, max_threads, prompt, forward, reverse, tags, metadata, project_id, coerce_ascii ): """Upload a FASTA or FASTQ (optionally gzip'd) to One Codex""" appendables = {} if tags: appendables["tags"] = [] for tag in tags: appendables["tags"].append(tag) ...
python
def upload( ctx, files, max_threads, prompt, forward, reverse, tags, metadata, project_id, coerce_ascii ): """Upload a FASTA or FASTQ (optionally gzip'd) to One Codex""" appendables = {} if tags: appendables["tags"] = [] for tag in tags: appendables["tags"].append(tag) ...
Upload a FASTA or FASTQ (optionally gzip'd) to One Codex
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/cli.py#L333-L439
onecodex/onecodex
onecodex/cli.py
login
def login(ctx): """Add an API key (saved in ~/.onecodex)""" base_url = os.environ.get("ONE_CODEX_API_BASE", "https://app.onecodex.com") if not ctx.obj["API_KEY"]: _login(base_url) else: email = _login(base_url, api_key=ctx.obj["API_KEY"]) ocx = Api(api_key=ctx.obj["API_KEY"], tel...
python
def login(ctx): """Add an API key (saved in ~/.onecodex)""" base_url = os.environ.get("ONE_CODEX_API_BASE", "https://app.onecodex.com") if not ctx.obj["API_KEY"]: _login(base_url) else: email = _login(base_url, api_key=ctx.obj["API_KEY"]) ocx = Api(api_key=ctx.obj["API_KEY"], tel...
Add an API key (saved in ~/.onecodex)
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/cli.py#L445-L459
onecodex/onecodex
onecodex/scripts/subset_reads.py
make_taxonomy_dict
def make_taxonomy_dict(classification, parent=False): """ Takes a classification data frame returned by the API and parses it into a dictionary mapping a tax_id to its children (or parent). Restricted to tax_id's that are represented in the classification results. """ tax_id_map = {} i...
python
def make_taxonomy_dict(classification, parent=False): """ Takes a classification data frame returned by the API and parses it into a dictionary mapping a tax_id to its children (or parent). Restricted to tax_id's that are represented in the classification results. """ tax_id_map = {} i...
Takes a classification data frame returned by the API and parses it into a dictionary mapping a tax_id to its children (or parent). Restricted to tax_id's that are represented in the classification results.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/scripts/subset_reads.py#L63-L85
onecodex/onecodex
onecodex/scripts/subset_reads.py
recurse_taxonomy_map
def recurse_taxonomy_map(tax_id_map, tax_id, parent=False): """ Takes the output dict from make_taxonomy_map and an input tax_id and recurses either up or down through the tree to get /all/ children (or parents) of the given tax_id. """ if parent: # TODO: allow filtering on tax_id and i...
python
def recurse_taxonomy_map(tax_id_map, tax_id, parent=False): """ Takes the output dict from make_taxonomy_map and an input tax_id and recurses either up or down through the tree to get /all/ children (or parents) of the given tax_id. """ if parent: # TODO: allow filtering on tax_id and i...
Takes the output dict from make_taxonomy_map and an input tax_id and recurses either up or down through the tree to get /all/ children (or parents) of the given tax_id.
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/scripts/subset_reads.py#L88-L113
onecodex/onecodex
onecodex/vendored/potion_client/converter.py
schema_resolve_refs
def schema_resolve_refs(schema, ref_resolver=None, root=None): """ Helper method for decoding references. Self-references are resolved automatically; other references are resolved using a callback function. :param object schema: :param callable ref_resolver: :param None root: :return: "...
python
def schema_resolve_refs(schema, ref_resolver=None, root=None): """ Helper method for decoding references. Self-references are resolved automatically; other references are resolved using a callback function. :param object schema: :param callable ref_resolver: :param None root: :return: "...
Helper method for decoding references. Self-references are resolved automatically; other references are resolved using a callback function. :param object schema: :param callable ref_resolver: :param None root: :return:
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/vendored/potion_client/converter.py#L153-L180
onecodex/onecodex
onecodex/notebooks/report.py
reference
def reference(text=None, label=None): """Add a reference to the bibliography and insert a superscript number. Parameters ---------- text : `string`, optional The complete text of the reference, e.g. Roo, et al. "How to Python." Nature, 2019. label : `string`, optional A short label ...
python
def reference(text=None, label=None): """Add a reference to the bibliography and insert a superscript number. Parameters ---------- text : `string`, optional The complete text of the reference, e.g. Roo, et al. "How to Python." Nature, 2019. label : `string`, optional A short label ...
Add a reference to the bibliography and insert a superscript number. Parameters ---------- text : `string`, optional The complete text of the reference, e.g. Roo, et al. "How to Python." Nature, 2019. label : `string`, optional A short label to describe this reference. Notes --...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/notebooks/report.py#L211-L314
onecodex/onecodex
onecodex/vendored/potion_client/__init__.py
Client.resource_factory
def resource_factory(self, name, schema, resource_cls=None): """ Registers a new resource with a given schema. The schema must not have any unresolved references (such as `{"$ref": "#"}` for self-references, or otherwise). A subclass of :class:`Resource` may be provided to add specific f...
python
def resource_factory(self, name, schema, resource_cls=None): """ Registers a new resource with a given schema. The schema must not have any unresolved references (such as `{"$ref": "#"}` for self-references, or otherwise). A subclass of :class:`Resource` may be provided to add specific f...
Registers a new resource with a given schema. The schema must not have any unresolved references (such as `{"$ref": "#"}` for self-references, or otherwise). A subclass of :class:`Resource` may be provided to add specific functionality to the resulting :class:`Resource`. :param str name: ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/vendored/potion_client/__init__.py#L78-L144
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
extract_string_pairs_in_dir
def extract_string_pairs_in_dir(directory, exclude_dirs, special_ui_components_prefix): """ Extract string pairs in the given directory's xib/storyboard files. Args: directory (str): The path to the directory. exclude_dirs (str): A list of directories to exclude from extraction. special...
python
def extract_string_pairs_in_dir(directory, exclude_dirs, special_ui_components_prefix): """ Extract string pairs in the given directory's xib/storyboard files. Args: directory (str): The path to the directory. exclude_dirs (str): A list of directories to exclude from extraction. special...
Extract string pairs in the given directory's xib/storyboard files. Args: directory (str): The path to the directory. exclude_dirs (str): A list of directories to exclude from extraction. special_ui_components_prefix (str): If not None, extraction will not warn about internation...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L32-L49
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
extract_element_internationalized_comment
def extract_element_internationalized_comment(element): """ Extracts the xib element's comment, if the element has been internationalized. Args: element (element): The element from which to extract the comment. Returns: The element's internationalized comment, None if it does not exist, or...
python
def extract_element_internationalized_comment(element): """ Extracts the xib element's comment, if the element has been internationalized. Args: element (element): The element from which to extract the comment. Returns: The element's internationalized comment, None if it does not exist, or...
Extracts the xib element's comment, if the element has been internationalized. Args: element (element): The element from which to extract the comment. Returns: The element's internationalized comment, None if it does not exist, or hasn't been internationalized (according to the JTLocal...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L66-L86
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
warn_if_element_not_of_class
def warn_if_element_not_of_class(element, class_suffix, special_ui_components_prefix): """ Log a warning if the element is not of the given type (indicating that it is not internationalized). Args: element: The xib's XML element. class_name: The type the element should be, but is missing. ...
python
def warn_if_element_not_of_class(element, class_suffix, special_ui_components_prefix): """ Log a warning if the element is not of the given type (indicating that it is not internationalized). Args: element: The xib's XML element. class_name: The type the element should be, but is missing. ...
Log a warning if the element is not of the given type (indicating that it is not internationalized). Args: element: The xib's XML element. class_name: The type the element should be, but is missing. special_ui_components_prefix: If provided, will not warn about class with this prefix (defau...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L89-L103
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
add_string_pairs_from_attributed_ui_element
def add_string_pairs_from_attributed_ui_element(results, ui_element, comment_prefix): """ Adds string pairs from a UI element with attributed text Args: results (list): The list to add the results to. attributed_element (element): The element from the xib that contains, to extract the fragments...
python
def add_string_pairs_from_attributed_ui_element(results, ui_element, comment_prefix): """ Adds string pairs from a UI element with attributed text Args: results (list): The list to add the results to. attributed_element (element): The element from the xib that contains, to extract the fragments...
Adds string pairs from a UI element with attributed text Args: results (list): The list to add the results to. attributed_element (element): The element from the xib that contains, to extract the fragments from. comment_prefix (str): The prefix of the comment to use for extracted string ...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L106-L136
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
add_string_pairs_from_label_element
def add_string_pairs_from_label_element(xib_file, results, label, special_ui_components_prefix): """ Adds string pairs from a label element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. label (element): The label element from the xib, to ex...
python
def add_string_pairs_from_label_element(xib_file, results, label, special_ui_components_prefix): """ Adds string pairs from a label element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. label (element): The label element from the xib, to ex...
Adds string pairs from a label element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. label (element): The label element from the xib, to extract the string pairs from. special_ui_components_prefix (str): If not None, extract...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L139-L167
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
add_string_pairs_from_text_field_element
def add_string_pairs_from_text_field_element(xib_file, results, text_field, special_ui_components_prefix): """ Adds string pairs from a textfield element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. text_field(element): The textfield eleme...
python
def add_string_pairs_from_text_field_element(xib_file, results, text_field, special_ui_components_prefix): """ Adds string pairs from a textfield element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. text_field(element): The textfield eleme...
Adds string pairs from a textfield element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. text_field(element): The textfield element from the xib, to extract the string pairs from. special_ui_components_prefix (str): If not N...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L170-L198
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
add_string_pairs_from_text_view_element
def add_string_pairs_from_text_view_element(xib_file, results, text_view, special_ui_components_prefix): """ Adds string pairs from a textview element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. text_view(element): The textview element fr...
python
def add_string_pairs_from_text_view_element(xib_file, results, text_view, special_ui_components_prefix): """ Adds string pairs from a textview element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. text_view(element): The textview element fr...
Adds string pairs from a textview element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. text_view(element): The textview element from the xib, to extract the string pairs from. special_ui_components_prefix(str): A custom prefix for inte...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L201-L223
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
add_string_pairs_from_button_element
def add_string_pairs_from_button_element(xib_file, results, button, special_ui_components_prefix): """ Adds strings pairs from a button xib element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. button(element): The button element from the x...
python
def add_string_pairs_from_button_element(xib_file, results, button, special_ui_components_prefix): """ Adds strings pairs from a button xib element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. button(element): The button element from the x...
Adds strings pairs from a button xib element. Args: xib_file (str): Path to the xib file. results (list): The list to add the results to. button(element): The button element from the xib, to extract the string pairs from. special_ui_components_prefix(str): A custom prefix for intern...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L226-L254
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
extract_string_pairs_in_ib_file
def extract_string_pairs_in_ib_file(file_path, special_ui_components_prefix): """ Extract the strings pairs (key and comment) from a xib file. Args: file_path (str): The path to the xib file. special_ui_components_prefix (str): If not None, extraction will not warn about internation...
python
def extract_string_pairs_in_ib_file(file_path, special_ui_components_prefix): """ Extract the strings pairs (key and comment) from a xib file. Args: file_path (str): The path to the xib file. special_ui_components_prefix (str): If not None, extraction will not warn about internation...
Extract the strings pairs (key and comment) from a xib file. Args: file_path (str): The path to the xib file. special_ui_components_prefix (str): If not None, extraction will not warn about internationalized UI components with this class prefix. Returns: list: List of tuple...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L257-L295
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_diff.py
localization_diff
def localization_diff(localizable_file, translated_file, excluded_strings_file, output_translation_file): """ Generates a strings file representing the strings that were yet to be translated. Args: localizable_file (str): The path to the localization strings file, meaning the file that represents the s...
python
def localization_diff(localizable_file, translated_file, excluded_strings_file, output_translation_file): """ Generates a strings file representing the strings that were yet to be translated. Args: localizable_file (str): The path to the localization strings file, meaning the file that represents the s...
Generates a strings file representing the strings that were yet to be translated. Args: localizable_file (str): The path to the localization strings file, meaning the file that represents the strings that require translation. translated_file (str): The path to the translated strings fil...
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_diff.py#L32-L88
onecodex/onecodex
onecodex/viz/_metadata.py
VizMetadataMixin.plot_metadata
def plot_metadata( self, rank="auto", haxis="Label", vaxis="simpson", title=None, xlabel=None, ylabel=None, return_chart=False, plot_type="auto", label=None, ): """Plot an arbitrary metadata field versus an arbitrary quantity as...
python
def plot_metadata( self, rank="auto", haxis="Label", vaxis="simpson", title=None, xlabel=None, ylabel=None, return_chart=False, plot_type="auto", label=None, ): """Plot an arbitrary metadata field versus an arbitrary quantity as...
Plot an arbitrary metadata field versus an arbitrary quantity as a boxplot or scatter plot. Parameters ---------- rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analysis will be restricted to abundances of taxa at the specified level. ...
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/viz/_metadata.py#L9-L175
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/__init__.py
add_404_page
def add_404_page(app): """Build an extra ``404.html`` page if no ``"404"`` key is in the ``html_additional_pages`` config. """ is_epub = isinstance(app.builder, EpubBuilder) config_pages = app.config.html_additional_pages if not is_epub and "404" not in config_pages: yield ("404", {}, "...
python
def add_404_page(app): """Build an extra ``404.html`` page if no ``"404"`` key is in the ``html_additional_pages`` config. """ is_epub = isinstance(app.builder, EpubBuilder) config_pages = app.config.html_additional_pages if not is_epub and "404" not in config_pages: yield ("404", {}, "...
Build an extra ``404.html`` page if no ``"404"`` key is in the ``html_additional_pages`` config.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/__init__.py#L52-L60
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/__init__.py
canonical_url
def canonical_url(app, pagename, templatename, context, doctree): """Build the canonical URL for a page. Appends the path for the page to the base URL specified by the ``html_context["canonical_url"]`` config and stores it in ``html_context["page_canonical_url"]``. """ base = context.get("canoni...
python
def canonical_url(app, pagename, templatename, context, doctree): """Build the canonical URL for a page. Appends the path for the page to the base URL specified by the ``html_context["canonical_url"]`` config and stores it in ``html_context["page_canonical_url"]``. """ base = context.get("canoni...
Build the canonical URL for a page. Appends the path for the page to the base URL specified by the ``html_context["canonical_url"]`` config and stores it in ``html_context["page_canonical_url"]``.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/__init__.py#L64-L76
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/__init__.py
singlehtml_sidebars
def singlehtml_sidebars(app): """When using a ``singlehtml`` builder, replace the ``html_sidebars`` config with ``singlehtml_sidebars``. This can be used to change what sidebars are rendered for the single page called ``"index"`` by the builder. """ if app.config.singlehtml_sidebars is not None ...
python
def singlehtml_sidebars(app): """When using a ``singlehtml`` builder, replace the ``html_sidebars`` config with ``singlehtml_sidebars``. This can be used to change what sidebars are rendered for the single page called ``"index"`` by the builder. """ if app.config.singlehtml_sidebars is not None ...
When using a ``singlehtml`` builder, replace the ``html_sidebars`` config with ``singlehtml_sidebars``. This can be used to change what sidebars are rendered for the single page called ``"index"`` by the builder.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/__init__.py#L80-L89
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/__init__.py
skip_internal
def skip_internal(app, what, name, obj, skip, options): """Skip rendering autodoc when the docstring contains a line with only the string `:internal:`. """ docstring = inspect.getdoc(obj) or "" if skip or re.search(r"^\s*:internal:\s*$", docstring, re.M) is not None: return True
python
def skip_internal(app, what, name, obj, skip, options): """Skip rendering autodoc when the docstring contains a line with only the string `:internal:`. """ docstring = inspect.getdoc(obj) or "" if skip or re.search(r"^\s*:internal:\s*$", docstring, re.M) is not None: return True
Skip rendering autodoc when the docstring contains a line with only the string `:internal:`.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/__init__.py#L93-L100
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/__init__.py
cut_module_meta
def cut_module_meta(app, what, name, obj, options, lines): """Don't render lines that start with ``:copyright:`` or ``:license:`` when rendering module autodoc. These lines are useful meta information in the source code, but are noisy in the docs. """ if what != "module": return lines[:...
python
def cut_module_meta(app, what, name, obj, options, lines): """Don't render lines that start with ``:copyright:`` or ``:license:`` when rendering module autodoc. These lines are useful meta information in the source code, but are noisy in the docs. """ if what != "module": return lines[:...
Don't render lines that start with ``:copyright:`` or ``:license:`` when rendering module autodoc. These lines are useful meta information in the source code, but are noisy in the docs.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/__init__.py#L104-L114
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/__init__.py
get_version
def get_version(name, version_length=2, placeholder="x"): """Ensures that the named package is installed and returns version strings to be used by Sphinx. Sphinx uses ``version`` to mean an abbreviated form of the full version string, which is called ``release``. In ``conf.py``:: release, vers...
python
def get_version(name, version_length=2, placeholder="x"): """Ensures that the named package is installed and returns version strings to be used by Sphinx. Sphinx uses ``version`` to mean an abbreviated form of the full version string, which is called ``release``. In ``conf.py``:: release, vers...
Ensures that the named package is installed and returns version strings to be used by Sphinx. Sphinx uses ``version`` to mean an abbreviated form of the full version string, which is called ``release``. In ``conf.py``:: release, version = get_version("Flask") # release = 1.0.x, version = 1...
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/__init__.py#L117-L151
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/theme_check.py
set_is_pallets_theme
def set_is_pallets_theme(app): """Set the ``is_pallets_theme`` config to ``True`` if the current theme is a decedent of the ``pocoo`` theme. """ if app.config.is_pallets_theme is not None: return theme = getattr(app.builder, "theme", None) while theme is not None: if theme.name...
python
def set_is_pallets_theme(app): """Set the ``is_pallets_theme`` config to ``True`` if the current theme is a decedent of the ``pocoo`` theme. """ if app.config.is_pallets_theme is not None: return theme = getattr(app.builder, "theme", None) while theme is not None: if theme.name...
Set the ``is_pallets_theme`` config to ``True`` if the current theme is a decedent of the ``pocoo`` theme.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/theme_check.py#L4-L20
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/theme_check.py
only_pallets_theme
def only_pallets_theme(default=None): """Create a decorator that calls a function only if the ``is_pallets_theme`` config is ``True``. Used to prevent Sphinx event callbacks from doing anything if the Pallets themes are installed but not used. :: @only_pallets_theme() def inject_value(...
python
def only_pallets_theme(default=None): """Create a decorator that calls a function only if the ``is_pallets_theme`` config is ``True``. Used to prevent Sphinx event callbacks from doing anything if the Pallets themes are installed but not used. :: @only_pallets_theme() def inject_value(...
Create a decorator that calls a function only if the ``is_pallets_theme`` config is ``True``. Used to prevent Sphinx event callbacks from doing anything if the Pallets themes are installed but not used. :: @only_pallets_theme() def inject_value(app): ... app.connect("b...
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/theme_check.py#L23-L50
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/themes/click/domain.py
patch_modules
def patch_modules(): """Patch modules to work better with :meth:`ExampleRunner.invoke`. ``subprocess.call` output is redirected to ``click.echo`` so it shows up in the example output. """ old_call = subprocess.call def dummy_call(*args, **kwargs): with tempfile.TemporaryFile("wb+") as ...
python
def patch_modules(): """Patch modules to work better with :meth:`ExampleRunner.invoke`. ``subprocess.call` output is redirected to ``click.echo`` so it shows up in the example output. """ old_call = subprocess.call def dummy_call(*args, **kwargs): with tempfile.TemporaryFile("wb+") as ...
Patch modules to work better with :meth:`ExampleRunner.invoke`. ``subprocess.call` output is redirected to ``click.echo`` so it shows up in the example output.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/themes/click/domain.py#L62-L84
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/themes/click/domain.py
get_example_runner
def get_example_runner(document): """Get or create the :class:`ExampleRunner` instance associated with a document. """ runner = getattr(document, "click_example_runner", None) if runner is None: runner = document.click_example_runner = ExampleRunner() return runner
python
def get_example_runner(document): """Get or create the :class:`ExampleRunner` instance associated with a document. """ runner = getattr(document, "click_example_runner", None) if runner is None: runner = document.click_example_runner = ExampleRunner() return runner
Get or create the :class:`ExampleRunner` instance associated with a document.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/themes/click/domain.py#L199-L206
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/themes/click/domain.py
ExampleRunner.invoke
def invoke( self, cli, args=None, prog_name=None, input=None, terminate_input=False, env=None, _output_lines=None, **extra ): """Like :meth:`CliRunner.invoke` but displays what the user would enter in the terminal for env vars, ...
python
def invoke( self, cli, args=None, prog_name=None, input=None, terminate_input=False, env=None, _output_lines=None, **extra ): """Like :meth:`CliRunner.invoke` but displays what the user would enter in the terminal for env vars, ...
Like :meth:`CliRunner.invoke` but displays what the user would enter in the terminal for env vars, command args, and prompts. :param terminate_input: Whether to display "^D" after a list of input. :param _output_lines: A list used internally to collect lines to b...
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/themes/click/domain.py#L109-L157
pallets/pallets-sphinx-themes
src/pallets_sphinx_themes/themes/click/domain.py
ExampleRunner.declare_example
def declare_example(self, source): """Execute the given code, adding it to the runner's namespace.""" with patch_modules(): code = compile(source, "<docs>", "exec") exec(code, self.namespace)
python
def declare_example(self, source): """Execute the given code, adding it to the runner's namespace.""" with patch_modules(): code = compile(source, "<docs>", "exec") exec(code, self.namespace)
Execute the given code, adding it to the runner's namespace.
https://github.com/pallets/pallets-sphinx-themes/blob/1d4517d76dd492017f17acd7f72e82e40a1f1bc6/src/pallets_sphinx_themes/themes/click/domain.py#L159-L163