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_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
acorg/dark-matter | dark/diamond/hsp.py | _debugPrint | def _debugPrint(hsp, queryLen, localDict, msg=''):
"""
Print debugging information showing the local variables used during
a call to normalizeHSP and the hsp and then raise an C{AssertionError}.
@param hsp: The HSP C{dict} passed to normalizeHSP.
@param queryLen: the length of the query sequence.
... | python | def _debugPrint(hsp, queryLen, localDict, msg=''):
"""
Print debugging information showing the local variables used during
a call to normalizeHSP and the hsp and then raise an C{AssertionError}.
@param hsp: The HSP C{dict} passed to normalizeHSP.
@param queryLen: the length of the query sequence.
... | [
"def",
"_debugPrint",
"(",
"hsp",
",",
"queryLen",
",",
"localDict",
",",
"msg",
"=",
"''",
")",
":",
"print",
"(",
"'normalizeHSP error:'",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"print",
"(",
"' queryLen: %d'",
"%",
"queryLen",
",",
"file",
"=",... | Print debugging information showing the local variables used during
a call to normalizeHSP and the hsp and then raise an C{AssertionError}.
@param hsp: The HSP C{dict} passed to normalizeHSP.
@param queryLen: the length of the query sequence.
@param localDict: A C{dict} of local variables (as produced ... | [
"Print",
"debugging",
"information",
"showing",
"the",
"local",
"variables",
"used",
"during",
"a",
"call",
"to",
"normalizeHSP",
"and",
"the",
"hsp",
"and",
"then",
"raise",
"an",
"C",
"{",
"AssertionError",
"}",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/diamond/hsp.py#L7-L31 |
acorg/dark-matter | dark/diamond/hsp.py | _sanityCheck | def _sanityCheck(subjectStart, subjectEnd, queryStart, queryEnd,
queryStartInSubject, queryEndInSubject, hsp, queryLen,
subjectGaps, queryGaps, localDict):
"""
Perform some sanity checks on an HSP. Call _debugPrint on any error.
@param subjectStart: The 0-based C{int} star... | python | def _sanityCheck(subjectStart, subjectEnd, queryStart, queryEnd,
queryStartInSubject, queryEndInSubject, hsp, queryLen,
subjectGaps, queryGaps, localDict):
"""
Perform some sanity checks on an HSP. Call _debugPrint on any error.
@param subjectStart: The 0-based C{int} star... | [
"def",
"_sanityCheck",
"(",
"subjectStart",
",",
"subjectEnd",
",",
"queryStart",
",",
"queryEnd",
",",
"queryStartInSubject",
",",
"queryEndInSubject",
",",
"hsp",
",",
"queryLen",
",",
"subjectGaps",
",",
"queryGaps",
",",
"localDict",
")",
":",
"# Subject indic... | Perform some sanity checks on an HSP. Call _debugPrint on any error.
@param subjectStart: The 0-based C{int} start offset of the match in the
subject.
@param subjectEnd: The 0-based C{int} end offset of the match in the
subject.
@param queryStart: The 0-based C{int} start offset of the matc... | [
"Perform",
"some",
"sanity",
"checks",
"on",
"an",
"HSP",
".",
"Call",
"_debugPrint",
"on",
"any",
"error",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/diamond/hsp.py#L34-L82 |
acorg/dark-matter | dark/diamond/hsp.py | normalizeHSP | def normalizeHSP(hsp, queryLen, diamondTask):
"""
Examine an HSP and return information about where the query and subject
match begins and ends. Return a dict with keys that allow the query to
be displayed against the subject. The returned readStartInSubject and
readEndInSubject indices are offsets... | python | def normalizeHSP(hsp, queryLen, diamondTask):
"""
Examine an HSP and return information about where the query and subject
match begins and ends. Return a dict with keys that allow the query to
be displayed against the subject. The returned readStartInSubject and
readEndInSubject indices are offsets... | [
"def",
"normalizeHSP",
"(",
"hsp",
",",
"queryLen",
",",
"diamondTask",
")",
":",
"queryGaps",
",",
"subjectGaps",
"=",
"countGaps",
"(",
"hsp",
"[",
"'btop'",
"]",
")",
"# Make some variables using Python's standard string indexing (start",
"# offset included, end offset... | Examine an HSP and return information about where the query and subject
match begins and ends. Return a dict with keys that allow the query to
be displayed against the subject. The returned readStartInSubject and
readEndInSubject indices are offsets into the subject. I.e., they
indicate where in the su... | [
"Examine",
"an",
"HSP",
"and",
"return",
"information",
"about",
"where",
"the",
"query",
"and",
"subject",
"match",
"begins",
"and",
"ends",
".",
"Return",
"a",
"dict",
"with",
"keys",
"that",
"allow",
"the",
"query",
"to",
"be",
"displayed",
"against",
"... | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/diamond/hsp.py#L85-L197 |
flo-compbio/genometools | genometools/gcloud/service_account.py | get_storage_credentials | def get_storage_credentials(key, read_only=False):
"""Authenticates a service account for reading and/or writing on a bucket.
This uses the `google.oauth2.service_account` module to obtain "scoped
credentials". These can be used with the `google.storage` module.
TODO: docstring"""
if read_only... | python | def get_storage_credentials(key, read_only=False):
"""Authenticates a service account for reading and/or writing on a bucket.
This uses the `google.oauth2.service_account` module to obtain "scoped
credentials". These can be used with the `google.storage` module.
TODO: docstring"""
if read_only... | [
"def",
"get_storage_credentials",
"(",
"key",
",",
"read_only",
"=",
"False",
")",
":",
"if",
"read_only",
":",
"scopes",
"=",
"[",
"'https://www.googleapis.com/auth/devstorage.read_only'",
"]",
"else",
":",
"scopes",
"=",
"[",
"'https://www.googleapis.com/auth/devstora... | Authenticates a service account for reading and/or writing on a bucket.
This uses the `google.oauth2.service_account` module to obtain "scoped
credentials". These can be used with the `google.storage` module.
TODO: docstring | [
"Authenticates",
"a",
"service",
"account",
"for",
"reading",
"and",
"/",
"or",
"writing",
"on",
"a",
"bucket",
".",
"This",
"uses",
"the",
"google",
".",
"oauth2",
".",
"service_account",
"module",
"to",
"obtain",
"scoped",
"credentials",
".",
"These",
"can... | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/gcloud/service_account.py#L9-L25 |
flo-compbio/genometools | genometools/gcloud/service_account.py | get_compute_credentials | def get_compute_credentials(key):
"""Authenticates a service account for the compute engine.
This uses the `oauth2client.service_account` module. Since the `google`
Python package does not support the compute engine (yet?), we need to make
direct HTTP requests. For that we need authentication tokens. O... | python | def get_compute_credentials(key):
"""Authenticates a service account for the compute engine.
This uses the `oauth2client.service_account` module. Since the `google`
Python package does not support the compute engine (yet?), we need to make
direct HTTP requests. For that we need authentication tokens. O... | [
"def",
"get_compute_credentials",
"(",
"key",
")",
":",
"scopes",
"=",
"[",
"'https://www.googleapis.com/auth/compute'",
"]",
"credentials",
"=",
"ServiceAccountCredentials",
".",
"from_json_keyfile_dict",
"(",
"key",
",",
"scopes",
"=",
"scopes",
")",
"return",
"cred... | Authenticates a service account for the compute engine.
This uses the `oauth2client.service_account` module. Since the `google`
Python package does not support the compute engine (yet?), we need to make
direct HTTP requests. For that we need authentication tokens. Obtaining
these based on the credentia... | [
"Authenticates",
"a",
"service",
"account",
"for",
"the",
"compute",
"engine",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/gcloud/service_account.py#L28-L47 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.hash | def hash(self):
"""Generate a hash value."""
h = hash_pandas_object(self, index=True)
return hashlib.md5(h.values.tobytes()).hexdigest() | python | def hash(self):
"""Generate a hash value."""
h = hash_pandas_object(self, index=True)
return hashlib.md5(h.values.tobytes()).hexdigest() | [
"def",
"hash",
"(",
"self",
")",
":",
"h",
"=",
"hash_pandas_object",
"(",
"self",
",",
"index",
"=",
"True",
")",
"return",
"hashlib",
".",
"md5",
"(",
"h",
".",
"values",
".",
"tobytes",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | Generate a hash value. | [
"Generate",
"a",
"hash",
"value",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L86-L89 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.genes | def genes(self):
"""Return a list of all genes."""
return [ExpGene.from_series(g)
for i, g in self.reset_index().iterrows()] | python | def genes(self):
"""Return a list of all genes."""
return [ExpGene.from_series(g)
for i, g in self.reset_index().iterrows()] | [
"def",
"genes",
"(",
"self",
")",
":",
"return",
"[",
"ExpGene",
".",
"from_series",
"(",
"g",
")",
"for",
"i",
",",
"g",
"in",
"self",
".",
"reset_index",
"(",
")",
".",
"iterrows",
"(",
")",
"]"
] | Return a list of all genes. | [
"Return",
"a",
"list",
"of",
"all",
"genes",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L97-L100 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.read_tsv | def read_tsv(cls, file_or_buffer: str):
"""Read genes from tab-delimited text file."""
df = pd.read_csv(file_or_buffer, sep='\t', index_col=0)
df = df.where(pd.notnull(df), None)
# Note: df.where(..., None) changes all column types to `object`.
return cls(df) | python | def read_tsv(cls, file_or_buffer: str):
"""Read genes from tab-delimited text file."""
df = pd.read_csv(file_or_buffer, sep='\t', index_col=0)
df = df.where(pd.notnull(df), None)
# Note: df.where(..., None) changes all column types to `object`.
return cls(df) | [
"def",
"read_tsv",
"(",
"cls",
",",
"file_or_buffer",
":",
"str",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"file_or_buffer",
",",
"sep",
"=",
"'\\t'",
",",
"index_col",
"=",
"0",
")",
"df",
"=",
"df",
".",
"where",
"(",
"pd",
".",
"notnull"... | Read genes from tab-delimited text file. | [
"Read",
"genes",
"from",
"tab",
"-",
"delimited",
"text",
"file",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L113-L118 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.from_genes | def from_genes(cls, genes: List[ExpGene]):
"""Initialize instance using a list of `ExpGene` objects."""
data = [g.to_dict() for g in genes]
index = [d.pop('ensembl_id') for d in data]
table = cls(data, index=index)
return table | python | def from_genes(cls, genes: List[ExpGene]):
"""Initialize instance using a list of `ExpGene` objects."""
data = [g.to_dict() for g in genes]
index = [d.pop('ensembl_id') for d in data]
table = cls(data, index=index)
return table | [
"def",
"from_genes",
"(",
"cls",
",",
"genes",
":",
"List",
"[",
"ExpGene",
"]",
")",
":",
"data",
"=",
"[",
"g",
".",
"to_dict",
"(",
")",
"for",
"g",
"in",
"genes",
"]",
"index",
"=",
"[",
"d",
".",
"pop",
"(",
"'ensembl_id'",
")",
"for",
"d"... | Initialize instance using a list of `ExpGene` objects. | [
"Initialize",
"instance",
"using",
"a",
"list",
"of",
"ExpGene",
"objects",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L121-L126 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.from_gene_ids | def from_gene_ids(cls, gene_ids: List[str]):
"""Initialize instance from gene IDs."""
genes = [ExpGene(id_) for id_ in gene_ids]
return cls.from_genes(genes) | python | def from_gene_ids(cls, gene_ids: List[str]):
"""Initialize instance from gene IDs."""
genes = [ExpGene(id_) for id_ in gene_ids]
return cls.from_genes(genes) | [
"def",
"from_gene_ids",
"(",
"cls",
",",
"gene_ids",
":",
"List",
"[",
"str",
"]",
")",
":",
"genes",
"=",
"[",
"ExpGene",
"(",
"id_",
")",
"for",
"id_",
"in",
"gene_ids",
"]",
"return",
"cls",
".",
"from_genes",
"(",
"genes",
")"
] | Initialize instance from gene IDs. | [
"Initialize",
"instance",
"from",
"gene",
"IDs",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L129-L132 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.from_gene_ids_and_names | def from_gene_ids_and_names(cls, gene_names: Dict[str, str]):
"""Initialize instance from gene IDs and names."""
genes = [ExpGene(id_, name=name) for id_, name in gene_names.items()]
return cls.from_genes(genes) | python | def from_gene_ids_and_names(cls, gene_names: Dict[str, str]):
"""Initialize instance from gene IDs and names."""
genes = [ExpGene(id_, name=name) for id_, name in gene_names.items()]
return cls.from_genes(genes) | [
"def",
"from_gene_ids_and_names",
"(",
"cls",
",",
"gene_names",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
":",
"genes",
"=",
"[",
"ExpGene",
"(",
"id_",
",",
"name",
"=",
"name",
")",
"for",
"id_",
",",
"name",
"in",
"gene_names",
".",
"items",... | Initialize instance from gene IDs and names. | [
"Initialize",
"instance",
"from",
"gene",
"IDs",
"and",
"names",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L135-L138 |
flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.find_gene | def find_gene(self, name: str):
"""Find gene(s) by name."""
result = [ExpGene.from_series(s)
for i, s in self.loc[self['name'] == name].iterrows()]
return result | python | def find_gene(self, name: str):
"""Find gene(s) by name."""
result = [ExpGene.from_series(s)
for i, s in self.loc[self['name'] == name].iterrows()]
return result | [
"def",
"find_gene",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"result",
"=",
"[",
"ExpGene",
".",
"from_series",
"(",
"s",
")",
"for",
"i",
",",
"s",
"in",
"self",
".",
"loc",
"[",
"self",
"[",
"'name'",
"]",
"==",
"name",
"]",
".",
"iter... | Find gene(s) by name. | [
"Find",
"gene",
"(",
"s",
")",
"by",
"name",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L149-L153 |
flo-compbio/genometools | genometools/expression/visualize/corr_heatmap.py | SampleCorrelationHeatmap.get_figure | def get_figure(self, **kwargs):
"""Get a plotly figure of the heatmap."""
emin = kwargs.pop('emin', -1.0)
emax = kwargs.pop('emax', 1.0)
width = kwargs.pop('width', 800)
height = kwargs.pop('height', 600)
margin_left = kwargs.pop('margin_left', 100)
margin_bottom... | python | def get_figure(self, **kwargs):
"""Get a plotly figure of the heatmap."""
emin = kwargs.pop('emin', -1.0)
emax = kwargs.pop('emax', 1.0)
width = kwargs.pop('width', 800)
height = kwargs.pop('height', 600)
margin_left = kwargs.pop('margin_left', 100)
margin_bottom... | [
"def",
"get_figure",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"emin",
"=",
"kwargs",
".",
"pop",
"(",
"'emin'",
",",
"-",
"1.0",
")",
"emax",
"=",
"kwargs",
".",
"pop",
"(",
"'emax'",
",",
"1.0",
")",
"width",
"=",
"kwargs",
".",
"pop",
... | Get a plotly figure of the heatmap. | [
"Get",
"a",
"plotly",
"figure",
"of",
"the",
"heatmap",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/visualize/corr_heatmap.py#L79-L328 |
ownport/scrapy-dblite | dblite/__init__.py | copy | def copy(src, trg, transform=None):
''' copy items with optional fields transformation
'''
source = open(src[0], src[1])
target = open(trg[0], trg[1], autocommit=1000)
for item in source.get():
item = dict(item)
if '_id' in item:
del item['_id']
if transform:
... | python | def copy(src, trg, transform=None):
''' copy items with optional fields transformation
'''
source = open(src[0], src[1])
target = open(trg[0], trg[1], autocommit=1000)
for item in source.get():
item = dict(item)
if '_id' in item:
del item['_id']
if transform:
... | [
"def",
"copy",
"(",
"src",
",",
"trg",
",",
"transform",
"=",
"None",
")",
":",
"source",
"=",
"open",
"(",
"src",
"[",
"0",
"]",
",",
"src",
"[",
"1",
"]",
")",
"target",
"=",
"open",
"(",
"trg",
"[",
"0",
"]",
",",
"trg",
"[",
"1",
"]",
... | copy items with optional fields transformation | [
"copy",
"items",
"with",
"optional",
"fields",
"transformation"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L34-L51 |
ownport/scrapy-dblite | dblite/__init__.py | _regexp | def _regexp(expr, item):
''' REGEXP function for Sqlite
'''
reg = re.compile(expr)
return reg.search(item) is not None | python | def _regexp(expr, item):
''' REGEXP function for Sqlite
'''
reg = re.compile(expr)
return reg.search(item) is not None | [
"def",
"_regexp",
"(",
"expr",
",",
"item",
")",
":",
"reg",
"=",
"re",
".",
"compile",
"(",
"expr",
")",
"return",
"reg",
".",
"search",
"(",
"item",
")",
"is",
"not",
"None"
] | REGEXP function for Sqlite | [
"REGEXP",
"function",
"for",
"Sqlite"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L54-L58 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._dict_factory | def _dict_factory(cursor, row):
''' factory for sqlite3 to return results as dict
'''
d = {}
for idx, col in enumerate(cursor.description):
if col[0] == 'rowid':
d['_id'] = row[idx]
else:
d[col[0]] = row[idx]
return d | python | def _dict_factory(cursor, row):
''' factory for sqlite3 to return results as dict
'''
d = {}
for idx, col in enumerate(cursor.description):
if col[0] == 'rowid':
d['_id'] = row[idx]
else:
d[col[0]] = row[idx]
return d | [
"def",
"_dict_factory",
"(",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"if",
"col",
"[",
"0",
"]",
"==",
"'rowid'",
":",
"d",
"[",
"'_id'",
"]",
... | factory for sqlite3 to return results as dict | [
"factory",
"for",
"sqlite3",
"to",
"return",
"results",
"as",
"dict"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L121-L130 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.parse_uri | def parse_uri(uri):
''' parse URI
'''
if not uri or uri.find('://') <= 0:
raise RuntimeError('Incorrect URI definition: {}'.format(uri))
backend, rest_uri = uri.split('://')
if backend not in SUPPORTED_BACKENDS:
raise RuntimeError('Unknown backend: {}'.for... | python | def parse_uri(uri):
''' parse URI
'''
if not uri or uri.find('://') <= 0:
raise RuntimeError('Incorrect URI definition: {}'.format(uri))
backend, rest_uri = uri.split('://')
if backend not in SUPPORTED_BACKENDS:
raise RuntimeError('Unknown backend: {}'.for... | [
"def",
"parse_uri",
"(",
"uri",
")",
":",
"if",
"not",
"uri",
"or",
"uri",
".",
"find",
"(",
"'://'",
")",
"<=",
"0",
":",
"raise",
"RuntimeError",
"(",
"'Incorrect URI definition: {}'",
".",
"format",
"(",
"uri",
")",
")",
"backend",
",",
"rest_uri",
... | parse URI | [
"parse",
"URI"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L133-L143 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.fieldnames | def fieldnames(self):
''' return fieldnames
'''
if not self._fields:
if self._item_class is not None:
for m in inspect.getmembers(self._item_class):
if m[0] == 'fields' and isinstance(m[1], dict):
self._fields = m[1]
... | python | def fieldnames(self):
''' return fieldnames
'''
if not self._fields:
if self._item_class is not None:
for m in inspect.getmembers(self._item_class):
if m[0] == 'fields' and isinstance(m[1], dict):
self._fields = m[1]
... | [
"def",
"fieldnames",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_fields",
":",
"if",
"self",
".",
"_item_class",
"is",
"not",
"None",
":",
"for",
"m",
"in",
"inspect",
".",
"getmembers",
"(",
"self",
".",
"_item_class",
")",
":",
"if",
"m",
... | return fieldnames | [
"return",
"fieldnames"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L146-L158 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._create_table | def _create_table(self, table_name):
''' create sqlite's table for storing simple dictionaries
'''
if self.fieldnames:
sql_fields = []
for field in self._fields:
if field != '_id':
if 'dblite' in self._fields[field]:
... | python | def _create_table(self, table_name):
''' create sqlite's table for storing simple dictionaries
'''
if self.fieldnames:
sql_fields = []
for field in self._fields:
if field != '_id':
if 'dblite' in self._fields[field]:
... | [
"def",
"_create_table",
"(",
"self",
",",
"table_name",
")",
":",
"if",
"self",
".",
"fieldnames",
":",
"sql_fields",
"=",
"[",
"]",
"for",
"field",
"in",
"self",
".",
"_fields",
":",
"if",
"field",
"!=",
"'_id'",
":",
"if",
"'dblite'",
"in",
"self",
... | create sqlite's table for storing simple dictionaries | [
"create",
"sqlite",
"s",
"table",
"for",
"storing",
"simple",
"dictionaries"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L160-L176 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._make_item | def _make_item(self, item):
''' make Item class
'''
for field in self._item_class.fields:
if (field in item) and ('dblite_serializer' in self._item_class.fields[field]):
serializer = self._item_class.fields[field]['dblite_serializer']
item[field] = ser... | python | def _make_item(self, item):
''' make Item class
'''
for field in self._item_class.fields:
if (field in item) and ('dblite_serializer' in self._item_class.fields[field]):
serializer = self._item_class.fields[field]['dblite_serializer']
item[field] = ser... | [
"def",
"_make_item",
"(",
"self",
",",
"item",
")",
":",
"for",
"field",
"in",
"self",
".",
"_item_class",
".",
"fields",
":",
"if",
"(",
"field",
"in",
"item",
")",
"and",
"(",
"'dblite_serializer'",
"in",
"self",
".",
"_item_class",
".",
"fields",
"[... | make Item class | [
"make",
"Item",
"class"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L178-L185 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.get | def get(self, criteria=None, offset=None, limit=None):
''' returns items selected by criteria
If the criteria is not defined, get() returns all items.
'''
if criteria is None and limit is None:
return self._get_all()
elif limit is not None and limit == 1:
... | python | def get(self, criteria=None, offset=None, limit=None):
''' returns items selected by criteria
If the criteria is not defined, get() returns all items.
'''
if criteria is None and limit is None:
return self._get_all()
elif limit is not None and limit == 1:
... | [
"def",
"get",
"(",
"self",
",",
"criteria",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"criteria",
"is",
"None",
"and",
"limit",
"is",
"None",
":",
"return",
"self",
".",
"_get_all",
"(",
")",
"elif",
"limit... | returns items selected by criteria
If the criteria is not defined, get() returns all items. | [
"returns",
"items",
"selected",
"by",
"criteria"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L187-L197 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._get_all | def _get_all(self):
''' return all items
'''
rowid = 0
while True:
SQL_SELECT_MANY = 'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;' % self._table
self._cursor.execute(SQL_SELECT_MANY, (rowid, ITEMS_PER_REQUEST))
items = self._cursor.fetchall()
... | python | def _get_all(self):
''' return all items
'''
rowid = 0
while True:
SQL_SELECT_MANY = 'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;' % self._table
self._cursor.execute(SQL_SELECT_MANY, (rowid, ITEMS_PER_REQUEST))
items = self._cursor.fetchall()
... | [
"def",
"_get_all",
"(",
"self",
")",
":",
"rowid",
"=",
"0",
"while",
"True",
":",
"SQL_SELECT_MANY",
"=",
"'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;'",
"%",
"self",
".",
"_table",
"self",
".",
"_cursor",
".",
"execute",
"(",
"SQL_SELECT_MANY",
",",
"(",... | return all items | [
"return",
"all",
"items"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L199-L211 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._get_with_criteria | def _get_with_criteria(self, criteria, offset=None, limit=None):
''' returns items selected by criteria
'''
SQL = SQLBuilder(self._table, criteria).select(offset=offset, limit=limit)
self._cursor.execute(SQL)
for item in self._cursor.fetchall():
yield self._make_item(... | python | def _get_with_criteria(self, criteria, offset=None, limit=None):
''' returns items selected by criteria
'''
SQL = SQLBuilder(self._table, criteria).select(offset=offset, limit=limit)
self._cursor.execute(SQL)
for item in self._cursor.fetchall():
yield self._make_item(... | [
"def",
"_get_with_criteria",
"(",
"self",
",",
"criteria",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"SQL",
"=",
"SQLBuilder",
"(",
"self",
".",
"_table",
",",
"criteria",
")",
".",
"select",
"(",
"offset",
"=",
"offset",
",",
... | returns items selected by criteria | [
"returns",
"items",
"selected",
"by",
"criteria"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L213-L219 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.get_one | def get_one(self, criteria):
''' return one item
'''
try:
items = [item for item in self._get_with_criteria(criteria, limit=1)]
return items[0]
except:
return None | python | def get_one(self, criteria):
''' return one item
'''
try:
items = [item for item in self._get_with_criteria(criteria, limit=1)]
return items[0]
except:
return None | [
"def",
"get_one",
"(",
"self",
",",
"criteria",
")",
":",
"try",
":",
"items",
"=",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"_get_with_criteria",
"(",
"criteria",
",",
"limit",
"=",
"1",
")",
"]",
"return",
"items",
"[",
"0",
"]",
"except",
... | return one item | [
"return",
"one",
"item"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L221-L228 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._do_autocommit | def _do_autocommit(self):
''' perform autocommit
'''
# commit()
self._commit_counter += 1
# autocommit as boolean
if isinstance(self._autocommit, bool) and self._autocommit:
self.commit()
self._commit_counter = 0
# autocommit as counter
... | python | def _do_autocommit(self):
''' perform autocommit
'''
# commit()
self._commit_counter += 1
# autocommit as boolean
if isinstance(self._autocommit, bool) and self._autocommit:
self.commit()
self._commit_counter = 0
# autocommit as counter
... | [
"def",
"_do_autocommit",
"(",
"self",
")",
":",
"# commit()",
"self",
".",
"_commit_counter",
"+=",
"1",
"# autocommit as boolean",
"if",
"isinstance",
"(",
"self",
".",
"_autocommit",
",",
"bool",
")",
"and",
"self",
".",
"_autocommit",
":",
"self",
".",
"c... | perform autocommit | [
"perform",
"autocommit"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L230-L244 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.put | def put(self, item):
''' store item in sqlite database
'''
if isinstance(item, self._item_class):
self._put_one(item)
elif isinstance(item, (list, tuple)):
self._put_many(item)
else:
raise RuntimeError('Unknown item(s) type, %s' % type(item)) | python | def put(self, item):
''' store item in sqlite database
'''
if isinstance(item, self._item_class):
self._put_one(item)
elif isinstance(item, (list, tuple)):
self._put_many(item)
else:
raise RuntimeError('Unknown item(s) type, %s' % type(item)) | [
"def",
"put",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"self",
".",
"_item_class",
")",
":",
"self",
".",
"_put_one",
"(",
"item",
")",
"elif",
"isinstance",
"(",
"item",
",",
"(",
"list",
",",
"tuple",
")",
")",
... | store item in sqlite database | [
"store",
"item",
"in",
"sqlite",
"database"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L246-L254 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._put_one | def _put_one(self, item):
''' store one item in database
'''
# prepare values
values = []
for k, v in item.items():
if k == '_id':
continue
if 'dblite_serializer' in item.fields[k]:
serializer = item.fields[k]['dblite_serial... | python | def _put_one(self, item):
''' store one item in database
'''
# prepare values
values = []
for k, v in item.items():
if k == '_id':
continue
if 'dblite_serializer' in item.fields[k]:
serializer = item.fields[k]['dblite_serial... | [
"def",
"_put_one",
"(",
"self",
",",
"item",
")",
":",
"# prepare values",
"values",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"item",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'_id'",
":",
"continue",
"if",
"'dblite_serializer'",
"in",
"item",... | store one item in database | [
"store",
"one",
"item",
"in",
"database"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L256-L288 |
ownport/scrapy-dblite | dblite/__init__.py | Storage._put_many | def _put_many(self, items):
''' store items in sqlite database
'''
for item in items:
if not isinstance(item, self._item_class):
raise RuntimeError('Items mismatch for %s and %s' % (self._item_class, type(item)))
self._put_one(item) | python | def _put_many(self, items):
''' store items in sqlite database
'''
for item in items:
if not isinstance(item, self._item_class):
raise RuntimeError('Items mismatch for %s and %s' % (self._item_class, type(item)))
self._put_one(item) | [
"def",
"_put_many",
"(",
"self",
",",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"if",
"not",
"isinstance",
"(",
"item",
",",
"self",
".",
"_item_class",
")",
":",
"raise",
"RuntimeError",
"(",
"'Items mismatch for %s and %s'",
"%",
"(",
"self",... | store items in sqlite database | [
"store",
"items",
"in",
"sqlite",
"database"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L290-L296 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.sql | def sql(self, sql, params=()):
''' execute sql request and return items
'''
def _items(items):
for item in items:
yield self._item_class(item)
sql = sql.strip()
try:
self._cursor.execute(sql, params)
except sqlite3.OperationalError... | python | def sql(self, sql, params=()):
''' execute sql request and return items
'''
def _items(items):
for item in items:
yield self._item_class(item)
sql = sql.strip()
try:
self._cursor.execute(sql, params)
except sqlite3.OperationalError... | [
"def",
"sql",
"(",
"self",
",",
"sql",
",",
"params",
"=",
"(",
")",
")",
":",
"def",
"_items",
"(",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"yield",
"self",
".",
"_item_class",
"(",
"item",
")",
"sql",
"=",
"sql",
".",
"strip",
"... | execute sql request and return items | [
"execute",
"sql",
"request",
"and",
"return",
"items"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L298-L316 |
ownport/scrapy-dblite | dblite/__init__.py | Storage.delete | def delete(self, criteria=None, _all=False):
''' delete dictionary(ies) in sqlite database
_all = True - delete all items
'''
if isinstance(criteria, self._item_class):
criteria = {'_id': criteria['_id']}
if criteria is None and not _all:
raise RuntimeEr... | python | def delete(self, criteria=None, _all=False):
''' delete dictionary(ies) in sqlite database
_all = True - delete all items
'''
if isinstance(criteria, self._item_class):
criteria = {'_id': criteria['_id']}
if criteria is None and not _all:
raise RuntimeEr... | [
"def",
"delete",
"(",
"self",
",",
"criteria",
"=",
"None",
",",
"_all",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"criteria",
",",
"self",
".",
"_item_class",
")",
":",
"criteria",
"=",
"{",
"'_id'",
":",
"criteria",
"[",
"'_id'",
"]",
"}",
... | delete dictionary(ies) in sqlite database
_all = True - delete all items | [
"delete",
"dictionary",
"(",
"ies",
")",
"in",
"sqlite",
"database"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L318-L330 |
invenia/Arbiter | arbiter/async.py | run_tasks | def run_tasks(tasks, max_workers=None, use_processes=False):
"""
Run an iterable of tasks.
tasks: The iterable of tasks
max_workers: (optional, None) The maximum number of workers to use.
As of Python 3.5, if None is passed to the thread executor will
default to 5 * the number of proces... | python | def run_tasks(tasks, max_workers=None, use_processes=False):
"""
Run an iterable of tasks.
tasks: The iterable of tasks
max_workers: (optional, None) The maximum number of workers to use.
As of Python 3.5, if None is passed to the thread executor will
default to 5 * the number of proces... | [
"def",
"run_tasks",
"(",
"tasks",
",",
"max_workers",
"=",
"None",
",",
"use_processes",
"=",
"False",
")",
":",
"futures",
"=",
"set",
"(",
")",
"if",
"use_processes",
":",
"get_executor",
"=",
"concurrent",
".",
"futures",
".",
"ProcessPoolExecutor",
"else... | Run an iterable of tasks.
tasks: The iterable of tasks
max_workers: (optional, None) The maximum number of workers to use.
As of Python 3.5, if None is passed to the thread executor will
default to 5 * the number of processors and the process executor
will default to the number of proce... | [
"Run",
"an",
"iterable",
"of",
"tasks",
"."
] | train | https://github.com/invenia/Arbiter/blob/51008393ae8797da85bcd67807259a157f941dfd/arbiter/async.py#L12-L70 |
flo-compbio/genometools | genometools/gcloud/operations.py | wait_for_zone_op | def wait_for_zone_op(access_token, project, zone, name, interval=1.0):
"""Wait until a zone operation is finished.
TODO: docstring"""
assert isinstance(interval, (int, float))
assert interval >= 0.1
status = 'RUNNING'
progress = 0
LOGGER.info('Waiting for zone operation "%s" to finis... | python | def wait_for_zone_op(access_token, project, zone, name, interval=1.0):
"""Wait until a zone operation is finished.
TODO: docstring"""
assert isinstance(interval, (int, float))
assert interval >= 0.1
status = 'RUNNING'
progress = 0
LOGGER.info('Waiting for zone operation "%s" to finis... | [
"def",
"wait_for_zone_op",
"(",
"access_token",
",",
"project",
",",
"zone",
",",
"name",
",",
"interval",
"=",
"1.0",
")",
":",
"assert",
"isinstance",
"(",
"interval",
",",
"(",
"int",
",",
"float",
")",
")",
"assert",
"interval",
">=",
"0.1",
"status"... | Wait until a zone operation is finished.
TODO: docstring | [
"Wait",
"until",
"a",
"zone",
"operation",
"is",
"finished",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/gcloud/operations.py#L12-L41 |
acorg/dark-matter | dark/local_align.py | LocalAlignment._initialise | def _initialise(self):
"""
Initialises table with dictionary.
"""
d = {'score': 0, 'pointer': None, 'ins': 0, 'del': 0}
cols = len(self.seq1Seq) + 1
rows = len(self.seq2Seq) + 1
# Note that this puts a ref to the same dict (d) into each cell of
# the table... | python | def _initialise(self):
"""
Initialises table with dictionary.
"""
d = {'score': 0, 'pointer': None, 'ins': 0, 'del': 0}
cols = len(self.seq1Seq) + 1
rows = len(self.seq2Seq) + 1
# Note that this puts a ref to the same dict (d) into each cell of
# the table... | [
"def",
"_initialise",
"(",
"self",
")",
":",
"d",
"=",
"{",
"'score'",
":",
"0",
",",
"'pointer'",
":",
"None",
",",
"'ins'",
":",
"0",
",",
"'del'",
":",
"0",
"}",
"cols",
"=",
"len",
"(",
"self",
".",
"seq1Seq",
")",
"+",
"1",
"rows",
"=",
... | Initialises table with dictionary. | [
"Initialises",
"table",
"with",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L57-L69 |
acorg/dark-matter | dark/local_align.py | LocalAlignment._fillAndTraceback | def _fillAndTraceback(self, table):
"""
Perform Local Alignment according to Smith-Waterman Algorithm.
Fills the table and then traces back from the highest score.
NB left = deletion and up = insertion wrt seq1
"""
# Fill
max_score = 0
max_row = 0
... | python | def _fillAndTraceback(self, table):
"""
Perform Local Alignment according to Smith-Waterman Algorithm.
Fills the table and then traces back from the highest score.
NB left = deletion and up = insertion wrt seq1
"""
# Fill
max_score = 0
max_row = 0
... | [
"def",
"_fillAndTraceback",
"(",
"self",
",",
"table",
")",
":",
"# Fill",
"max_score",
"=",
"0",
"max_row",
"=",
"0",
"max_col",
"=",
"0",
"for",
"row",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
".",
"seq2Seq",
")",
"+",
"1",
")",
":",
"... | Perform Local Alignment according to Smith-Waterman Algorithm.
Fills the table and then traces back from the highest score.
NB left = deletion and up = insertion wrt seq1 | [
"Perform",
"Local",
"Alignment",
"according",
"to",
"Smith",
"-",
"Waterman",
"Algorithm",
".",
"Fills",
"the",
"table",
"and",
"then",
"traces",
"back",
"from",
"the",
"highest",
"score",
".",
"NB",
"left",
"=",
"deletion",
"and",
"up",
"=",
"insertion",
... | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L71-L199 |
acorg/dark-matter | dark/local_align.py | LocalAlignment._cigarString | def _cigarString(self, output):
"""
Return a cigar string of aligned sequences.
@param output: a C{tup} of strings (align1, align, align2)
@return: a C{str} containing the cigar string. Eg with input:
'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3=
"""
cigar = [... | python | def _cigarString(self, output):
"""
Return a cigar string of aligned sequences.
@param output: a C{tup} of strings (align1, align, align2)
@return: a C{str} containing the cigar string. Eg with input:
'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3=
"""
cigar = [... | [
"def",
"_cigarString",
"(",
"self",
",",
"output",
")",
":",
"cigar",
"=",
"[",
"]",
"count",
"=",
"0",
"align1",
"=",
"output",
"[",
"0",
"]",
"align2",
"=",
"output",
"[",
"2",
"]",
"for",
"nt1",
",",
"nt2",
"in",
"zip",
"(",
"align1",
",",
"... | Return a cigar string of aligned sequences.
@param output: a C{tup} of strings (align1, align, align2)
@return: a C{str} containing the cigar string. Eg with input:
'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3= | [
"Return",
"a",
"cigar",
"string",
"of",
"aligned",
"sequences",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L201-L242 |
acorg/dark-matter | dark/local_align.py | LocalAlignment._alignmentToStr | def _alignmentToStr(self, result):
"""
Make a textual representation of an alignment result.
@param result: A C{dict}, as returned by C{self.createAlignment}.
@return: A C{str} desription of a result. For every three lines the
first and third contain the input sequences, pos... | python | def _alignmentToStr(self, result):
"""
Make a textual representation of an alignment result.
@param result: A C{dict}, as returned by C{self.createAlignment}.
@return: A C{str} desription of a result. For every three lines the
first and third contain the input sequences, pos... | [
"def",
"_alignmentToStr",
"(",
"self",
",",
"result",
")",
":",
"if",
"result",
"is",
"None",
":",
"return",
"(",
"'\\nNo alignment between %s and %s\\n'",
"%",
"(",
"self",
".",
"seq1ID",
",",
"self",
".",
"seq2ID",
")",
")",
"else",
":",
"header",
"=",
... | Make a textual representation of an alignment result.
@param result: A C{dict}, as returned by C{self.createAlignment}.
@return: A C{str} desription of a result. For every three lines the
first and third contain the input sequences, possibly padded
with '-'. The second contains ... | [
"Make",
"a",
"textual",
"representation",
"of",
"an",
"alignment",
"result",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L293-L326 |
acorg/dark-matter | dark/local_align.py | LocalAlignment.createAlignment | def createAlignment(self, resultFormat=dict):
"""
Run the alignment algorithm.
@param resultFormat: Either C{dict} or C{str}, giving the desired
result format.
@return: If C{resultFormat} is C{dict}, a C{dict} containing
information about the match (or C{None}) i... | python | def createAlignment(self, resultFormat=dict):
"""
Run the alignment algorithm.
@param resultFormat: Either C{dict} or C{str}, giving the desired
result format.
@return: If C{resultFormat} is C{dict}, a C{dict} containing
information about the match (or C{None}) i... | [
"def",
"createAlignment",
"(",
"self",
",",
"resultFormat",
"=",
"dict",
")",
":",
"table",
"=",
"self",
".",
"_initialise",
"(",
")",
"alignment",
"=",
"self",
".",
"_fillAndTraceback",
"(",
"table",
")",
"output",
"=",
"alignment",
"[",
"0",
"]",
"if",... | Run the alignment algorithm.
@param resultFormat: Either C{dict} or C{str}, giving the desired
result format.
@return: If C{resultFormat} is C{dict}, a C{dict} containing
information about the match (or C{None}) if there is no match.
If C{resultFormat} is C{str}, a C... | [
"Run",
"the",
"alignment",
"algorithm",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L328-L356 |
ownport/scrapy-dblite | dblite/query.py | SQLBuilder.select | def select(self, fields=['rowid', '*'], offset=None, limit=None):
''' return SELECT SQL
'''
# base SQL
SQL = 'SELECT %s FROM %s' % (','.join(fields), self._table)
# selectors
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
... | python | def select(self, fields=['rowid', '*'], offset=None, limit=None):
''' return SELECT SQL
'''
# base SQL
SQL = 'SELECT %s FROM %s' % (','.join(fields), self._table)
# selectors
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
... | [
"def",
"select",
"(",
"self",
",",
"fields",
"=",
"[",
"'rowid'",
",",
"'*'",
"]",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"# base SQL",
"SQL",
"=",
"'SELECT %s FROM %s'",
"%",
"(",
"','",
".",
"join",
"(",
"fields",
")",
"... | return SELECT SQL | [
"return",
"SELECT",
"SQL"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L37-L59 |
ownport/scrapy-dblite | dblite/query.py | SQLBuilder.delete | def delete(self):
''' return DELETE SQL
'''
SQL = 'DELETE FROM %s' % self._table
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
return SQL | python | def delete(self):
''' return DELETE SQL
'''
SQL = 'DELETE FROM %s' % self._table
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
return SQL | [
"def",
"delete",
"(",
"self",
")",
":",
"SQL",
"=",
"'DELETE FROM %s'",
"%",
"self",
".",
"_table",
"if",
"self",
".",
"_selectors",
":",
"SQL",
"=",
"' '",
".",
"join",
"(",
"[",
"SQL",
",",
"'WHERE'",
",",
"self",
".",
"_selectors",
"]",
")",
"."... | return DELETE SQL | [
"return",
"DELETE",
"SQL"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L61-L68 |
ownport/scrapy-dblite | dblite/query.py | SQLBuilder._parse | def _parse(self, params):
''' parse parameters and return SQL
'''
if not isinstance(params, dict):
return None, None
if len(params) == 0:
return None, None
selectors = list()
modifiers = list()
for k in params.keys():
... | python | def _parse(self, params):
''' parse parameters and return SQL
'''
if not isinstance(params, dict):
return None, None
if len(params) == 0:
return None, None
selectors = list()
modifiers = list()
for k in params.keys():
... | [
"def",
"_parse",
"(",
"self",
",",
"params",
")",
":",
"if",
"not",
"isinstance",
"(",
"params",
",",
"dict",
")",
":",
"return",
"None",
",",
"None",
"if",
"len",
"(",
"params",
")",
"==",
"0",
":",
"return",
"None",
",",
"None",
"selectors",
"=",... | parse parameters and return SQL | [
"parse",
"parameters",
"and",
"return",
"SQL"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L70-L98 |
ownport/scrapy-dblite | dblite/query.py | SQLBuilder._logical | def _logical(self, operator, params):
'''
$and: joins query clauses with a logical AND returns all items
that match the conditions of both clauses
$or: joins query clauses with a logical OR returns all items
that match the conditions of either clause.
... | python | def _logical(self, operator, params):
'''
$and: joins query clauses with a logical AND returns all items
that match the conditions of both clauses
$or: joins query clauses with a logical OR returns all items
that match the conditions of either clause.
... | [
"def",
"_logical",
"(",
"self",
",",
"operator",
",",
"params",
")",
":",
"result",
"=",
"list",
"(",
")",
"if",
"isinstance",
"(",
"params",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"params",
".",
"items",
"(",
")",
":",
"selectors",
"... | $and: joins query clauses with a logical AND returns all items
that match the conditions of both clauses
$or: joins query clauses with a logical OR returns all items
that match the conditions of either clause. | [
"$and",
":",
"joins",
"query",
"clauses",
"with",
"a",
"logical",
"AND",
"returns",
"all",
"items",
"that",
"match",
"the",
"conditions",
"of",
"both",
"clauses",
"$or",
":",
"joins",
"query",
"clauses",
"with",
"a",
"logical",
"OR",
"returns",
"all",
"ite... | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L100-L125 |
ownport/scrapy-dblite | dblite/query.py | SQLBuilder._modifier | def _modifier(self, operator, params):
'''
$orderby: sorts the results of a query in ascending (1) or descending (-1) order.
'''
if operator == '$orderby':
order_types = {-1: 'DESC', 1: 'ASC'}
if not isinstance(params, dict):
raise RuntimeError... | python | def _modifier(self, operator, params):
'''
$orderby: sorts the results of a query in ascending (1) or descending (-1) order.
'''
if operator == '$orderby':
order_types = {-1: 'DESC', 1: 'ASC'}
if not isinstance(params, dict):
raise RuntimeError... | [
"def",
"_modifier",
"(",
"self",
",",
"operator",
",",
"params",
")",
":",
"if",
"operator",
"==",
"'$orderby'",
":",
"order_types",
"=",
"{",
"-",
"1",
":",
"'DESC'",
",",
"1",
":",
"'ASC'",
"}",
"if",
"not",
"isinstance",
"(",
"params",
",",
"dict"... | $orderby: sorts the results of a query in ascending (1) or descending (-1) order. | [
"$orderby",
":",
"sorts",
"the",
"results",
"of",
"a",
"query",
"in",
"ascending",
"(",
"1",
")",
"or",
"descending",
"(",
"-",
"1",
")",
"order",
"."
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L127-L138 |
ownport/scrapy-dblite | dblite/query.py | SQLBuilder._value_wrapper | def _value_wrapper(self, value):
''' wrapper for values
'''
if isinstance(value, (int, float,)):
return '=%s' % value
elif isinstance(value, (str, unicode)):
value = value.strip()
# LIKE
if RE_LIKE.match(value):
return ' LI... | python | def _value_wrapper(self, value):
''' wrapper for values
'''
if isinstance(value, (int, float,)):
return '=%s' % value
elif isinstance(value, (str, unicode)):
value = value.strip()
# LIKE
if RE_LIKE.match(value):
return ' LI... | [
"def",
"_value_wrapper",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
",",
")",
")",
":",
"return",
"'=%s'",
"%",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"str",
",",
"unicode",
... | wrapper for values | [
"wrapper",
"for",
"values"
] | train | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L140-L156 |
openfisca/openfisca-web-api | openfisca_web_api/urls.py | make_router | def make_router(*routings):
"""Return a WSGI application that dispatches requests to controllers """
routes = []
for routing in routings:
methods, regex, app = routing[:3]
if isinstance(methods, basestring):
methods = (methods,)
vars = routing[3] if len(routing) >= 4 else... | python | def make_router(*routings):
"""Return a WSGI application that dispatches requests to controllers """
routes = []
for routing in routings:
methods, regex, app = routing[:3]
if isinstance(methods, basestring):
methods = (methods,)
vars = routing[3] if len(routing) >= 4 else... | [
"def",
"make_router",
"(",
"*",
"routings",
")",
":",
"routes",
"=",
"[",
"]",
"for",
"routing",
"in",
"routings",
":",
"methods",
",",
"regex",
",",
"app",
"=",
"routing",
"[",
":",
"3",
"]",
"if",
"isinstance",
"(",
"methods",
",",
"basestring",
")... | Return a WSGI application that dispatches requests to controllers | [
"Return",
"a",
"WSGI",
"application",
"that",
"dispatches",
"requests",
"to",
"controllers"
] | train | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/urls.py#L63-L129 |
cemerick/nrepl-python-client | nrepl/__init__.py | connect | def connect(uri):
"""
Connects to an nREPL endpoint identified by the given URL/URI. Valid
examples include:
nrepl://192.168.0.12:7889
telnet://localhost:5000
http://your-app-name.heroku.com/repl
This fn delegates to another looked up in that dispatches on the scheme of
the URI... | python | def connect(uri):
"""
Connects to an nREPL endpoint identified by the given URL/URI. Valid
examples include:
nrepl://192.168.0.12:7889
telnet://localhost:5000
http://your-app-name.heroku.com/repl
This fn delegates to another looked up in that dispatches on the scheme of
the URI... | [
"def",
"connect",
"(",
"uri",
")",
":",
"#",
"uri",
"=",
"uri",
"if",
"isinstance",
"(",
"uri",
",",
"ParseResult",
")",
"else",
"urlparse",
"(",
"uri",
")",
"if",
"not",
"uri",
".",
"scheme",
":",
"raise",
"ValueError",
"(",
"\"uri has no scheme: \"",
... | Connects to an nREPL endpoint identified by the given URL/URI. Valid
examples include:
nrepl://192.168.0.12:7889
telnet://localhost:5000
http://your-app-name.heroku.com/repl
This fn delegates to another looked up in that dispatches on the scheme of
the URI provided (which can be a stri... | [
"Connects",
"to",
"an",
"nREPL",
"endpoint",
"identified",
"by",
"the",
"given",
"URL",
"/",
"URI",
".",
"Valid",
"examples",
"include",
":"
] | train | https://github.com/cemerick/nrepl-python-client/blob/7f0fa7bad73e52e2359b49bc5b719bc19590edf9/nrepl/__init__.py#L106-L129 |
cemerick/nrepl-python-client | nrepl/__init__.py | WatchableConnection.watch | def watch(self, key, criteria, callback):
"""
Registers a new watch under [key] (which can be used with `unwatch()`
to remove the watch) that filters messages using [criteria] (may be a
predicate or a 'criteria dict' [see the README for more info there]).
Matching messages are pa... | python | def watch(self, key, criteria, callback):
"""
Registers a new watch under [key] (which can be used with `unwatch()`
to remove the watch) that filters messages using [criteria] (may be a
predicate or a 'criteria dict' [see the README for more info there]).
Matching messages are pa... | [
"def",
"watch",
"(",
"self",
",",
"key",
",",
"criteria",
",",
"callback",
")",
":",
"if",
"hasattr",
"(",
"criteria",
",",
"'__call__'",
")",
":",
"pred",
"=",
"criteria",
"else",
":",
"pred",
"=",
"lambda",
"incoming",
":",
"_match_criteria",
"(",
"c... | Registers a new watch under [key] (which can be used with `unwatch()`
to remove the watch) that filters messages using [criteria] (may be a
predicate or a 'criteria dict' [see the README for more info there]).
Matching messages are passed to [callback], which must accept three
arguments:... | [
"Registers",
"a",
"new",
"watch",
"under",
"[",
"key",
"]",
"(",
"which",
"can",
"be",
"used",
"with",
"unwatch",
"()",
"to",
"remove",
"the",
"watch",
")",
"that",
"filters",
"messages",
"using",
"[",
"criteria",
"]",
"(",
"may",
"be",
"a",
"predicate... | train | https://github.com/cemerick/nrepl-python-client/blob/7f0fa7bad73e52e2359b49bc5b719bc19590edf9/nrepl/__init__.py#L85-L100 |
nkavaldj/myhdl_lib | myhdl_lib/fifo_async.py | fifo_async | def fifo_async(wrst, rrst, wclk, rclk, wfull, we, wdata, rempty, re, rdata, depth=None, width=None):
''' Asynchronous FIFO
Implements the design described in:
Clifford E. Cummings, "Simulation and Synthesis Techniques for Asynchronous FIFO Design," SNUG 2002 (Synopsys
Users Group Co... | python | def fifo_async(wrst, rrst, wclk, rclk, wfull, we, wdata, rempty, re, rdata, depth=None, width=None):
''' Asynchronous FIFO
Implements the design described in:
Clifford E. Cummings, "Simulation and Synthesis Techniques for Asynchronous FIFO Design," SNUG 2002 (Synopsys
Users Group Co... | [
"def",
"fifo_async",
"(",
"wrst",
",",
"rrst",
",",
"wclk",
",",
"rclk",
",",
"wfull",
",",
"we",
",",
"wdata",
",",
"rempty",
",",
"re",
",",
"rdata",
",",
"depth",
"=",
"None",
",",
"width",
"=",
"None",
")",
":",
"if",
"(",
"width",
"==",
"N... | Asynchronous FIFO
Implements the design described in:
Clifford E. Cummings, "Simulation and Synthesis Techniques for Asynchronous FIFO Design," SNUG 2002 (Synopsys
Users Group Conference, San Jose, CA, 2002) User Papers, March 2002, Section TB2, 2nd paper. Also available at
... | [
"Asynchronous",
"FIFO"
] | train | https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/myhdl_lib/fifo_async.py#L5-L166 |
openfisca/openfisca-web-api | openfisca_web_api/wsgihelpers.py | respond_json | def respond_json(ctx, data, code = None, headers = [], json_dumps_default = None, jsonp = None):
"""Return a JSON response.
This function is optimized for JSON following
`Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle
any JSON except f... | python | def respond_json(ctx, data, code = None, headers = [], json_dumps_default = None, jsonp = None):
"""Return a JSON response.
This function is optimized for JSON following
`Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle
any JSON except f... | [
"def",
"respond_json",
"(",
"ctx",
",",
"data",
",",
"code",
"=",
"None",
",",
"headers",
"=",
"[",
"]",
",",
"json_dumps_default",
"=",
"None",
",",
"jsonp",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"collections",
".",
"Mapping",
... | Return a JSON response.
This function is optimized for JSON following
`Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle
any JSON except for HTTP errors. | [
"Return",
"a",
"JSON",
"response",
"."
] | train | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/wsgihelpers.py#L69-L128 |
kyegupov/py-unrar2 | UnRAR2/unix.py | call_unrar | def call_unrar(params):
"""Calls rar/unrar command line executable, returns stdout pipe"""
global rar_executable_cached
if rar_executable_cached is None:
for command in ('unrar', 'rar'):
try:
subprocess.Popen([command], stdout=subprocess.PIPE)
rar_executab... | python | def call_unrar(params):
"""Calls rar/unrar command line executable, returns stdout pipe"""
global rar_executable_cached
if rar_executable_cached is None:
for command in ('unrar', 'rar'):
try:
subprocess.Popen([command], stdout=subprocess.PIPE)
rar_executab... | [
"def",
"call_unrar",
"(",
"params",
")",
":",
"global",
"rar_executable_cached",
"if",
"rar_executable_cached",
"is",
"None",
":",
"for",
"command",
"in",
"(",
"'unrar'",
",",
"'rar'",
")",
":",
"try",
":",
"subprocess",
".",
"Popen",
"(",
"[",
"command",
... | Calls rar/unrar command line executable, returns stdout pipe | [
"Calls",
"rar",
"/",
"unrar",
"command",
"line",
"executable",
"returns",
"stdout",
"pipe"
] | train | https://github.com/kyegupov/py-unrar2/blob/186a4c1feb9ef3d96a2331f8fb3ebf88036e15e5/UnRAR2/unix.py#L57-L78 |
biocommons/bioutils | src/bioutils/assemblies.py | get_assembly_names | def get_assembly_names():
"""return list of available assemblies
>>> assy_names = get_assembly_names()
>>> 'GRCh37.p13' in assy_names
True
"""
return [
n.replace(".json.gz", "")
for n in pkg_resources.resource_listdir(__name__, _assy_dir)
if n.endswith(".json.gz")... | python | def get_assembly_names():
"""return list of available assemblies
>>> assy_names = get_assembly_names()
>>> 'GRCh37.p13' in assy_names
True
"""
return [
n.replace(".json.gz", "")
for n in pkg_resources.resource_listdir(__name__, _assy_dir)
if n.endswith(".json.gz")... | [
"def",
"get_assembly_names",
"(",
")",
":",
"return",
"[",
"n",
".",
"replace",
"(",
"\".json.gz\"",
",",
"\"\"",
")",
"for",
"n",
"in",
"pkg_resources",
".",
"resource_listdir",
"(",
"__name__",
",",
"_assy_dir",
")",
"if",
"n",
".",
"endswith",
"(",
"\... | return list of available assemblies
>>> assy_names = get_assembly_names()
>>> 'GRCh37.p13' in assy_names
True | [
"return",
"list",
"of",
"available",
"assemblies",
">>>",
"assy_names",
"=",
"get_assembly_names",
"()"
] | train | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L34-L48 |
biocommons/bioutils | src/bioutils/assemblies.py | get_assembly | def get_assembly(name):
"""read a single assembly by name, returning a dictionary of assembly data
>>> assy = get_assembly('GRCh37.p13')
>>> assy['name']
'GRCh37.p13'
>>> assy['description']
'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)'
>>> assy['refseq_ac']
... | python | def get_assembly(name):
"""read a single assembly by name, returning a dictionary of assembly data
>>> assy = get_assembly('GRCh37.p13')
>>> assy['name']
'GRCh37.p13'
>>> assy['description']
'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)'
>>> assy['refseq_ac']
... | [
"def",
"get_assembly",
"(",
"name",
")",
":",
"fn",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"__name__",
",",
"_assy_path_fmt",
".",
"format",
"(",
"name",
"=",
"name",
")",
")",
"return",
"json",
".",
"load",
"(",
"gzip",
".",
"open",
"(",
... | read a single assembly by name, returning a dictionary of assembly data
>>> assy = get_assembly('GRCh37.p13')
>>> assy['name']
'GRCh37.p13'
>>> assy['description']
'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)'
>>> assy['refseq_ac']
'GCF_000001405.25'
>>>... | [
"read",
"a",
"single",
"assembly",
"by",
"name",
"returning",
"a",
"dictionary",
"of",
"assembly",
"data"
] | train | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L51-L85 |
biocommons/bioutils | src/bioutils/assemblies.py | get_assemblies | def get_assemblies(names=[]):
"""read specified assemblies, or all if none specified, returning a
dictionary of assembly-name: assembly. See get_assembly()
function for the structure of assembly data.
>>> assemblies = get_assemblies(names=['GRCh37.p13'])
>>> assy = assemblies['GRCh37.p13']
>>... | python | def get_assemblies(names=[]):
"""read specified assemblies, or all if none specified, returning a
dictionary of assembly-name: assembly. See get_assembly()
function for the structure of assembly data.
>>> assemblies = get_assemblies(names=['GRCh37.p13'])
>>> assy = assemblies['GRCh37.p13']
>>... | [
"def",
"get_assemblies",
"(",
"names",
"=",
"[",
"]",
")",
":",
"if",
"names",
"==",
"[",
"]",
":",
"names",
"=",
"get_assembly_names",
"(",
")",
"return",
"{",
"a",
"[",
"'name'",
"]",
":",
"a",
"for",
"a",
"in",
"(",
"get_assembly",
"(",
"n",
"... | read specified assemblies, or all if none specified, returning a
dictionary of assembly-name: assembly. See get_assembly()
function for the structure of assembly data.
>>> assemblies = get_assemblies(names=['GRCh37.p13'])
>>> assy = assemblies['GRCh37.p13']
>>> assemblies = get_assemblies()
>... | [
"read",
"specified",
"assemblies",
"or",
"all",
"if",
"none",
"specified",
"returning",
"a",
"dictionary",
"of",
"assembly",
"-",
"name",
":",
"assembly",
".",
"See",
"get_assembly",
"()",
"function",
"for",
"the",
"structure",
"of",
"assembly",
"data",
"."
] | train | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L88-L104 |
biocommons/bioutils | src/bioutils/assemblies.py | make_name_ac_map | def make_name_ac_map(assy_name, primary_only=False):
"""make map from sequence name to accession for given assembly name
>>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5')
>>> grch38p5_name_ac_map['1']
'NC_000001.11'
"""
return {
s['name']: s['refseq_ac']
for s in get_ass... | python | def make_name_ac_map(assy_name, primary_only=False):
"""make map from sequence name to accession for given assembly name
>>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5')
>>> grch38p5_name_ac_map['1']
'NC_000001.11'
"""
return {
s['name']: s['refseq_ac']
for s in get_ass... | [
"def",
"make_name_ac_map",
"(",
"assy_name",
",",
"primary_only",
"=",
"False",
")",
":",
"return",
"{",
"s",
"[",
"'name'",
"]",
":",
"s",
"[",
"'refseq_ac'",
"]",
"for",
"s",
"in",
"get_assembly",
"(",
"assy_name",
")",
"[",
"'sequences'",
"]",
"if",
... | make map from sequence name to accession for given assembly name
>>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5')
>>> grch38p5_name_ac_map['1']
'NC_000001.11' | [
"make",
"map",
"from",
"sequence",
"name",
"to",
"accession",
"for",
"given",
"assembly",
"name"
] | train | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L107-L119 |
biocommons/bioutils | src/bioutils/assemblies.py | make_ac_name_map | def make_ac_name_map(assy_name, primary_only=False):
"""make map from accession (str) to sequence name (str) for given assembly name
>>> grch38p5_ac_name_map = make_ac_name_map('GRCh38.p5')
>>> grch38p5_ac_name_map['NC_000001.11']
'1'
"""
return {
s['refseq_ac']: s['name']
for... | python | def make_ac_name_map(assy_name, primary_only=False):
"""make map from accession (str) to sequence name (str) for given assembly name
>>> grch38p5_ac_name_map = make_ac_name_map('GRCh38.p5')
>>> grch38p5_ac_name_map['NC_000001.11']
'1'
"""
return {
s['refseq_ac']: s['name']
for... | [
"def",
"make_ac_name_map",
"(",
"assy_name",
",",
"primary_only",
"=",
"False",
")",
":",
"return",
"{",
"s",
"[",
"'refseq_ac'",
"]",
":",
"s",
"[",
"'name'",
"]",
"for",
"s",
"in",
"get_assembly",
"(",
"assy_name",
")",
"[",
"'sequences'",
"]",
"if",
... | make map from accession (str) to sequence name (str) for given assembly name
>>> grch38p5_ac_name_map = make_ac_name_map('GRCh38.p5')
>>> grch38p5_ac_name_map['NC_000001.11']
'1' | [
"make",
"map",
"from",
"accession",
"(",
"str",
")",
"to",
"sequence",
"name",
"(",
"str",
")",
"for",
"given",
"assembly",
"name"
] | train | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L122-L135 |
flo-compbio/genometools | genometools/ensembl/cli/extract_protein_coding_exon_annotations.py | main | def main(args=None):
"""Extract all exon annotations of protein-coding genes."""
if args is None:
parser = get_argument_parser()
args = parser.parse_args()
input_file = args.annotation_file
output_file = args.output_file
species = args.species
chrom_pat = args.chromosome_patter... | python | def main(args=None):
"""Extract all exon annotations of protein-coding genes."""
if args is None:
parser = get_argument_parser()
args = parser.parse_args()
input_file = args.annotation_file
output_file = args.output_file
species = args.species
chrom_pat = args.chromosome_patter... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"parser",
"=",
"get_argument_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"input_file",
"=",
"args",
".",
"annotation_file",
"output_file",
"=",... | Extract all exon annotations of protein-coding genes. | [
"Extract",
"all",
"exon",
"annotations",
"of",
"protein",
"-",
"coding",
"genes",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ensembl/cli/extract_protein_coding_exon_annotations.py#L53-L131 |
acorg/dark-matter | dark/titles.py | titleCounts | def titleCounts(readsAlignments):
"""
Count the number of times each title in a readsAlignments instance is
matched. This is useful for rapidly discovering what titles were matched
and with what frequency.
@param readsAlignments: A L{dark.alignments.ReadsAlignments} instance.
@return: A C{dict}... | python | def titleCounts(readsAlignments):
"""
Count the number of times each title in a readsAlignments instance is
matched. This is useful for rapidly discovering what titles were matched
and with what frequency.
@param readsAlignments: A L{dark.alignments.ReadsAlignments} instance.
@return: A C{dict}... | [
"def",
"titleCounts",
"(",
"readsAlignments",
")",
":",
"titles",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"readAlignments",
"in",
"readsAlignments",
":",
"for",
"alignment",
"in",
"readAlignments",
":",
"titles",
"[",
"alignment",
".",
"subjectTitle",
"]",
... | Count the number of times each title in a readsAlignments instance is
matched. This is useful for rapidly discovering what titles were matched
and with what frequency.
@param readsAlignments: A L{dark.alignments.ReadsAlignments} instance.
@return: A C{dict} whose keys are titles and whose values are th... | [
"Count",
"the",
"number",
"of",
"times",
"each",
"title",
"in",
"a",
"readsAlignments",
"instance",
"is",
"matched",
".",
"This",
"is",
"useful",
"for",
"rapidly",
"discovering",
"what",
"titles",
"were",
"matched",
"and",
"with",
"what",
"frequency",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L8-L23 |
acorg/dark-matter | dark/titles.py | TitleAlignment.toDict | def toDict(self):
"""
Get information about a title alignment as a dictionary.
@return: A C{dict} representation of the title aligment.
"""
return {
'hsps': [hsp.toDict() for hsp in self.hsps],
'read': self.read.toDict(),
} | python | def toDict(self):
"""
Get information about a title alignment as a dictionary.
@return: A C{dict} representation of the title aligment.
"""
return {
'hsps': [hsp.toDict() for hsp in self.hsps],
'read': self.read.toDict(),
} | [
"def",
"toDict",
"(",
"self",
")",
":",
"return",
"{",
"'hsps'",
":",
"[",
"hsp",
".",
"toDict",
"(",
")",
"for",
"hsp",
"in",
"self",
".",
"hsps",
"]",
",",
"'read'",
":",
"self",
".",
"read",
".",
"toDict",
"(",
")",
",",
"}"
] | Get information about a title alignment as a dictionary.
@return: A C{dict} representation of the title aligment. | [
"Get",
"information",
"about",
"a",
"title",
"alignment",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L38-L47 |
acorg/dark-matter | dark/titles.py | TitleAlignments.hasScoreBetterThan | def hasScoreBetterThan(self, score):
"""
Is there an HSP with a score better than a given value?
@return: A C{bool}, C{True} if there is at least one HSP in the
alignments for this title with a score better than C{score}.
"""
# Note: Do not assume that HSPs in an alignme... | python | def hasScoreBetterThan(self, score):
"""
Is there an HSP with a score better than a given value?
@return: A C{bool}, C{True} if there is at least one HSP in the
alignments for this title with a score better than C{score}.
"""
# Note: Do not assume that HSPs in an alignme... | [
"def",
"hasScoreBetterThan",
"(",
"self",
",",
"score",
")",
":",
"# Note: Do not assume that HSPs in an alignment are sorted in",
"# decreasing order (as they are in BLAST output). If we could",
"# assume that, we could just check the first HSP in each alignment.",
"for",
"hsp",
"in",
"... | Is there an HSP with a score better than a given value?
@return: A C{bool}, C{True} if there is at least one HSP in the
alignments for this title with a score better than C{score}. | [
"Is",
"there",
"an",
"HSP",
"with",
"a",
"score",
"better",
"than",
"a",
"given",
"value?"
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L133-L146 |
acorg/dark-matter | dark/titles.py | TitleAlignments.coverage | def coverage(self):
"""
Get the fraction of this title sequence that is matched by its reads.
@return: The C{float} fraction of the title sequence matched by its
reads.
"""
intervals = ReadIntervals(self.subjectLength)
for hsp in self.hsps():
inte... | python | def coverage(self):
"""
Get the fraction of this title sequence that is matched by its reads.
@return: The C{float} fraction of the title sequence matched by its
reads.
"""
intervals = ReadIntervals(self.subjectLength)
for hsp in self.hsps():
inte... | [
"def",
"coverage",
"(",
"self",
")",
":",
"intervals",
"=",
"ReadIntervals",
"(",
"self",
".",
"subjectLength",
")",
"for",
"hsp",
"in",
"self",
".",
"hsps",
"(",
")",
":",
"intervals",
".",
"add",
"(",
"hsp",
".",
"subjectStart",
",",
"hsp",
".",
"s... | Get the fraction of this title sequence that is matched by its reads.
@return: The C{float} fraction of the title sequence matched by its
reads. | [
"Get",
"the",
"fraction",
"of",
"this",
"title",
"sequence",
"that",
"is",
"matched",
"by",
"its",
"reads",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L159-L169 |
acorg/dark-matter | dark/titles.py | TitleAlignments.coverageInfo | def coverageInfo(self):
"""
Return information about the bases found at each location in our title
sequence.
@return: A C{dict} whose keys are C{int} subject offsets and whose
values are unsorted lists of (score, base) 2-tuples, giving all the
bases from reads th... | python | def coverageInfo(self):
"""
Return information about the bases found at each location in our title
sequence.
@return: A C{dict} whose keys are C{int} subject offsets and whose
values are unsorted lists of (score, base) 2-tuples, giving all the
bases from reads th... | [
"def",
"coverageInfo",
"(",
"self",
")",
":",
"result",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"titleAlignment",
"in",
"self",
":",
"for",
"hsp",
"in",
"titleAlignment",
".",
"hsps",
":",
"score",
"=",
"hsp",
".",
"score",
".",
"score",
"for",
"(... | Return information about the bases found at each location in our title
sequence.
@return: A C{dict} whose keys are C{int} subject offsets and whose
values are unsorted lists of (score, base) 2-tuples, giving all the
bases from reads that matched the subject at subject location,
... | [
"Return",
"information",
"about",
"the",
"bases",
"found",
"at",
"each",
"location",
"in",
"our",
"title",
"sequence",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L181-L200 |
acorg/dark-matter | dark/titles.py | TitleAlignments.residueCounts | def residueCounts(self, convertCaseTo='upper'):
"""
Count residue frequencies at all sequence locations matched by reads.
@param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'.
If 'none', case will not be converted (both the upper and lower
case string of a residue... | python | def residueCounts(self, convertCaseTo='upper'):
"""
Count residue frequencies at all sequence locations matched by reads.
@param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'.
If 'none', case will not be converted (both the upper and lower
case string of a residue... | [
"def",
"residueCounts",
"(",
"self",
",",
"convertCaseTo",
"=",
"'upper'",
")",
":",
"if",
"convertCaseTo",
"==",
"'none'",
":",
"def",
"convert",
"(",
"x",
")",
":",
"return",
"x",
"elif",
"convertCaseTo",
"==",
"'lower'",
":",
"convert",
"=",
"str",
".... | Count residue frequencies at all sequence locations matched by reads.
@param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'.
If 'none', case will not be converted (both the upper and lower
case string of a residue will be present in the result if they are
present in th... | [
"Count",
"residue",
"frequencies",
"at",
"all",
"sequence",
"locations",
"matched",
"by",
"reads",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L202-L233 |
acorg/dark-matter | dark/titles.py | TitleAlignments.summary | def summary(self):
"""
Summarize the alignments for this subject.
@return: A C{dict} with C{str} keys:
bestScore: The C{float} best score of the matching reads.
coverage: The C{float} fraction of the subject genome that is
matched by at least one read.
... | python | def summary(self):
"""
Summarize the alignments for this subject.
@return: A C{dict} with C{str} keys:
bestScore: The C{float} best score of the matching reads.
coverage: The C{float} fraction of the subject genome that is
matched by at least one read.
... | [
"def",
"summary",
"(",
"self",
")",
":",
"return",
"{",
"'bestScore'",
":",
"self",
".",
"bestHsp",
"(",
")",
".",
"score",
".",
"score",
",",
"'coverage'",
":",
"self",
".",
"coverage",
"(",
")",
",",
"'hspCount'",
":",
"self",
".",
"hspCount",
"(",... | Summarize the alignments for this subject.
@return: A C{dict} with C{str} keys:
bestScore: The C{float} best score of the matching reads.
coverage: The C{float} fraction of the subject genome that is
matched by at least one read.
hspCount: The C{int} number o... | [
"Summarize",
"the",
"alignments",
"for",
"this",
"subject",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L235-L257 |
acorg/dark-matter | dark/titles.py | TitleAlignments.toDict | def toDict(self):
"""
Get information about the title's alignments as a dictionary.
@return: A C{dict} representation of the title's aligments.
"""
return {
'titleAlignments': [titleAlignment.toDict()
for titleAlignment in self],
... | python | def toDict(self):
"""
Get information about the title's alignments as a dictionary.
@return: A C{dict} representation of the title's aligments.
"""
return {
'titleAlignments': [titleAlignment.toDict()
for titleAlignment in self],
... | [
"def",
"toDict",
"(",
"self",
")",
":",
"return",
"{",
"'titleAlignments'",
":",
"[",
"titleAlignment",
".",
"toDict",
"(",
")",
"for",
"titleAlignment",
"in",
"self",
"]",
",",
"'subjectTitle'",
":",
"self",
".",
"subjectTitle",
",",
"'subjectLength'",
":",... | Get information about the title's alignments as a dictionary.
@return: A C{dict} representation of the title's aligments. | [
"Get",
"information",
"about",
"the",
"title",
"s",
"alignments",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L259-L270 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.addTitle | def addTitle(self, title, titleAlignments):
"""
Add a new title to self.
@param title: A C{str} title.
@param titleAlignments: An instance of L{TitleAlignments}.
@raises KeyError: If the title is already present.
"""
if title in self:
raise KeyError('... | python | def addTitle(self, title, titleAlignments):
"""
Add a new title to self.
@param title: A C{str} title.
@param titleAlignments: An instance of L{TitleAlignments}.
@raises KeyError: If the title is already present.
"""
if title in self:
raise KeyError('... | [
"def",
"addTitle",
"(",
"self",
",",
"title",
",",
"titleAlignments",
")",
":",
"if",
"title",
"in",
"self",
":",
"raise",
"KeyError",
"(",
"'Title %r already present in TitlesAlignments '",
"'instance.'",
"%",
"title",
")",
"else",
":",
"self",
"[",
"title",
... | Add a new title to self.
@param title: A C{str} title.
@param titleAlignments: An instance of L{TitleAlignments}.
@raises KeyError: If the title is already present. | [
"Add",
"a",
"new",
"title",
"to",
"self",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L307-L319 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.filter | def filter(self, minMatchingReads=None, minMedianScore=None,
withScoreBetterThan=None, minNewReads=None, minCoverage=None,
maxTitles=None, sortOn='maxScore'):
"""
Filter the titles in self to create another TitlesAlignments.
@param minMatchingReads: titles that are... | python | def filter(self, minMatchingReads=None, minMedianScore=None,
withScoreBetterThan=None, minNewReads=None, minCoverage=None,
maxTitles=None, sortOn='maxScore'):
"""
Filter the titles in self to create another TitlesAlignments.
@param minMatchingReads: titles that are... | [
"def",
"filter",
"(",
"self",
",",
"minMatchingReads",
"=",
"None",
",",
"minMedianScore",
"=",
"None",
",",
"withScoreBetterThan",
"=",
"None",
",",
"minNewReads",
"=",
"None",
",",
"minCoverage",
"=",
"None",
",",
"maxTitles",
"=",
"None",
",",
"sortOn",
... | Filter the titles in self to create another TitlesAlignments.
@param minMatchingReads: titles that are matched by fewer reads
are unacceptable.
@param minMedianScore: sequences that are matched with a median
bit score that is less are unacceptable.
@param withScoreBetter... | [
"Filter",
"the",
"titles",
"in",
"self",
"to",
"create",
"another",
"TitlesAlignments",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L321-L413 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.hsps | def hsps(self):
"""
Get all HSPs for all the alignments for all titles.
@return: A generator yielding L{dark.hsp.HSP} instances.
"""
return (hsp for titleAlignments in self.values()
for alignment in titleAlignments for hsp in alignment.hsps) | python | def hsps(self):
"""
Get all HSPs for all the alignments for all titles.
@return: A generator yielding L{dark.hsp.HSP} instances.
"""
return (hsp for titleAlignments in self.values()
for alignment in titleAlignments for hsp in alignment.hsps) | [
"def",
"hsps",
"(",
"self",
")",
":",
"return",
"(",
"hsp",
"for",
"titleAlignments",
"in",
"self",
".",
"values",
"(",
")",
"for",
"alignment",
"in",
"titleAlignments",
"for",
"hsp",
"in",
"alignment",
".",
"hsps",
")"
] | Get all HSPs for all the alignments for all titles.
@return: A generator yielding L{dark.hsp.HSP} instances. | [
"Get",
"all",
"HSPs",
"for",
"all",
"the",
"alignments",
"for",
"all",
"titles",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L415-L422 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.sortTitles | def sortTitles(self, by):
"""
Sort titles by a given attribute and then by title.
@param by: A C{str}, one of 'length', 'maxScore', 'medianScore',
'readCount', or 'title'.
@raise ValueError: If an unknown C{by} value is given.
@return: A sorted C{list} of titles.
... | python | def sortTitles(self, by):
"""
Sort titles by a given attribute and then by title.
@param by: A C{str}, one of 'length', 'maxScore', 'medianScore',
'readCount', or 'title'.
@raise ValueError: If an unknown C{by} value is given.
@return: A sorted C{list} of titles.
... | [
"def",
"sortTitles",
"(",
"self",
",",
"by",
")",
":",
"# First sort titles by the secondary key, which is always the title.",
"titles",
"=",
"sorted",
"(",
"iter",
"(",
"self",
")",
")",
"# Then sort on the primary key (if any).",
"if",
"by",
"==",
"'length'",
":",
"... | Sort titles by a given attribute and then by title.
@param by: A C{str}, one of 'length', 'maxScore', 'medianScore',
'readCount', or 'title'.
@raise ValueError: If an unknown C{by} value is given.
@return: A sorted C{list} of titles. | [
"Sort",
"titles",
"by",
"a",
"given",
"attribute",
"and",
"then",
"by",
"title",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L424-L456 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.summary | def summary(self, sortOn=None):
"""
Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@retu... | python | def summary(self, sortOn=None):
"""
Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@retu... | [
"def",
"summary",
"(",
"self",
",",
"sortOn",
"=",
"None",
")",
":",
"titles",
"=",
"self",
"if",
"sortOn",
"is",
"None",
"else",
"self",
".",
"sortTitles",
"(",
"sortOn",
")",
"for",
"title",
"in",
"titles",
":",
"yield",
"self",
"[",
"title",
"]",
... | Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@return: A generator that yields C{dict} instances as pro... | [
"Summarize",
"all",
"the",
"alignments",
"for",
"this",
"title",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L458-L472 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.tabSeparatedSummary | def tabSeparatedSummary(self, sortOn=None):
"""
Summarize all the alignments for this title as multi-line string with
TAB-separated values on each line.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
... | python | def tabSeparatedSummary(self, sortOn=None):
"""
Summarize all the alignments for this title as multi-line string with
TAB-separated values on each line.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
... | [
"def",
"tabSeparatedSummary",
"(",
"self",
",",
"sortOn",
"=",
"None",
")",
":",
"# The order of the fields returned here is somewhat arbitrary. The",
"# subject titles are last because they are so variable in length.",
"# Putting them last makes it more likely that the initial columns in",
... | Summarize all the alignments for this title as multi-line string with
TAB-separated values on each line.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is give... | [
"Summarize",
"all",
"the",
"alignments",
"for",
"this",
"title",
"as",
"multi",
"-",
"line",
"string",
"with",
"TAB",
"-",
"separated",
"values",
"on",
"each",
"line",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L474-L508 |
acorg/dark-matter | dark/titles.py | TitlesAlignments.toDict | def toDict(self):
"""
Get information about the titles alignments as a dictionary.
@return: A C{dict} representation of the titles aligments.
"""
return {
'scoreClass': self.scoreClass.__name__,
'titles': dict((title, titleAlignments.toDict())
... | python | def toDict(self):
"""
Get information about the titles alignments as a dictionary.
@return: A C{dict} representation of the titles aligments.
"""
return {
'scoreClass': self.scoreClass.__name__,
'titles': dict((title, titleAlignments.toDict())
... | [
"def",
"toDict",
"(",
"self",
")",
":",
"return",
"{",
"'scoreClass'",
":",
"self",
".",
"scoreClass",
".",
"__name__",
",",
"'titles'",
":",
"dict",
"(",
"(",
"title",
",",
"titleAlignments",
".",
"toDict",
"(",
")",
")",
"for",
"title",
",",
"titleAl... | Get information about the titles alignments as a dictionary.
@return: A C{dict} representation of the titles aligments. | [
"Get",
"information",
"about",
"the",
"titles",
"alignments",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L510-L520 |
acorg/dark-matter | dark/filter.py | addFASTAFilteringCommandLineOptions | def addFASTAFilteringCommandLineOptions(parser):
"""
Add standard FASTA filtering command-line options to an argparse parser.
These are options that can be used to select or omit entire FASTA records,
NOT options that change them (for that see
addFASTAEditingCommandLineOptions).
@param parser:... | python | def addFASTAFilteringCommandLineOptions(parser):
"""
Add standard FASTA filtering command-line options to an argparse parser.
These are options that can be used to select or omit entire FASTA records,
NOT options that change them (for that see
addFASTAEditingCommandLineOptions).
@param parser:... | [
"def",
"addFASTAFilteringCommandLineOptions",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--minLength'",
",",
"type",
"=",
"int",
",",
"help",
"=",
"'The minimum sequence length'",
")",
"parser",
".",
"add_argument",
"(",
"'--maxLength'",
",",
"... | Add standard FASTA filtering command-line options to an argparse parser.
These are options that can be used to select or omit entire FASTA records,
NOT options that change them (for that see
addFASTAEditingCommandLineOptions).
@param parser: An C{argparse.ArgumentParser} instance. | [
"Add",
"standard",
"FASTA",
"filtering",
"command",
"-",
"line",
"options",
"to",
"an",
"argparse",
"parser",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L172-L268 |
acorg/dark-matter | dark/filter.py | parseFASTAFilteringCommandLineOptions | def parseFASTAFilteringCommandLineOptions(args, reads):
"""
Examine parsed FASTA filtering command-line options and return filtered
reads.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The fi... | python | def parseFASTAFilteringCommandLineOptions(args, reads):
"""
Examine parsed FASTA filtering command-line options and return filtered
reads.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The fi... | [
"def",
"parseFASTAFilteringCommandLineOptions",
"(",
"args",
",",
"reads",
")",
":",
"keepSequences",
"=",
"(",
"parseRangeString",
"(",
"args",
".",
"keepSequences",
",",
"convertToZeroBased",
"=",
"True",
")",
"if",
"args",
".",
"keepSequences",
"else",
"None",
... | Examine parsed FASTA filtering command-line options and return filtered
reads.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The filtered C{Reads} instance. | [
"Examine",
"parsed",
"FASTA",
"filtering",
"command",
"-",
"line",
"options",
"and",
"return",
"filtered",
"reads",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L271-L301 |
acorg/dark-matter | dark/filter.py | addFASTAEditingCommandLineOptions | def addFASTAEditingCommandLineOptions(parser):
"""
Add standard FASTA editing command-line options to an argparse parser.
These are options that can be used to alter FASTA records, NOT options
that simply select or reject those things (for those see
addFASTAFilteringCommandLineOptions).
@param... | python | def addFASTAEditingCommandLineOptions(parser):
"""
Add standard FASTA editing command-line options to an argparse parser.
These are options that can be used to alter FASTA records, NOT options
that simply select or reject those things (for those see
addFASTAFilteringCommandLineOptions).
@param... | [
"def",
"addFASTAEditingCommandLineOptions",
"(",
"parser",
")",
":",
"# A mutually exclusive group for --keepSites, --keepSitesFile,",
"# --removeSites, and --removeSitesFile.",
"group",
"=",
"parser",
".",
"add_mutually_exclusive_group",
"(",
")",
"# In the 4 options below, the 'indic... | Add standard FASTA editing command-line options to an argparse parser.
These are options that can be used to alter FASTA records, NOT options
that simply select or reject those things (for those see
addFASTAFilteringCommandLineOptions).
@param parser: An C{argparse.ArgumentParser} instance. | [
"Add",
"standard",
"FASTA",
"editing",
"command",
"-",
"line",
"options",
"to",
"an",
"argparse",
"parser",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L304-L389 |
acorg/dark-matter | dark/filter.py | parseFASTAEditingCommandLineOptions | def parseFASTAEditingCommandLineOptions(args, reads):
"""
Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to fil... | python | def parseFASTAEditingCommandLineOptions(args, reads):
"""
Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to fil... | [
"def",
"parseFASTAEditingCommandLineOptions",
"(",
"args",
",",
"reads",
")",
":",
"removeGaps",
"=",
"args",
".",
"removeGaps",
"removeDescriptions",
"=",
"args",
".",
"removeDescriptions",
"truncateTitlesAfter",
"=",
"args",
".",
"truncateTitlesAfter",
"keepSites",
... | Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The filtered C{Reads} instance. | [
"Examine",
"parsed",
"FASTA",
"editing",
"command",
"-",
"line",
"options",
"and",
"return",
"information",
"about",
"kept",
"sites",
"and",
"sequences",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L392-L443 |
acorg/dark-matter | dark/filter.py | TitleFilter.accept | def accept(self, title):
"""
Return a value (see below) to indicate if a title is acceptable (and,
if so, in what way).
@param title: A C{str} sequence title.
@return: An C{int} to indicate an acceptable title or not. This will be
C{self.REJECT} if the title is unac... | python | def accept(self, title):
"""
Return a value (see below) to indicate if a title is acceptable (and,
if so, in what way).
@param title: A C{str} sequence title.
@return: An C{int} to indicate an acceptable title or not. This will be
C{self.REJECT} if the title is unac... | [
"def",
"accept",
"(",
"self",
",",
"title",
")",
":",
"if",
"self",
".",
"_whitelist",
"and",
"title",
"in",
"self",
".",
"_whitelist",
":",
"return",
"self",
".",
"WHITELIST_ACCEPT",
"if",
"self",
".",
"_blacklist",
"and",
"title",
"in",
"self",
".",
... | Return a value (see below) to indicate if a title is acceptable (and,
if so, in what way).
@param title: A C{str} sequence title.
@return: An C{int} to indicate an acceptable title or not. This will be
C{self.REJECT} if the title is unacceptable.
C{self.WHITELIST_ACCEPT... | [
"Return",
"a",
"value",
"(",
"see",
"below",
")",
"to",
"indicate",
"if",
"a",
"title",
"is",
"acceptable",
"(",
"and",
"if",
"so",
"in",
"what",
"way",
")",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L67-L110 |
acorg/dark-matter | dark/filter.py | ReadSetFilter.accept | def accept(self, title, titleAlignments):
"""
Return C{True} if the read id set in C{titleAlignments} is sufficiently
different from all previously seen read sets.
@param title: A C{str} sequence title.
@param titleAlignments: An instance of L{TitleAlignment}.
@return: A... | python | def accept(self, title, titleAlignments):
"""
Return C{True} if the read id set in C{titleAlignments} is sufficiently
different from all previously seen read sets.
@param title: A C{str} sequence title.
@param titleAlignments: An instance of L{TitleAlignment}.
@return: A... | [
"def",
"accept",
"(",
"self",
",",
"title",
",",
"titleAlignments",
")",
":",
"# Sanity check: titles can only be passed once.",
"assert",
"title",
"not",
"in",
"self",
".",
"_titles",
",",
"(",
"'Title %r seen multiple times.'",
"%",
"title",
")",
"readIds",
"=",
... | Return C{True} if the read id set in C{titleAlignments} is sufficiently
different from all previously seen read sets.
@param title: A C{str} sequence title.
@param titleAlignments: An instance of L{TitleAlignment}.
@return: A C{bool} indicating whether a title has an acceptably novel
... | [
"Return",
"C",
"{",
"True",
"}",
"if",
"the",
"read",
"id",
"set",
"in",
"C",
"{",
"titleAlignments",
"}",
"is",
"sufficiently",
"different",
"from",
"all",
"previously",
"seen",
"read",
"sets",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L129-L157 |
acorg/dark-matter | dark/blast/conversion.py | XMLRecordsReader._convertBlastRecordToDict | def _convertBlastRecordToDict(self, record):
"""
Pull (only) the fields we use out of the record and return them as a
dict. Although we take the title from each alignment description, we
save space in the JSON output by storing it in the alignment dict (not
in a separated 'descr... | python | def _convertBlastRecordToDict(self, record):
"""
Pull (only) the fields we use out of the record and return them as a
dict. Although we take the title from each alignment description, we
save space in the JSON output by storing it in the alignment dict (not
in a separated 'descr... | [
"def",
"_convertBlastRecordToDict",
"(",
"self",
",",
"record",
")",
":",
"alignments",
"=",
"[",
"]",
"for",
"alignment",
"in",
"record",
".",
"alignments",
":",
"hsps",
"=",
"[",
"]",
"for",
"hsp",
"in",
"alignment",
".",
"hsps",
":",
"hsps",
".",
"a... | Pull (only) the fields we use out of the record and return them as a
dict. Although we take the title from each alignment description, we
save space in the JSON output by storing it in the alignment dict (not
in a separated 'description' dict). When we undo this conversion (in
JSONRecor... | [
"Pull",
"(",
"only",
")",
"the",
"fields",
"we",
"use",
"out",
"of",
"the",
"record",
"and",
"return",
"them",
"as",
"a",
"dict",
".",
"Although",
"we",
"take",
"the",
"title",
"from",
"each",
"alignment",
"description",
"we",
"save",
"space",
"in",
"t... | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L31-L73 |
acorg/dark-matter | dark/blast/conversion.py | XMLRecordsReader._convertBlastParamsToDict | def _convertBlastParamsToDict(self, record):
"""
Pull the global BLAST parameters out of a BLAST record and return
them as a C{dict}.
Some of these attributes are useless (not filled in), but we record
them all just in case we one day need them or they start to be used or
... | python | def _convertBlastParamsToDict(self, record):
"""
Pull the global BLAST parameters out of a BLAST record and return
them as a C{dict}.
Some of these attributes are useless (not filled in), but we record
them all just in case we one day need them or they start to be used or
... | [
"def",
"_convertBlastParamsToDict",
"(",
"self",
",",
"record",
")",
":",
"result",
"=",
"{",
"}",
"for",
"attr",
"in",
"(",
"# From Bio.Blast.Record.Header",
"'application'",
",",
"'version'",
",",
"'date'",
",",
"'reference'",
",",
"'query'",
",",
"'query_lett... | Pull the global BLAST parameters out of a BLAST record and return
them as a C{dict}.
Some of these attributes are useless (not filled in), but we record
them all just in case we one day need them or they start to be used or
they disappear etc. Any of those changes might alert us that so... | [
"Pull",
"the",
"global",
"BLAST",
"parameters",
"out",
"of",
"a",
"BLAST",
"record",
"and",
"return",
"them",
"as",
"a",
"C",
"{",
"dict",
"}",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L75-L140 |
acorg/dark-matter | dark/blast/conversion.py | XMLRecordsReader.records | def records(self):
"""
Yield BLAST records, as read by the BioPython NCBIXML.parse
method. Set self.params from data in the first record.
"""
first = True
with as_handle(self._filename) as fp:
for record in NCBIXML.parse(fp):
if first:
... | python | def records(self):
"""
Yield BLAST records, as read by the BioPython NCBIXML.parse
method. Set self.params from data in the first record.
"""
first = True
with as_handle(self._filename) as fp:
for record in NCBIXML.parse(fp):
if first:
... | [
"def",
"records",
"(",
"self",
")",
":",
"first",
"=",
"True",
"with",
"as_handle",
"(",
"self",
".",
"_filename",
")",
"as",
"fp",
":",
"for",
"record",
"in",
"NCBIXML",
".",
"parse",
"(",
"fp",
")",
":",
"if",
"first",
":",
"self",
".",
"params",... | Yield BLAST records, as read by the BioPython NCBIXML.parse
method. Set self.params from data in the first record. | [
"Yield",
"BLAST",
"records",
"as",
"read",
"by",
"the",
"BioPython",
"NCBIXML",
".",
"parse",
"method",
".",
"Set",
"self",
".",
"params",
"from",
"data",
"in",
"the",
"first",
"record",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L142-L153 |
acorg/dark-matter | dark/blast/conversion.py | XMLRecordsReader.saveAsJSON | def saveAsJSON(self, fp):
"""
Write the records out as JSON. The first JSON object saved contains
the BLAST parameters.
@param fp: A C{str} file pointer to write to.
"""
first = True
for record in self.records():
if first:
print(dumps(... | python | def saveAsJSON(self, fp):
"""
Write the records out as JSON. The first JSON object saved contains
the BLAST parameters.
@param fp: A C{str} file pointer to write to.
"""
first = True
for record in self.records():
if first:
print(dumps(... | [
"def",
"saveAsJSON",
"(",
"self",
",",
"fp",
")",
":",
"first",
"=",
"True",
"for",
"record",
"in",
"self",
".",
"records",
"(",
")",
":",
"if",
"first",
":",
"print",
"(",
"dumps",
"(",
"self",
".",
"params",
",",
"separators",
"=",
"(",
"','",
... | Write the records out as JSON. The first JSON object saved contains
the BLAST parameters.
@param fp: A C{str} file pointer to write to. | [
"Write",
"the",
"records",
"out",
"as",
"JSON",
".",
"The",
"first",
"JSON",
"object",
"saved",
"contains",
"the",
"BLAST",
"parameters",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L155-L168 |
acorg/dark-matter | dark/blast/conversion.py | JSONRecordsReader._open | def _open(self, filename):
"""
Open the input file. Set self._fp to point to it. Read the first
line of parameters.
@param filename: A C{str} filename containing JSON BLAST records.
@raise ValueError: if the first line of the file isn't valid JSON,
if the input file ... | python | def _open(self, filename):
"""
Open the input file. Set self._fp to point to it. Read the first
line of parameters.
@param filename: A C{str} filename containing JSON BLAST records.
@raise ValueError: if the first line of the file isn't valid JSON,
if the input file ... | [
"def",
"_open",
"(",
"self",
",",
"filename",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.bz2'",
")",
":",
"if",
"six",
".",
"PY3",
":",
"self",
".",
"_fp",
"=",
"bz2",
".",
"open",
"(",
"filename",
",",
"mode",
"=",
"'rt'",
",",
"encodi... | Open the input file. Set self._fp to point to it. Read the first
line of parameters.
@param filename: A C{str} filename containing JSON BLAST records.
@raise ValueError: if the first line of the file isn't valid JSON,
if the input file is empty, or if the JSON does not contain an
... | [
"Open",
"the",
"input",
"file",
".",
"Set",
"self",
".",
"_fp",
"to",
"point",
"to",
"it",
".",
"Read",
"the",
"first",
"line",
"of",
"parameters",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L196-L229 |
acorg/dark-matter | dark/blast/conversion.py | JSONRecordsReader._dictToAlignments | def _dictToAlignments(self, blastDict, read):
"""
Take a dict (made by XMLRecordsReader._convertBlastRecordToDict)
and convert it to a list of alignments.
@param blastDict: A C{dict}, from convertBlastRecordToDict.
@param read: A C{Read} instance, containing the read that BLAST ... | python | def _dictToAlignments(self, blastDict, read):
"""
Take a dict (made by XMLRecordsReader._convertBlastRecordToDict)
and convert it to a list of alignments.
@param blastDict: A C{dict}, from convertBlastRecordToDict.
@param read: A C{Read} instance, containing the read that BLAST ... | [
"def",
"_dictToAlignments",
"(",
"self",
",",
"blastDict",
",",
"read",
")",
":",
"if",
"(",
"blastDict",
"[",
"'query'",
"]",
"!=",
"read",
".",
"id",
"and",
"blastDict",
"[",
"'query'",
"]",
".",
"split",
"(",
")",
"[",
"0",
"]",
"!=",
"read",
".... | Take a dict (made by XMLRecordsReader._convertBlastRecordToDict)
and convert it to a list of alignments.
@param blastDict: A C{dict}, from convertBlastRecordToDict.
@param read: A C{Read} instance, containing the read that BLAST used
to create this record.
@raise ValueError:... | [
"Take",
"a",
"dict",
"(",
"made",
"by",
"XMLRecordsReader",
".",
"_convertBlastRecordToDict",
")",
"and",
"convert",
"it",
"to",
"a",
"list",
"of",
"alignments",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L231-L285 |
acorg/dark-matter | dark/blast/conversion.py | JSONRecordsReader.readAlignments | def readAlignments(self, reads):
"""
Read lines of JSON from self._filename, convert them to read alignments
and yield them.
@param reads: An iterable of L{Read} instances, corresponding to the
reads that were given to BLAST.
@raise ValueError: If any of the lines in... | python | def readAlignments(self, reads):
"""
Read lines of JSON from self._filename, convert them to read alignments
and yield them.
@param reads: An iterable of L{Read} instances, corresponding to the
reads that were given to BLAST.
@raise ValueError: If any of the lines in... | [
"def",
"readAlignments",
"(",
"self",
",",
"reads",
")",
":",
"if",
"self",
".",
"_fp",
"is",
"None",
":",
"self",
".",
"_open",
"(",
"self",
".",
"_filename",
")",
"reads",
"=",
"iter",
"(",
"reads",
")",
"try",
":",
"for",
"lineNumber",
",",
"lin... | Read lines of JSON from self._filename, convert them to read alignments
and yield them.
@param reads: An iterable of L{Read} instances, corresponding to the
reads that were given to BLAST.
@raise ValueError: If any of the lines in the file cannot be converted
to JSON.
... | [
"Read",
"lines",
"of",
"JSON",
"from",
"self",
".",
"_filename",
"convert",
"them",
"to",
"read",
"alignments",
"and",
"yield",
"them",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L287-L326 |
acorg/dark-matter | dark/reads.py | _makeComplementTable | def _makeComplementTable(complementData):
"""
Make a sequence complement table.
@param complementData: A C{dict} whose keys and values are strings of
length one. A key, value pair indicates a substitution that should
be performed during complementation.
@return: A 256 character string t... | python | def _makeComplementTable(complementData):
"""
Make a sequence complement table.
@param complementData: A C{dict} whose keys and values are strings of
length one. A key, value pair indicates a substitution that should
be performed during complementation.
@return: A 256 character string t... | [
"def",
"_makeComplementTable",
"(",
"complementData",
")",
":",
"table",
"=",
"list",
"(",
"range",
"(",
"256",
")",
")",
"for",
"_from",
",",
"to",
"in",
"complementData",
".",
"items",
"(",
")",
":",
"table",
"[",
"ord",
"(",
"_from",
"[",
"0",
"]"... | Make a sequence complement table.
@param complementData: A C{dict} whose keys and values are strings of
length one. A key, value pair indicates a substitution that should
be performed during complementation.
@return: A 256 character string that can be used as a translation table
by the ... | [
"Make",
"a",
"sequence",
"complement",
"table",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L18-L32 |
acorg/dark-matter | dark/reads.py | addFASTACommandLineOptions | def addFASTACommandLineOptions(parser):
"""
Add standard command-line options to an argparse parser.
@param parser: An C{argparse.ArgumentParser} instance.
"""
parser.add_argument(
'--fastaFile', type=open, default=sys.stdin, metavar='FILENAME',
help=('The name of the FASTA input f... | python | def addFASTACommandLineOptions(parser):
"""
Add standard command-line options to an argparse parser.
@param parser: An C{argparse.ArgumentParser} instance.
"""
parser.add_argument(
'--fastaFile', type=open, default=sys.stdin, metavar='FILENAME',
help=('The name of the FASTA input f... | [
"def",
"addFASTACommandLineOptions",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--fastaFile'",
",",
"type",
"=",
"open",
",",
"default",
"=",
"sys",
".",
"stdin",
",",
"metavar",
"=",
"'FILENAME'",
",",
"help",
"=",
"(",
"'The name of the... | Add standard command-line options to an argparse parser.
@param parser: An C{argparse.ArgumentParser} instance. | [
"Add",
"standard",
"command",
"-",
"line",
"options",
"to",
"an",
"argparse",
"parser",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1476-L1510 |
acorg/dark-matter | dark/reads.py | parseFASTACommandLineOptions | def parseFASTACommandLineOptions(args):
"""
Examine parsed command-line options and return a Reads instance.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@return: A C{Reads} subclass instance, depending on the type of FASTA file
given.
"""
... | python | def parseFASTACommandLineOptions(args):
"""
Examine parsed command-line options and return a Reads instance.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@return: A C{Reads} subclass instance, depending on the type of FASTA file
given.
"""
... | [
"def",
"parseFASTACommandLineOptions",
"(",
"args",
")",
":",
"# Set default FASTA type.",
"if",
"not",
"(",
"args",
".",
"fasta",
"or",
"args",
".",
"fastq",
"or",
"args",
".",
"fasta_ss",
")",
":",
"args",
".",
"fasta",
"=",
"True",
"readClass",
"=",
"re... | Examine parsed command-line options and return a Reads instance.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@return: A C{Reads} subclass instance, depending on the type of FASTA file
given. | [
"Examine",
"parsed",
"command",
"-",
"line",
"options",
"and",
"return",
"a",
"Reads",
"instance",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1513-L1536 |
acorg/dark-matter | dark/reads.py | _NucleotideRead.translations | def translations(self):
"""
Yield all six translations of a nucleotide sequence.
@return: A generator that produces six L{TranslatedRead} instances.
"""
rc = self.reverseComplement().sequence
for reverseComplemented in False, True:
for frame in 0, 1, 2:
... | python | def translations(self):
"""
Yield all six translations of a nucleotide sequence.
@return: A generator that produces six L{TranslatedRead} instances.
"""
rc = self.reverseComplement().sequence
for reverseComplemented in False, True:
for frame in 0, 1, 2:
... | [
"def",
"translations",
"(",
"self",
")",
":",
"rc",
"=",
"self",
".",
"reverseComplement",
"(",
")",
".",
"sequence",
"for",
"reverseComplemented",
"in",
"False",
",",
"True",
":",
"for",
"frame",
"in",
"0",
",",
"1",
",",
"2",
":",
"seq",
"=",
"rc",... | Yield all six translations of a nucleotide sequence.
@return: A generator that produces six L{TranslatedRead} instances. | [
"Yield",
"all",
"six",
"translations",
"of",
"a",
"nucleotide",
"sequence",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L275-L295 |
acorg/dark-matter | dark/reads.py | _NucleotideRead.reverseComplement | def reverseComplement(self):
"""
Reverse complement a nucleotide sequence.
@return: The reverse complemented sequence as an instance of the
current class.
"""
quality = None if self.quality is None else self.quality[::-1]
sequence = self.sequence.translate(se... | python | def reverseComplement(self):
"""
Reverse complement a nucleotide sequence.
@return: The reverse complemented sequence as an instance of the
current class.
"""
quality = None if self.quality is None else self.quality[::-1]
sequence = self.sequence.translate(se... | [
"def",
"reverseComplement",
"(",
"self",
")",
":",
"quality",
"=",
"None",
"if",
"self",
".",
"quality",
"is",
"None",
"else",
"self",
".",
"quality",
"[",
":",
":",
"-",
"1",
"]",
"sequence",
"=",
"self",
".",
"sequence",
".",
"translate",
"(",
"sel... | Reverse complement a nucleotide sequence.
@return: The reverse complemented sequence as an instance of the
current class. | [
"Reverse",
"complement",
"a",
"nucleotide",
"sequence",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L297-L306 |
acorg/dark-matter | dark/reads.py | AARead.checkAlphabet | def checkAlphabet(self, count=10):
"""
A function which checks if an AA read really contains amino acids. This
additional testing is needed, because the letters in the DNA alphabet
are also in the AA alphabet.
@param count: An C{int}, indicating how many bases or amino acids at
... | python | def checkAlphabet(self, count=10):
"""
A function which checks if an AA read really contains amino acids. This
additional testing is needed, because the letters in the DNA alphabet
are also in the AA alphabet.
@param count: An C{int}, indicating how many bases or amino acids at
... | [
"def",
"checkAlphabet",
"(",
"self",
",",
"count",
"=",
"10",
")",
":",
"if",
"six",
".",
"PY3",
":",
"readLetters",
"=",
"super",
"(",
")",
".",
"checkAlphabet",
"(",
"count",
")",
"else",
":",
"readLetters",
"=",
"Read",
".",
"checkAlphabet",
"(",
... | A function which checks if an AA read really contains amino acids. This
additional testing is needed, because the letters in the DNA alphabet
are also in the AA alphabet.
@param count: An C{int}, indicating how many bases or amino acids at
the start of the sequence should be conside... | [
"A",
"function",
"which",
"checks",
"if",
"an",
"AA",
"read",
"really",
"contains",
"amino",
"acids",
".",
"This",
"additional",
"testing",
"is",
"needed",
"because",
"the",
"letters",
"in",
"the",
"DNA",
"alphabet",
"are",
"also",
"in",
"the",
"AA",
"alph... | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L385-L406 |
acorg/dark-matter | dark/reads.py | AARead.ORFs | def ORFs(self, openORFs=False):
"""
Find all ORFs in our sequence.
@param openORFs: If C{True} allow ORFs that do not have a start codon
and/or do not have a stop codon.
@return: A generator that yields AAReadORF instances that correspond
to the ORFs found in the... | python | def ORFs(self, openORFs=False):
"""
Find all ORFs in our sequence.
@param openORFs: If C{True} allow ORFs that do not have a start codon
and/or do not have a stop codon.
@return: A generator that yields AAReadORF instances that correspond
to the ORFs found in the... | [
"def",
"ORFs",
"(",
"self",
",",
"openORFs",
"=",
"False",
")",
":",
"# Return open ORFs to the left and right and closed ORFs within the",
"# sequence.",
"if",
"openORFs",
":",
"ORFStart",
"=",
"0",
"inOpenORF",
"=",
"True",
"# open on the left",
"inORF",
"=",
"False... | Find all ORFs in our sequence.
@param openORFs: If C{True} allow ORFs that do not have a start codon
and/or do not have a stop codon.
@return: A generator that yields AAReadORF instances that correspond
to the ORFs found in the AA sequence. | [
"Find",
"all",
"ORFs",
"in",
"our",
"sequence",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L427-L482 |
acorg/dark-matter | dark/reads.py | AAReadORF.toDict | def toDict(self):
"""
Get information about this read in a dictionary.
@return: A C{dict} with keys/values for the attributes of self.
"""
if six.PY3:
result = super().toDict()
else:
result = AARead.toDict(self)
result.update({
... | python | def toDict(self):
"""
Get information about this read in a dictionary.
@return: A C{dict} with keys/values for the attributes of self.
"""
if six.PY3:
result = super().toDict()
else:
result = AARead.toDict(self)
result.update({
... | [
"def",
"toDict",
"(",
"self",
")",
":",
"if",
"six",
".",
"PY3",
":",
"result",
"=",
"super",
"(",
")",
".",
"toDict",
"(",
")",
"else",
":",
"result",
"=",
"AARead",
".",
"toDict",
"(",
"self",
")",
"result",
".",
"update",
"(",
"{",
"'start'",
... | Get information about this read in a dictionary.
@return: A C{dict} with keys/values for the attributes of self. | [
"Get",
"information",
"about",
"this",
"read",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L535-L553 |
acorg/dark-matter | dark/reads.py | AAReadORF.fromDict | def fromDict(cls, d):
"""
Create a new instance from attribute values provided in a dictionary.
@param d: A C{dict} with keys/values for the attributes of a new
instance of this class. Keys 'id' and 'sequence' with C{str} values
must be provided. A 'quality' C{str} key i... | python | def fromDict(cls, d):
"""
Create a new instance from attribute values provided in a dictionary.
@param d: A C{dict} with keys/values for the attributes of a new
instance of this class. Keys 'id' and 'sequence' with C{str} values
must be provided. A 'quality' C{str} key i... | [
"def",
"fromDict",
"(",
"cls",
",",
"d",
")",
":",
"# Make a dummy instance whose attributes we can set explicitly.",
"new",
"=",
"cls",
"(",
"AARead",
"(",
"''",
",",
"''",
")",
",",
"0",
",",
"0",
",",
"True",
",",
"True",
")",
"new",
".",
"id",
"=",
... | Create a new instance from attribute values provided in a dictionary.
@param d: A C{dict} with keys/values for the attributes of a new
instance of this class. Keys 'id' and 'sequence' with C{str} values
must be provided. A 'quality' C{str} key is optional. Keys 'start'
and '... | [
"Create",
"a",
"new",
"instance",
"from",
"attribute",
"values",
"provided",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L556-L577 |
acorg/dark-matter | dark/reads.py | SSAARead.toString | def toString(self, format_='fasta-ss', structureSuffix=':structure'):
"""
Convert the read to a string in PDB format (sequence & structure). This
consists of two FASTA records, one for the sequence then one for the
structure.
@param format_: Either 'fasta-ss' or 'fasta'. In the ... | python | def toString(self, format_='fasta-ss', structureSuffix=':structure'):
"""
Convert the read to a string in PDB format (sequence & structure). This
consists of two FASTA records, one for the sequence then one for the
structure.
@param format_: Either 'fasta-ss' or 'fasta'. In the ... | [
"def",
"toString",
"(",
"self",
",",
"format_",
"=",
"'fasta-ss'",
",",
"structureSuffix",
"=",
"':structure'",
")",
":",
"if",
"format_",
"==",
"'fasta-ss'",
":",
"return",
"'>%s\\n%s\\n>%s%s\\n%s\\n'",
"%",
"(",
"self",
".",
"id",
",",
"self",
".",
"sequen... | Convert the read to a string in PDB format (sequence & structure). This
consists of two FASTA records, one for the sequence then one for the
structure.
@param format_: Either 'fasta-ss' or 'fasta'. In the former case, the
structure information is returned. Otherwise, plain FASTA is
... | [
"Convert",
"the",
"read",
"to",
"a",
"string",
"in",
"PDB",
"format",
"(",
"sequence",
"&",
"structure",
")",
".",
"This",
"consists",
"of",
"two",
"FASTA",
"records",
"one",
"for",
"the",
"sequence",
"then",
"one",
"for",
"the",
"structure",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L624-L647 |
acorg/dark-matter | dark/reads.py | SSAARead.newFromSites | def newFromSites(self, sites, exclude=False):
"""
Create a new read from self, with only certain sites.
@param sites: A set of C{int} 0-based sites (i.e., indices) in
sequences that should be kept. If C{None} (the default), all sites
are kept.
@param exclude: If ... | python | def newFromSites(self, sites, exclude=False):
"""
Create a new read from self, with only certain sites.
@param sites: A set of C{int} 0-based sites (i.e., indices) in
sequences that should be kept. If C{None} (the default), all sites
are kept.
@param exclude: If ... | [
"def",
"newFromSites",
"(",
"self",
",",
"sites",
",",
"exclude",
"=",
"False",
")",
":",
"if",
"exclude",
":",
"sites",
"=",
"set",
"(",
"range",
"(",
"len",
"(",
"self",
")",
")",
")",
"-",
"sites",
"newSequence",
"=",
"[",
"]",
"newStructure",
"... | Create a new read from self, with only certain sites.
@param sites: A set of C{int} 0-based sites (i.e., indices) in
sequences that should be kept. If C{None} (the default), all sites
are kept.
@param exclude: If C{True} the C{sites} will be excluded, not
included. | [
"Create",
"a",
"new",
"read",
"from",
"self",
"with",
"only",
"certain",
"sites",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L673-L696 |
acorg/dark-matter | dark/reads.py | TranslatedRead.toDict | def toDict(self):
"""
Get information about this read in a dictionary.
@return: A C{dict} with keys/values for the attributes of self.
"""
if six.PY3:
result = super().toDict()
else:
result = AARead.toDict(self)
result.update({
... | python | def toDict(self):
"""
Get information about this read in a dictionary.
@return: A C{dict} with keys/values for the attributes of self.
"""
if six.PY3:
result = super().toDict()
else:
result = AARead.toDict(self)
result.update({
... | [
"def",
"toDict",
"(",
"self",
")",
":",
"if",
"six",
".",
"PY3",
":",
"result",
"=",
"super",
"(",
")",
".",
"toDict",
"(",
")",
"else",
":",
"result",
"=",
"AARead",
".",
"toDict",
"(",
"self",
")",
"result",
".",
"update",
"(",
"{",
"'frame'",
... | Get information about this read in a dictionary.
@return: A C{dict} with keys/values for the attributes of self. | [
"Get",
"information",
"about",
"this",
"read",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L736-L752 |
acorg/dark-matter | dark/reads.py | TranslatedRead.fromDict | def fromDict(cls, d):
"""
Create a new instance from attribute values provided in a dictionary.
@param d: A C{dict} with keys/values for the attributes of a new
instance of this class. Keys 'id' and 'sequence' with C{str} values
must be provided. A 'quality' C{str} key i... | python | def fromDict(cls, d):
"""
Create a new instance from attribute values provided in a dictionary.
@param d: A C{dict} with keys/values for the attributes of a new
instance of this class. Keys 'id' and 'sequence' with C{str} values
must be provided. A 'quality' C{str} key i... | [
"def",
"fromDict",
"(",
"cls",
",",
"d",
")",
":",
"# Make a dummy instance whose attributes we can set explicitly.",
"new",
"=",
"cls",
"(",
"AARead",
"(",
"''",
",",
"''",
")",
",",
"0",
",",
"True",
")",
"new",
".",
"id",
"=",
"d",
"[",
"'id'",
"]",
... | Create a new instance from attribute values provided in a dictionary.
@param d: A C{dict} with keys/values for the attributes of a new
instance of this class. Keys 'id' and 'sequence' with C{str} values
must be provided. A 'quality' C{str} key is optional. Key 'frame'
must h... | [
"Create",
"a",
"new",
"instance",
"from",
"attribute",
"values",
"provided",
"in",
"a",
"dictionary",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L755-L773 |
acorg/dark-matter | dark/reads.py | TranslatedRead.maximumORFLength | def maximumORFLength(self, openORFs=True):
"""
Return the length of the longest (possibly partial) ORF in a translated
read. The ORF may originate or terminate outside the sequence, which is
why the length is just a lower bound.
"""
return max(len(orf) for orf in self.ORF... | python | def maximumORFLength(self, openORFs=True):
"""
Return the length of the longest (possibly partial) ORF in a translated
read. The ORF may originate or terminate outside the sequence, which is
why the length is just a lower bound.
"""
return max(len(orf) for orf in self.ORF... | [
"def",
"maximumORFLength",
"(",
"self",
",",
"openORFs",
"=",
"True",
")",
":",
"return",
"max",
"(",
"len",
"(",
"orf",
")",
"for",
"orf",
"in",
"self",
".",
"ORFs",
"(",
"openORFs",
")",
")"
] | Return the length of the longest (possibly partial) ORF in a translated
read. The ORF may originate or terminate outside the sequence, which is
why the length is just a lower bound. | [
"Return",
"the",
"length",
"of",
"the",
"longest",
"(",
"possibly",
"partial",
")",
"ORF",
"in",
"a",
"translated",
"read",
".",
"The",
"ORF",
"may",
"originate",
"or",
"terminate",
"outside",
"the",
"sequence",
"which",
"is",
"why",
"the",
"length",
"is",... | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L775-L781 |
acorg/dark-matter | dark/reads.py | ReadFilter.filter | def filter(self, read):
"""
Check if a read passes the filter.
@param read: A C{Read} instance.
@return: C{read} if C{read} passes the filter, C{False} if not.
"""
self.readIndex += 1
if self.alwaysFalse:
return False
if self.wantedSequenceN... | python | def filter(self, read):
"""
Check if a read passes the filter.
@param read: A C{Read} instance.
@return: C{read} if C{read} passes the filter, C{False} if not.
"""
self.readIndex += 1
if self.alwaysFalse:
return False
if self.wantedSequenceN... | [
"def",
"filter",
"(",
"self",
",",
"read",
")",
":",
"self",
".",
"readIndex",
"+=",
"1",
"if",
"self",
".",
"alwaysFalse",
":",
"return",
"False",
"if",
"self",
".",
"wantedSequenceNumberGeneratorExhausted",
":",
"return",
"False",
"if",
"self",
".",
"nex... | Check if a read passes the filter.
@param read: A C{Read} instance.
@return: C{read} if C{read} passes the filter, C{False} if not. | [
"Check",
"if",
"a",
"read",
"passes",
"the",
"filter",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1039-L1171 |
acorg/dark-matter | dark/reads.py | Reads.filterRead | def filterRead(self, read):
"""
Filter a read, according to our set of filters.
@param read: A C{Read} instance or one of its subclasses.
@return: C{False} if the read fails any of our filters, else the
C{Read} instance returned by our list of filters.
"""
fo... | python | def filterRead(self, read):
"""
Filter a read, according to our set of filters.
@param read: A C{Read} instance or one of its subclasses.
@return: C{False} if the read fails any of our filters, else the
C{Read} instance returned by our list of filters.
"""
fo... | [
"def",
"filterRead",
"(",
"self",
",",
"read",
")",
":",
"for",
"filterFunc",
"in",
"self",
".",
"_filters",
":",
"filteredRead",
"=",
"filterFunc",
"(",
"read",
")",
"if",
"filteredRead",
"is",
"False",
":",
"return",
"False",
"else",
":",
"read",
"=",
... | Filter a read, according to our set of filters.
@param read: A C{Read} instance or one of its subclasses.
@return: C{False} if the read fails any of our filters, else the
C{Read} instance returned by our list of filters. | [
"Filter",
"a",
"read",
"according",
"to",
"our",
"set",
"of",
"filters",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1221-L1235 |
acorg/dark-matter | dark/reads.py | Reads.save | def save(self, filename, format_='fasta'):
"""
Write the reads to C{filename} in the requested format.
@param filename: Either a C{str} file name to save into (the file will
be overwritten) or an open file descriptor (e.g., sys.stdout).
@param format_: A C{str} format to sav... | python | def save(self, filename, format_='fasta'):
"""
Write the reads to C{filename} in the requested format.
@param filename: Either a C{str} file name to save into (the file will
be overwritten) or an open file descriptor (e.g., sys.stdout).
@param format_: A C{str} format to sav... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"format_",
"=",
"'fasta'",
")",
":",
"format_",
"=",
"format_",
".",
"lower",
"(",
")",
"count",
"=",
"0",
"if",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"try",
":",
"with",
"open",
"(",... | Write the reads to C{filename} in the requested format.
@param filename: Either a C{str} file name to save into (the file will
be overwritten) or an open file descriptor (e.g., sys.stdout).
@param format_: A C{str} format to save as, either 'fasta', 'fastq' or
'fasta-ss'.
... | [
"Write",
"the",
"reads",
"to",
"C",
"{",
"filename",
"}",
"in",
"the",
"requested",
"format",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1323-L1352 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.