partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
Instruction._disassemble
Format instruction details for inclusion in disassembly output *lineno_width* sets the width of the line number field (0 omits it) *mark_as_current* inserts a '-->' marker arrow as part of the line
pyte/backports.py
def _disassemble(self, lineno_width=3, mark_as_current=False): """Format instruction details for inclusion in disassembly output *lineno_width* sets the width of the line number field (0 omits it) *mark_as_current* inserts a '-->' marker arrow as part of the line """ fields = []...
def _disassemble(self, lineno_width=3, mark_as_current=False): """Format instruction details for inclusion in disassembly output *lineno_width* sets the width of the line number field (0 omits it) *mark_as_current* inserts a '-->' marker arrow as part of the line """ fields = []...
[ "Format", "instruction", "details", "for", "inclusion", "in", "disassembly", "output" ]
Fuyukai/Pyte
python
https://github.com/Fuyukai/Pyte/blob/7ef04938d80f8b646bd73d976ac9787a5b88edd9/pyte/backports.py#L27-L61
[ "def", "_disassemble", "(", "self", ",", "lineno_width", "=", "3", ",", "mark_as_current", "=", "False", ")", ":", "fields", "=", "[", "]", "# Column: Source code line number", "if", "lineno_width", ":", "if", "self", ".", "starts_line", "is", "not", "None", ...
7ef04938d80f8b646bd73d976ac9787a5b88edd9
valid
intersection
Returns intersection of two lists. Assumes the lists are sorted by start positions
pyfastaq/intervals.py
def intersection(l1, l2): '''Returns intersection of two lists. Assumes the lists are sorted by start positions''' if len(l1) == 0 or len(l2) == 0: return [] out = [] l2_pos = 0 for l in l1: while l2_pos < len(l2) and l2[l2_pos].end < l.start: l2_pos += 1 if l...
def intersection(l1, l2): '''Returns intersection of two lists. Assumes the lists are sorted by start positions''' if len(l1) == 0 or len(l2) == 0: return [] out = [] l2_pos = 0 for l in l1: while l2_pos < len(l2) and l2[l2_pos].end < l.start: l2_pos += 1 if l...
[ "Returns", "intersection", "of", "two", "lists", ".", "Assumes", "the", "lists", "are", "sorted", "by", "start", "positions" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L68-L89
[ "def", "intersection", "(", "l1", ",", "l2", ")", ":", "if", "len", "(", "l1", ")", "==", "0", "or", "len", "(", "l2", ")", "==", "0", ":", "return", "[", "]", "out", "=", "[", "]", "l2_pos", "=", "0", "for", "l", "in", "l1", ":", "while", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
merge_overlapping_in_list
Sorts list, merges any overlapping intervals, and also adjacent intervals. e.g. [0,1], [1,2] would be merge to [0,.2].
pyfastaq/intervals.py
def merge_overlapping_in_list(l): '''Sorts list, merges any overlapping intervals, and also adjacent intervals. e.g. [0,1], [1,2] would be merge to [0,.2].''' i = 0 l.sort() while i < len(l) - 1: u = l[i].union(l[i+1]) if u is not None: l[i] = u l.pop(i+1)...
def merge_overlapping_in_list(l): '''Sorts list, merges any overlapping intervals, and also adjacent intervals. e.g. [0,1], [1,2] would be merge to [0,.2].''' i = 0 l.sort() while i < len(l) - 1: u = l[i].union(l[i+1]) if u is not None: l[i] = u l.pop(i+1)...
[ "Sorts", "list", "merges", "any", "overlapping", "intervals", "and", "also", "adjacent", "intervals", ".", "e", ".", "g", ".", "[", "0", "1", "]", "[", "1", "2", "]", "would", "be", "merge", "to", "[", "0", ".", "2", "]", "." ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L92-L104
[ "def", "merge_overlapping_in_list", "(", "l", ")", ":", "i", "=", "0", "l", ".", "sort", "(", ")", "while", "i", "<", "len", "(", "l", ")", "-", "1", ":", "u", "=", "l", "[", "i", "]", ".", "union", "(", "l", "[", "i", "+", "1", "]", ")",...
2c775c846d2491678a9637daa320592e02c26c72
valid
remove_contained_in_list
Sorts list in place, then removes any intervals that are completely contained inside another interval
pyfastaq/intervals.py
def remove_contained_in_list(l): '''Sorts list in place, then removes any intervals that are completely contained inside another interval''' i = 0 l.sort() while i < len(l) - 1: if l[i+1].contains(l[i]): l.pop(i) elif l[i].contains(l[i+1]): l.pop(i+1) e...
def remove_contained_in_list(l): '''Sorts list in place, then removes any intervals that are completely contained inside another interval''' i = 0 l.sort() while i < len(l) - 1: if l[i+1].contains(l[i]): l.pop(i) elif l[i].contains(l[i+1]): l.pop(i+1) e...
[ "Sorts", "list", "in", "place", "then", "removes", "any", "intervals", "that", "are", "completely", "contained", "inside", "another", "interval" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L107-L119
[ "def", "remove_contained_in_list", "(", "l", ")", ":", "i", "=", "0", "l", ".", "sort", "(", ")", "while", "i", "<", "len", "(", "l", ")", "-", "1", ":", "if", "l", "[", "i", "+", "1", "]", ".", "contains", "(", "l", "[", "i", "]", ")", "...
2c775c846d2491678a9637daa320592e02c26c72
valid
Interval.distance_to_point
Returns the distance from the point to the interval. Zero if the point lies inside the interval.
pyfastaq/intervals.py
def distance_to_point(self, p): '''Returns the distance from the point to the interval. Zero if the point lies inside the interval.''' if self.start <= p <= self.end: return 0 else: return min(abs(self.start - p), abs(self.end - p))
def distance_to_point(self, p): '''Returns the distance from the point to the interval. Zero if the point lies inside the interval.''' if self.start <= p <= self.end: return 0 else: return min(abs(self.start - p), abs(self.end - p))
[ "Returns", "the", "distance", "from", "the", "point", "to", "the", "interval", ".", "Zero", "if", "the", "point", "lies", "inside", "the", "interval", "." ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L34-L39
[ "def", "distance_to_point", "(", "self", ",", "p", ")", ":", "if", "self", ".", "start", "<=", "p", "<=", "self", ".", "end", ":", "return", "0", "else", ":", "return", "min", "(", "abs", "(", "self", ".", "start", "-", "p", ")", ",", "abs", "(...
2c775c846d2491678a9637daa320592e02c26c72
valid
Interval.intersects
Returns true iff this interval intersects the interval i
pyfastaq/intervals.py
def intersects(self, i): '''Returns true iff this interval intersects the interval i''' return self.start <= i.end and i.start <= self.end
def intersects(self, i): '''Returns true iff this interval intersects the interval i''' return self.start <= i.end and i.start <= self.end
[ "Returns", "true", "iff", "this", "interval", "intersects", "the", "interval", "i" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L41-L43
[ "def", "intersects", "(", "self", ",", "i", ")", ":", "return", "self", ".", "start", "<=", "i", ".", "end", "and", "i", ".", "start", "<=", "self", ".", "end" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Interval.contains
Returns true iff this interval contains the interval i
pyfastaq/intervals.py
def contains(self, i): '''Returns true iff this interval contains the interval i''' return self.start <= i.start and i.end <= self.end
def contains(self, i): '''Returns true iff this interval contains the interval i''' return self.start <= i.start and i.end <= self.end
[ "Returns", "true", "iff", "this", "interval", "contains", "the", "interval", "i" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L45-L47
[ "def", "contains", "(", "self", ",", "i", ")", ":", "return", "self", ".", "start", "<=", "i", ".", "start", "and", "i", ".", "end", "<=", "self", ".", "end" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Interval.union
If intervals intersect, returns their union, otherwise returns None
pyfastaq/intervals.py
def union(self, i): '''If intervals intersect, returns their union, otherwise returns None''' if self.intersects(i) or self.end + 1 == i.start or i.end + 1 == self.start: return Interval(min(self.start, i.start), max(self.end, i.end)) else: return None
def union(self, i): '''If intervals intersect, returns their union, otherwise returns None''' if self.intersects(i) or self.end + 1 == i.start or i.end + 1 == self.start: return Interval(min(self.start, i.start), max(self.end, i.end)) else: return None
[ "If", "intervals", "intersect", "returns", "their", "union", "otherwise", "returns", "None" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L49-L54
[ "def", "union", "(", "self", ",", "i", ")", ":", "if", "self", ".", "intersects", "(", "i", ")", "or", "self", ".", "end", "+", "1", "==", "i", ".", "start", "or", "i", ".", "end", "+", "1", "==", "self", ".", "start", ":", "return", "Interva...
2c775c846d2491678a9637daa320592e02c26c72
valid
Interval.union_fill_gap
Like union, but ignores whether the two intervals intersect or not
pyfastaq/intervals.py
def union_fill_gap(self, i): '''Like union, but ignores whether the two intervals intersect or not''' return Interval(min(self.start, i.start), max(self.end, i.end))
def union_fill_gap(self, i): '''Like union, but ignores whether the two intervals intersect or not''' return Interval(min(self.start, i.start), max(self.end, i.end))
[ "Like", "union", "but", "ignores", "whether", "the", "two", "intervals", "intersect", "or", "not" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L56-L58
[ "def", "union_fill_gap", "(", "self", ",", "i", ")", ":", "return", "Interval", "(", "min", "(", "self", ".", "start", ",", "i", ".", "start", ")", ",", "max", "(", "self", ".", "end", ",", "i", ".", "end", ")", ")" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Interval.intersection
If intervals intersect, returns their intersection, otherwise returns None
pyfastaq/intervals.py
def intersection(self, i): '''If intervals intersect, returns their intersection, otherwise returns None''' if self.intersects(i): return Interval(max(self.start, i.start), min(self.end, i.end)) else: return None
def intersection(self, i): '''If intervals intersect, returns their intersection, otherwise returns None''' if self.intersects(i): return Interval(max(self.start, i.start), min(self.end, i.end)) else: return None
[ "If", "intervals", "intersect", "returns", "their", "intersection", "otherwise", "returns", "None" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/intervals.py#L60-L65
[ "def", "intersection", "(", "self", ",", "i", ")", ":", "if", "self", ".", "intersects", "(", "i", ")", ":", "return", "Interval", "(", "max", "(", "self", ".", "start", ",", "i", ".", "start", ")", ",", "min", "(", "self", ".", "end", ",", "i"...
2c775c846d2491678a9637daa320592e02c26c72
valid
file_reader
Iterates over a FASTA or FASTQ file, yielding the next sequence in the file until there are no more sequences
pyfastaq/sequences.py
def file_reader(fname, read_quals=False): '''Iterates over a FASTA or FASTQ file, yielding the next sequence in the file until there are no more sequences''' f = utils.open_file_read(fname) line = f.readline() phylip_regex = re.compile('^\s*[0-9]+\s+[0-9]+$') gbk_regex = re.compile('^LOCUS\s+\S') ...
def file_reader(fname, read_quals=False): '''Iterates over a FASTA or FASTQ file, yielding the next sequence in the file until there are no more sequences''' f = utils.open_file_read(fname) line = f.readline() phylip_regex = re.compile('^\s*[0-9]+\s+[0-9]+$') gbk_regex = re.compile('^LOCUS\s+\S') ...
[ "Iterates", "over", "a", "FASTA", "or", "FASTQ", "file", "yielding", "the", "next", "sequence", "in", "the", "file", "until", "there", "are", "no", "more", "sequences" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L33-L147
[ "def", "file_reader", "(", "fname", ",", "read_quals", "=", "False", ")", ":", "f", "=", "utils", ".", "open_file_read", "(", "fname", ")", "line", "=", "f", ".", "readline", "(", ")", "phylip_regex", "=", "re", ".", "compile", "(", "'^\\s*[0-9]+\\s+[0-9...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.subseq
Returns Fasta object with the same name, of the bases from start to end, but not including end
pyfastaq/sequences.py
def subseq(self, start, end): '''Returns Fasta object with the same name, of the bases from start to end, but not including end''' return Fasta(self.id, self.seq[start:end])
def subseq(self, start, end): '''Returns Fasta object with the same name, of the bases from start to end, but not including end''' return Fasta(self.id, self.seq[start:end])
[ "Returns", "Fasta", "object", "with", "the", "same", "name", "of", "the", "bases", "from", "start", "to", "end", "but", "not", "including", "end" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L175-L177
[ "def", "subseq", "(", "self", ",", "start", ",", "end", ")", ":", "return", "Fasta", "(", "self", ".", "id", ",", "self", ".", "seq", "[", "start", ":", "end", "]", ")" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.split_capillary_id
Gets the prefix and suffix of an name of a capillary read, e.g. xxxxx.p1k or xxxx.q1k. Returns a tuple (prefix, suffx)
pyfastaq/sequences.py
def split_capillary_id(self): '''Gets the prefix and suffix of an name of a capillary read, e.g. xxxxx.p1k or xxxx.q1k. Returns a tuple (prefix, suffx)''' try: a = self.id.rsplit('.', 1) if a[1].startswith('p'): dir = 'fwd' elif a[1].startswith('q'): ...
def split_capillary_id(self): '''Gets the prefix and suffix of an name of a capillary read, e.g. xxxxx.p1k or xxxx.q1k. Returns a tuple (prefix, suffx)''' try: a = self.id.rsplit('.', 1) if a[1].startswith('p'): dir = 'fwd' elif a[1].startswith('q'): ...
[ "Gets", "the", "prefix", "and", "suffix", "of", "an", "name", "of", "a", "capillary", "read", "e", ".", "g", ".", "xxxxx", ".", "p1k", "or", "xxxx", ".", "q1k", ".", "Returns", "a", "tuple", "(", "prefix", "suffx", ")" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L179-L192
[ "def", "split_capillary_id", "(", "self", ")", ":", "try", ":", "a", "=", "self", ".", "id", ".", "rsplit", "(", "'.'", ",", "1", ")", "if", "a", "[", "1", "]", ".", "startswith", "(", "'p'", ")", ":", "dir", "=", "'fwd'", "elif", "a", "[", "...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.expand_nucleotides
Assumes sequence is nucleotides. Returns list of all combinations of redundant nucleotides. e.g. R is A or G, so CRT would have combinations CAT and CGT
pyfastaq/sequences.py
def expand_nucleotides(self): '''Assumes sequence is nucleotides. Returns list of all combinations of redundant nucleotides. e.g. R is A or G, so CRT would have combinations CAT and CGT''' s = list(self.seq) for i in range(len(s)): if s[i] in redundant_nts: s[i] = ''....
def expand_nucleotides(self): '''Assumes sequence is nucleotides. Returns list of all combinations of redundant nucleotides. e.g. R is A or G, so CRT would have combinations CAT and CGT''' s = list(self.seq) for i in range(len(s)): if s[i] in redundant_nts: s[i] = ''....
[ "Assumes", "sequence", "is", "nucleotides", ".", "Returns", "list", "of", "all", "combinations", "of", "redundant", "nucleotides", ".", "e", ".", "g", ".", "R", "is", "A", "or", "G", "so", "CRT", "would", "have", "combinations", "CAT", "and", "CGT" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L194-L204
[ "def", "expand_nucleotides", "(", "self", ")", ":", "s", "=", "list", "(", "self", ".", "seq", ")", "for", "i", "in", "range", "(", "len", "(", "s", ")", ")", ":", "if", "s", "[", "i", "]", "in", "redundant_nts", ":", "s", "[", "i", "]", "=",...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.strip_illumina_suffix
Removes any trailing /1 or /2 off the end of the name
pyfastaq/sequences.py
def strip_illumina_suffix(self): '''Removes any trailing /1 or /2 off the end of the name''' if self.id.endswith('/1') or self.id.endswith('/2'): self.id = self.id[:-2]
def strip_illumina_suffix(self): '''Removes any trailing /1 or /2 off the end of the name''' if self.id.endswith('/1') or self.id.endswith('/2'): self.id = self.id[:-2]
[ "Removes", "any", "trailing", "/", "1", "or", "/", "2", "off", "the", "end", "of", "the", "name" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L210-L213
[ "def", "strip_illumina_suffix", "(", "self", ")", ":", "if", "self", ".", "id", ".", "endswith", "(", "'/1'", ")", "or", "self", ".", "id", ".", "endswith", "(", "'/2'", ")", ":", "self", ".", "id", "=", "self", ".", "id", "[", ":", "-", "2", "...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.is_all_Ns
Returns true if the sequence is all Ns (upper or lower case)
pyfastaq/sequences.py
def is_all_Ns(self, start=0, end=None): '''Returns true if the sequence is all Ns (upper or lower case)''' if end is not None: if start > end: raise Error('Error in is_all_Ns. Start coord must be <= end coord') end += 1 else: end = len(self) ...
def is_all_Ns(self, start=0, end=None): '''Returns true if the sequence is all Ns (upper or lower case)''' if end is not None: if start > end: raise Error('Error in is_all_Ns. Start coord must be <= end coord') end += 1 else: end = len(self) ...
[ "Returns", "true", "if", "the", "sequence", "is", "all", "Ns", "(", "upper", "or", "lower", "case", ")" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L219-L231
[ "def", "is_all_Ns", "(", "self", ",", "start", "=", "0", ",", "end", "=", "None", ")", ":", "if", "end", "is", "not", "None", ":", "if", "start", ">", "end", ":", "raise", "Error", "(", "'Error in is_all_Ns. Start coord must be <= end coord'", ")", "end", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.add_insertions
Adds a random base within window bases around every skip bases. e.g. skip=10, window=1 means a random base added somwhere in theintervals [9,11], [19,21] ...
pyfastaq/sequences.py
def add_insertions(self, skip=10, window=1, test=False): '''Adds a random base within window bases around every skip bases. e.g. skip=10, window=1 means a random base added somwhere in theintervals [9,11], [19,21] ... ''' assert 2 * window < skip new_seq = list(self.seq) for i in range(l...
def add_insertions(self, skip=10, window=1, test=False): '''Adds a random base within window bases around every skip bases. e.g. skip=10, window=1 means a random base added somwhere in theintervals [9,11], [19,21] ... ''' assert 2 * window < skip new_seq = list(self.seq) for i in range(l...
[ "Adds", "a", "random", "base", "within", "window", "bases", "around", "every", "skip", "bases", ".", "e", ".", "g", ".", "skip", "=", "10", "window", "=", "1", "means", "a", "random", "base", "added", "somwhere", "in", "theintervals", "[", "9", "11", ...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L237-L248
[ "def", "add_insertions", "(", "self", ",", "skip", "=", "10", ",", "window", "=", "1", ",", "test", "=", "False", ")", ":", "assert", "2", "*", "window", "<", "skip", "new_seq", "=", "list", "(", "self", ".", "seq", ")", "for", "i", "in", "range"...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.replace_bases
Replaces all occurrences of 'old' with 'new'
pyfastaq/sequences.py
def replace_bases(self, old, new): '''Replaces all occurrences of 'old' with 'new' ''' self.seq = self.seq.replace(old, new)
def replace_bases(self, old, new): '''Replaces all occurrences of 'old' with 'new' ''' self.seq = self.seq.replace(old, new)
[ "Replaces", "all", "occurrences", "of", "old", "with", "new" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L250-L252
[ "def", "replace_bases", "(", "self", ",", "old", ",", "new", ")", ":", "self", ".", "seq", "=", "self", ".", "seq", ".", "replace", "(", "old", ",", "new", ")" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.replace_interval
Replaces the sequence from start to end with the sequence "new"
pyfastaq/sequences.py
def replace_interval(self, start, end, new): '''Replaces the sequence from start to end with the sequence "new"''' if start > end or start > len(self) - 1 or end > len(self) - 1: raise Error('Error replacing bases ' + str(start) + '-' + str(end) + ' in sequence ' + self.id) self.seq...
def replace_interval(self, start, end, new): '''Replaces the sequence from start to end with the sequence "new"''' if start > end or start > len(self) - 1 or end > len(self) - 1: raise Error('Error replacing bases ' + str(start) + '-' + str(end) + ' in sequence ' + self.id) self.seq...
[ "Replaces", "the", "sequence", "from", "start", "to", "end", "with", "the", "sequence", "new" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L260-L265
[ "def", "replace_interval", "(", "self", ",", "start", ",", "end", ",", "new", ")", ":", "if", "start", ">", "end", "or", "start", ">", "len", "(", "self", ")", "-", "1", "or", "end", ">", "len", "(", "self", ")", "-", "1", ":", "raise", "Error"...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.gaps
Finds the positions of all gaps in the sequence that are at least min_length long. Returns a list of Intervals. Coords are zero-based
pyfastaq/sequences.py
def gaps(self, min_length = 1): '''Finds the positions of all gaps in the sequence that are at least min_length long. Returns a list of Intervals. Coords are zero-based''' gaps = [] regex = re.compile('N+', re.IGNORECASE) for m in regex.finditer(self.seq): if m.span()[1] - m...
def gaps(self, min_length = 1): '''Finds the positions of all gaps in the sequence that are at least min_length long. Returns a list of Intervals. Coords are zero-based''' gaps = [] regex = re.compile('N+', re.IGNORECASE) for m in regex.finditer(self.seq): if m.span()[1] - m...
[ "Finds", "the", "positions", "of", "all", "gaps", "in", "the", "sequence", "that", "are", "at", "least", "min_length", "long", ".", "Returns", "a", "list", "of", "Intervals", ".", "Coords", "are", "zero", "-", "based" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L267-L274
[ "def", "gaps", "(", "self", ",", "min_length", "=", "1", ")", ":", "gaps", "=", "[", "]", "regex", "=", "re", ".", "compile", "(", "'N+'", ",", "re", ".", "IGNORECASE", ")", "for", "m", "in", "regex", ".", "finditer", "(", "self", ".", "seq", "...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.contig_coords
Finds coords of contigs, i.e. everything that's not a gap (N or n). Returns a list of Intervals. Coords are zero-based
pyfastaq/sequences.py
def contig_coords(self): '''Finds coords of contigs, i.e. everything that's not a gap (N or n). Returns a list of Intervals. Coords are zero-based''' # contigs are the opposite of gaps, so work out the coords from the gap coords gaps = self.gaps() if len(gaps) == 0: return [...
def contig_coords(self): '''Finds coords of contigs, i.e. everything that's not a gap (N or n). Returns a list of Intervals. Coords are zero-based''' # contigs are the opposite of gaps, so work out the coords from the gap coords gaps = self.gaps() if len(gaps) == 0: return [...
[ "Finds", "coords", "of", "contigs", "i", ".", "e", ".", "everything", "that", "s", "not", "a", "gap", "(", "N", "or", "n", ")", ".", "Returns", "a", "list", "of", "Intervals", ".", "Coords", "are", "zero", "-", "based" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L276-L294
[ "def", "contig_coords", "(", "self", ")", ":", "# contigs are the opposite of gaps, so work out the coords from the gap coords", "gaps", "=", "self", ".", "gaps", "(", ")", "if", "len", "(", "gaps", ")", "==", "0", ":", "return", "[", "intervals", ".", "Interval",...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.orfs
Returns a list of ORFs that the sequence has, starting on the given frame. Each returned ORF is an interval.Interval object. If revomp=True, then finds the ORFs of the reverse complement of the sequence.
pyfastaq/sequences.py
def orfs(self, frame=0, revcomp=False): '''Returns a list of ORFs that the sequence has, starting on the given frame. Each returned ORF is an interval.Interval object. If revomp=True, then finds the ORFs of the reverse complement of the sequence.''' assert frame in [0,1,...
def orfs(self, frame=0, revcomp=False): '''Returns a list of ORFs that the sequence has, starting on the given frame. Each returned ORF is an interval.Interval object. If revomp=True, then finds the ORFs of the reverse complement of the sequence.''' assert frame in [0,1,...
[ "Returns", "a", "list", "of", "ORFs", "that", "the", "sequence", "has", "starting", "on", "the", "given", "frame", ".", "Each", "returned", "ORF", "is", "an", "interval", ".", "Interval", "object", ".", "If", "revomp", "=", "True", "then", "finds", "the"...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L297-L321
[ "def", "orfs", "(", "self", ",", "frame", "=", "0", ",", "revcomp", "=", "False", ")", ":", "assert", "frame", "in", "[", "0", ",", "1", ",", "2", "]", "if", "revcomp", ":", "self", ".", "revcomp", "(", ")", "aa_seq", "=", "self", ".", "transla...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.all_orfs
Finds all open reading frames in the sequence, that are at least as long as min_length. Includes ORFs on the reverse strand. Returns a list of ORFs, where each element is a tuple: (interval.Interval, bool) where bool=True means on the reverse strand
pyfastaq/sequences.py
def all_orfs(self, min_length=300): '''Finds all open reading frames in the sequence, that are at least as long as min_length. Includes ORFs on the reverse strand. Returns a list of ORFs, where each element is a tuple: (interval.Interval, bool) where bool=True means o...
def all_orfs(self, min_length=300): '''Finds all open reading frames in the sequence, that are at least as long as min_length. Includes ORFs on the reverse strand. Returns a list of ORFs, where each element is a tuple: (interval.Interval, bool) where bool=True means o...
[ "Finds", "all", "open", "reading", "frames", "in", "the", "sequence", "that", "are", "at", "least", "as", "long", "as", "min_length", ".", "Includes", "ORFs", "on", "the", "reverse", "strand", ".", "Returns", "a", "list", "of", "ORFs", "where", "each", "...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L324-L335
[ "def", "all_orfs", "(", "self", ",", "min_length", "=", "300", ")", ":", "orfs", "=", "[", "]", "for", "frame", "in", "[", "0", ",", "1", ",", "2", "]", ":", "for", "revcomp", "in", "[", "False", ",", "True", "]", ":", "orfs", ".", "extend", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.is_complete_orf
Returns true iff length is >= 6, is a multiple of 3, and there is exactly one stop codon in the sequence and it is at the end
pyfastaq/sequences.py
def is_complete_orf(self): '''Returns true iff length is >= 6, is a multiple of 3, and there is exactly one stop codon in the sequence and it is at the end''' if len(self) %3 != 0 or len(self) < 6: return False orfs = self.orfs() complete_orf = intervals.Interval(0, len(self...
def is_complete_orf(self): '''Returns true iff length is >= 6, is a multiple of 3, and there is exactly one stop codon in the sequence and it is at the end''' if len(self) %3 != 0 or len(self) < 6: return False orfs = self.orfs() complete_orf = intervals.Interval(0, len(self...
[ "Returns", "true", "iff", "length", "is", ">", "=", "6", "is", "a", "multiple", "of", "3", "and", "there", "is", "exactly", "one", "stop", "codon", "in", "the", "sequence", "and", "it", "is", "at", "the", "end" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L338-L348
[ "def", "is_complete_orf", "(", "self", ")", ":", "if", "len", "(", "self", ")", "%", "3", "!=", "0", "or", "len", "(", "self", ")", "<", "6", ":", "return", "False", "orfs", "=", "self", ".", "orfs", "(", ")", "complete_orf", "=", "intervals", "....
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.looks_like_gene
Returns true iff: length >=6, length is a multiple of 3, first codon is start, last codon is a stop and has no other stop codons
pyfastaq/sequences.py
def looks_like_gene(self): '''Returns true iff: length >=6, length is a multiple of 3, first codon is start, last codon is a stop and has no other stop codons''' return self.is_complete_orf() \ and len(self) >= 6 \ and len(self) %3 == 0 \ and self.seq[0:3].upper() in geneti...
def looks_like_gene(self): '''Returns true iff: length >=6, length is a multiple of 3, first codon is start, last codon is a stop and has no other stop codons''' return self.is_complete_orf() \ and len(self) >= 6 \ and len(self) %3 == 0 \ and self.seq[0:3].upper() in geneti...
[ "Returns", "true", "iff", ":", "length", ">", "=", "6", "length", "is", "a", "multiple", "of", "3", "first", "codon", "is", "start", "last", "codon", "is", "a", "stop", "and", "has", "no", "other", "stop", "codons" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L351-L356
[ "def", "looks_like_gene", "(", "self", ")", ":", "return", "self", ".", "is_complete_orf", "(", ")", "and", "len", "(", "self", ")", ">=", "6", "and", "len", "(", "self", ")", "%", "3", "==", "0", "and", "self", ".", "seq", "[", "0", ":", "3", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.make_into_gene
Tries to make into a gene sequence. Tries all three reading frames and both strands. Returns a tuple (new sequence, strand, frame) if it was successful. Otherwise returns None.
pyfastaq/sequences.py
def make_into_gene(self): '''Tries to make into a gene sequence. Tries all three reading frames and both strands. Returns a tuple (new sequence, strand, frame) if it was successful. Otherwise returns None.''' for reverse in [True, False]: for frame in range(3): new_seq = copy...
def make_into_gene(self): '''Tries to make into a gene sequence. Tries all three reading frames and both strands. Returns a tuple (new sequence, strand, frame) if it was successful. Otherwise returns None.''' for reverse in [True, False]: for frame in range(3): new_seq = copy...
[ "Tries", "to", "make", "into", "a", "gene", "sequence", ".", "Tries", "all", "three", "reading", "frames", "and", "both", "strands", ".", "Returns", "a", "tuple", "(", "new", "sequence", "strand", "frame", ")", "if", "it", "was", "successful", ".", "Othe...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L359-L375
[ "def", "make_into_gene", "(", "self", ")", ":", "for", "reverse", "in", "[", "True", ",", "False", "]", ":", "for", "frame", "in", "range", "(", "3", ")", ":", "new_seq", "=", "copy", ".", "copy", "(", "self", ")", "if", "reverse", ":", "new_seq", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.trim
Removes first 'start'/'end' bases off the start/end of the sequence
pyfastaq/sequences.py
def trim(self, start, end): '''Removes first 'start'/'end' bases off the start/end of the sequence''' self.seq = self.seq[start:len(self.seq) - end]
def trim(self, start, end): '''Removes first 'start'/'end' bases off the start/end of the sequence''' self.seq = self.seq[start:len(self.seq) - end]
[ "Removes", "first", "start", "/", "end", "bases", "off", "the", "start", "/", "end", "of", "the", "sequence" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L425-L427
[ "def", "trim", "(", "self", ",", "start", ",", "end", ")", ":", "self", ".", "seq", "=", "self", ".", "seq", "[", "start", ":", "len", "(", "self", ".", "seq", ")", "-", "end", "]" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.to_Fastq
Returns a Fastq object. qual_scores expected to be a list of numbers, like you would get in a .qual file
pyfastaq/sequences.py
def to_Fastq(self, qual_scores): '''Returns a Fastq object. qual_scores expected to be a list of numbers, like you would get in a .qual file''' if len(self) != len(qual_scores): raise Error('Error making Fastq from Fasta, lengths differ.', self.id) return Fastq(self.id, self.seq, ''....
def to_Fastq(self, qual_scores): '''Returns a Fastq object. qual_scores expected to be a list of numbers, like you would get in a .qual file''' if len(self) != len(qual_scores): raise Error('Error making Fastq from Fasta, lengths differ.', self.id) return Fastq(self.id, self.seq, ''....
[ "Returns", "a", "Fastq", "object", ".", "qual_scores", "expected", "to", "be", "a", "list", "of", "numbers", "like", "you", "would", "get", "in", "a", ".", "qual", "file" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L430-L434
[ "def", "to_Fastq", "(", "self", ",", "qual_scores", ")", ":", "if", "len", "(", "self", ")", "!=", "len", "(", "qual_scores", ")", ":", "raise", "Error", "(", "'Error making Fastq from Fasta, lengths differ.'", ",", "self", ".", "id", ")", "return", "Fastq",...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.search
Finds every occurrence (including overlapping ones) of the search_string, including on the reverse strand. Returns a list where each element is a tuple (position, strand) where strand is in ['-', '+']. Positions are zero-based
pyfastaq/sequences.py
def search(self, search_string): '''Finds every occurrence (including overlapping ones) of the search_string, including on the reverse strand. Returns a list where each element is a tuple (position, strand) where strand is in ['-', '+']. Positions are zero-based''' seq = self.seq.upper() search_...
def search(self, search_string): '''Finds every occurrence (including overlapping ones) of the search_string, including on the reverse strand. Returns a list where each element is a tuple (position, strand) where strand is in ['-', '+']. Positions are zero-based''' seq = self.seq.upper() search_...
[ "Finds", "every", "occurrence", "(", "including", "overlapping", "ones", ")", "of", "the", "search_string", "including", "on", "the", "reverse", "strand", ".", "Returns", "a", "list", "where", "each", "element", "is", "a", "tuple", "(", "position", "strand", ...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L436-L461
[ "def", "search", "(", "self", ",", "search_string", ")", ":", "seq", "=", "self", ".", "seq", ".", "upper", "(", ")", "search_string", "=", "search_string", ".", "upper", "(", ")", "pos", "=", "0", "found", "=", "seq", ".", "find", "(", "search_strin...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.translate
Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2
pyfastaq/sequences.py
def translate(self, frame=0): '''Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2''' return Fasta(self.id, ''.join([genetic_codes.codes[genetic_code].get(self.seq[x:x+3].upper(), 'X') for x in range(frame, len(self)-1-frame, 3)])...
def translate(self, frame=0): '''Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2''' return Fasta(self.id, ''.join([genetic_codes.codes[genetic_code].get(self.seq[x:x+3].upper(), 'X') for x in range(frame, len(self)-1-frame, 3)])...
[ "Returns", "a", "Fasta", "sequence", "translated", "into", "amino", "acids", ".", "Starts", "translating", "from", "frame", "where", "frame", "expected", "to", "be", "0", "1", "or", "2" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L463-L465
[ "def", "translate", "(", "self", ",", "frame", "=", "0", ")", ":", "return", "Fasta", "(", "self", ".", "id", ",", "''", ".", "join", "(", "[", "genetic_codes", ".", "codes", "[", "genetic_code", "]", ".", "get", "(", "self", ".", "seq", "[", "x"...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fasta.gc_content
Returns the GC content for the sequence. Notes: This method ignores N when calculating the length of the sequence. It does not, however ignore other ambiguous bases. It also only includes the ambiguous base S (G or C). In this sense the method is conservative with...
pyfastaq/sequences.py
def gc_content(self, as_decimal=True): """Returns the GC content for the sequence. Notes: This method ignores N when calculating the length of the sequence. It does not, however ignore other ambiguous bases. It also only includes the ambiguous base S (G or C). In this...
def gc_content(self, as_decimal=True): """Returns the GC content for the sequence. Notes: This method ignores N when calculating the length of the sequence. It does not, however ignore other ambiguous bases. It also only includes the ambiguous base S (G or C). In this...
[ "Returns", "the", "GC", "content", "for", "the", "sequence", ".", "Notes", ":", "This", "method", "ignores", "N", "when", "calculating", "the", "length", "of", "the", "sequence", ".", "It", "does", "not", "however", "ignore", "other", "ambiguous", "bases", ...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L467-L505
[ "def", "gc_content", "(", "self", ",", "as_decimal", "=", "True", ")", ":", "gc_total", "=", "0.0", "num_bases", "=", "0.0", "n_tuple", "=", "tuple", "(", "'nN'", ")", "accepted_bases", "=", "tuple", "(", "'cCgGsS'", ")", "# counter sums all unique characters ...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fastq.subseq
Returns Fastq object with the same name, of the bases from start to end, but not including end
pyfastaq/sequences.py
def subseq(self, start, end): '''Returns Fastq object with the same name, of the bases from start to end, but not including end''' return Fastq(self.id, self.seq[start:end], self.qual[start:end])
def subseq(self, start, end): '''Returns Fastq object with the same name, of the bases from start to end, but not including end''' return Fastq(self.id, self.seq[start:end], self.qual[start:end])
[ "Returns", "Fastq", "object", "with", "the", "same", "name", "of", "the", "bases", "from", "start", "to", "end", "but", "not", "including", "end" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L580-L582
[ "def", "subseq", "(", "self", ",", "start", ",", "end", ")", ":", "return", "Fastq", "(", "self", ".", "id", ",", "self", ".", "seq", "[", "start", ":", "end", "]", ",", "self", ".", "qual", "[", "start", ":", "end", "]", ")" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
Fastq.trim
Removes first 'start'/'end' bases off the start/end of the sequence
pyfastaq/sequences.py
def trim(self, start, end): '''Removes first 'start'/'end' bases off the start/end of the sequence''' super().trim(start, end) self.qual = self.qual[start:len(self.qual) - end]
def trim(self, start, end): '''Removes first 'start'/'end' bases off the start/end of the sequence''' super().trim(start, end) self.qual = self.qual[start:len(self.qual) - end]
[ "Removes", "first", "start", "/", "end", "bases", "off", "the", "start", "/", "end", "of", "the", "sequence" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L624-L627
[ "def", "trim", "(", "self", ",", "start", ",", "end", ")", ":", "super", "(", ")", ".", "trim", "(", "start", ",", "end", ")", "self", ".", "qual", "=", "self", ".", "qual", "[", "start", ":", "len", "(", "self", ".", "qual", ")", "-", "end",...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fastq.trim_Ns
Removes any leading or trailing N or n characters from the sequence
pyfastaq/sequences.py
def trim_Ns(self): '''Removes any leading or trailing N or n characters from the sequence''' # get index of first base that is not an N i = 0 while i < len(self) and self.seq[i] in 'nN': i += 1 # strip off start of sequence and quality self.seq = self.seq[i:]...
def trim_Ns(self): '''Removes any leading or trailing N or n characters from the sequence''' # get index of first base that is not an N i = 0 while i < len(self) and self.seq[i] in 'nN': i += 1 # strip off start of sequence and quality self.seq = self.seq[i:]...
[ "Removes", "any", "leading", "or", "trailing", "N", "or", "n", "characters", "from", "the", "sequence" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L636-L649
[ "def", "trim_Ns", "(", "self", ")", ":", "# get index of first base that is not an N", "i", "=", "0", "while", "i", "<", "len", "(", "self", ")", "and", "self", ".", "seq", "[", "i", "]", "in", "'nN'", ":", "i", "+=", "1", "# strip off start of sequence an...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fastq.replace_interval
Replaces the sequence from start to end with the sequence "new"
pyfastaq/sequences.py
def replace_interval(self, start, end, new, qual_string): '''Replaces the sequence from start to end with the sequence "new"''' if len(new) != len(qual_string): raise Error('Length of new seq and qual string in replace_interval() must be equal. Cannot continue') super().replace_inter...
def replace_interval(self, start, end, new, qual_string): '''Replaces the sequence from start to end with the sequence "new"''' if len(new) != len(qual_string): raise Error('Length of new seq and qual string in replace_interval() must be equal. Cannot continue') super().replace_inter...
[ "Replaces", "the", "sequence", "from", "start", "to", "end", "with", "the", "sequence", "new" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L651-L656
[ "def", "replace_interval", "(", "self", ",", "start", ",", "end", ",", "new", ",", "qual_string", ")", ":", "if", "len", "(", "new", ")", "!=", "len", "(", "qual_string", ")", ":", "raise", "Error", "(", "'Length of new seq and qual string in replace_interval(...
2c775c846d2491678a9637daa320592e02c26c72
valid
Fastq.translate
Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2
pyfastaq/sequences.py
def translate(self): '''Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2''' fa = super().translate() return Fastq(fa.id, fa.seq, 'I'*len(fa.seq))
def translate(self): '''Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2''' fa = super().translate() return Fastq(fa.id, fa.seq, 'I'*len(fa.seq))
[ "Returns", "a", "Fasta", "sequence", "translated", "into", "amino", "acids", ".", "Starts", "translating", "from", "frame", "where", "frame", "expected", "to", "be", "0", "1", "or", "2" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/sequences.py#L658-L661
[ "def", "translate", "(", "self", ")", ":", "fa", "=", "super", "(", ")", ".", "translate", "(", ")", "return", "Fastq", "(", "fa", ".", "id", ",", "fa", ".", "seq", ",", "'I'", "*", "len", "(", "fa", ".", "seq", ")", ")" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
acgtn_only
Replace every non-acgtn (case insensitve) character with an N
pyfastaq/tasks.py
def acgtn_only(infile, outfile): '''Replace every non-acgtn (case insensitve) character with an N''' f = utils.open_file_write(outfile) for seq in sequences.file_reader(infile): seq.replace_non_acgt() print(seq, file=f) utils.close(f)
def acgtn_only(infile, outfile): '''Replace every non-acgtn (case insensitve) character with an N''' f = utils.open_file_write(outfile) for seq in sequences.file_reader(infile): seq.replace_non_acgt() print(seq, file=f) utils.close(f)
[ "Replace", "every", "non", "-", "acgtn", "(", "case", "insensitve", ")", "character", "with", "an", "N" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L9-L15
[ "def", "acgtn_only", "(", "infile", ",", "outfile", ")", ":", "f", "=", "utils", ".", "open_file_write", "(", "outfile", ")", "for", "seq", "in", "sequences", ".", "file_reader", "(", "infile", ")", ":", "seq", ".", "replace_non_acgt", "(", ")", "print",...
2c775c846d2491678a9637daa320592e02c26c72
valid
caf_to_fastq
Convert a CAF file to fastq. Reads shorter than min_length are not output. If clipping information is in the CAF file (with a line Clipping QUAL ...) and trim=True, then trim the reads
pyfastaq/tasks.py
def caf_to_fastq(infile, outfile, min_length=0, trim=False): '''Convert a CAF file to fastq. Reads shorter than min_length are not output. If clipping information is in the CAF file (with a line Clipping QUAL ...) and trim=True, then trim the reads''' caf_reader = caf.file_reader(infile) fout = utils.open_f...
def caf_to_fastq(infile, outfile, min_length=0, trim=False): '''Convert a CAF file to fastq. Reads shorter than min_length are not output. If clipping information is in the CAF file (with a line Clipping QUAL ...) and trim=True, then trim the reads''' caf_reader = caf.file_reader(infile) fout = utils.open_f...
[ "Convert", "a", "CAF", "file", "to", "fastq", ".", "Reads", "shorter", "than", "min_length", "are", "not", "output", ".", "If", "clipping", "information", "is", "in", "the", "CAF", "file", "(", "with", "a", "line", "Clipping", "QUAL", "...", ")", "and", ...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L18-L35
[ "def", "caf_to_fastq", "(", "infile", ",", "outfile", ",", "min_length", "=", "0", ",", "trim", "=", "False", ")", ":", "caf_reader", "=", "caf", ".", "file_reader", "(", "infile", ")", "fout", "=", "utils", ".", "open_file_write", "(", "outfile", ")", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
count_sequences
Returns the number of sequences in a file
pyfastaq/tasks.py
def count_sequences(infile): '''Returns the number of sequences in a file''' seq_reader = sequences.file_reader(infile) n = 0 for seq in seq_reader: n += 1 return n
def count_sequences(infile): '''Returns the number of sequences in a file''' seq_reader = sequences.file_reader(infile) n = 0 for seq in seq_reader: n += 1 return n
[ "Returns", "the", "number", "of", "sequences", "in", "a", "file" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L84-L90
[ "def", "count_sequences", "(", "infile", ")", ":", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "n", "=", "0", "for", "seq", "in", "seq_reader", ":", "n", "+=", "1", "return", "n" ]
2c775c846d2491678a9637daa320592e02c26c72
valid
interleave
Makes interleaved file from two sequence files. If used, will append suffix1 onto end of every sequence name in infile_1, unless it already ends with suffix1. Similar for sufffix2.
pyfastaq/tasks.py
def interleave(infile_1, infile_2, outfile, suffix1=None, suffix2=None): '''Makes interleaved file from two sequence files. If used, will append suffix1 onto end of every sequence name in infile_1, unless it already ends with suffix1. Similar for sufffix2.''' seq_reader_1 = sequences.file_reader(infile_1) ...
def interleave(infile_1, infile_2, outfile, suffix1=None, suffix2=None): '''Makes interleaved file from two sequence files. If used, will append suffix1 onto end of every sequence name in infile_1, unless it already ends with suffix1. Similar for sufffix2.''' seq_reader_1 = sequences.file_reader(infile_1) ...
[ "Makes", "interleaved", "file", "from", "two", "sequence", "files", ".", "If", "used", "will", "append", "suffix1", "onto", "end", "of", "every", "sequence", "name", "in", "infile_1", "unless", "it", "already", "ends", "with", "suffix1", ".", "Similar", "for...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L375-L406
[ "def", "interleave", "(", "infile_1", ",", "infile_2", ",", "outfile", ",", "suffix1", "=", "None", ",", "suffix2", "=", "None", ")", ":", "seq_reader_1", "=", "sequences", ".", "file_reader", "(", "infile_1", ")", "seq_reader_2", "=", "sequences", ".", "f...
2c775c846d2491678a9637daa320592e02c26c72
valid
make_random_contigs
Makes a multi fasta file of random sequences, all the same length
pyfastaq/tasks.py
def make_random_contigs(contigs, length, outfile, name_by_letters=False, prefix='', seed=None, first_number=1): '''Makes a multi fasta file of random sequences, all the same length''' random.seed(a=seed) fout = utils.open_file_write(outfile) letters = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') letters_index...
def make_random_contigs(contigs, length, outfile, name_by_letters=False, prefix='', seed=None, first_number=1): '''Makes a multi fasta file of random sequences, all the same length''' random.seed(a=seed) fout = utils.open_file_write(outfile) letters = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') letters_index...
[ "Makes", "a", "multi", "fasta", "file", "of", "random", "sequences", "all", "the", "same", "length" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L409-L428
[ "def", "make_random_contigs", "(", "contigs", ",", "length", ",", "outfile", ",", "name_by_letters", "=", "False", ",", "prefix", "=", "''", ",", "seed", "=", "None", ",", "first_number", "=", "1", ")", ":", "random", ".", "seed", "(", "a", "=", "seed"...
2c775c846d2491678a9637daa320592e02c26c72
valid
mean_length
Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N
pyfastaq/tasks.py
def mean_length(infile, limit=None): '''Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N''' total = 0 count = 0 seq_reader = sequences.file_reader(infile) for seq in seq_reader: total += len(seq) ...
def mean_length(infile, limit=None): '''Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N''' total = 0 count = 0 seq_reader = sequences.file_reader(infile) for seq in seq_reader: total += len(seq) ...
[ "Returns", "the", "mean", "length", "of", "the", "sequences", "in", "the", "input", "file", ".", "By", "default", "uses", "all", "sequences", ".", "To", "limit", "to", "the", "first", "N", "sequences", "use", "limit", "=", "N" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L431-L443
[ "def", "mean_length", "(", "infile", ",", "limit", "=", "None", ")", ":", "total", "=", "0", "count", "=", "0", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "for", "seq", "in", "seq_reader", ":", "total", "+=", "len", "(", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
merge_to_one_seq
Takes a multi fasta or fastq file and writes a new file that contains just one sequence, with the original sequences catted together, preserving their order
pyfastaq/tasks.py
def merge_to_one_seq(infile, outfile, seqname='union'): '''Takes a multi fasta or fastq file and writes a new file that contains just one sequence, with the original sequences catted together, preserving their order''' seq_reader = sequences.file_reader(infile) seqs = [] for seq in seq_reader: ...
def merge_to_one_seq(infile, outfile, seqname='union'): '''Takes a multi fasta or fastq file and writes a new file that contains just one sequence, with the original sequences catted together, preserving their order''' seq_reader = sequences.file_reader(infile) seqs = [] for seq in seq_reader: ...
[ "Takes", "a", "multi", "fasta", "or", "fastq", "file", "and", "writes", "a", "new", "file", "that", "contains", "just", "one", "sequence", "with", "the", "original", "sequences", "catted", "together", "preserving", "their", "order" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L446-L466
[ "def", "merge_to_one_seq", "(", "infile", ",", "outfile", ",", "seqname", "=", "'union'", ")", ":", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "seqs", "=", "[", "]", "for", "seq", "in", "seq_reader", ":", "seqs", ".", "append...
2c775c846d2491678a9637daa320592e02c26c72
valid
scaffolds_to_contigs
Makes a file of contigs from scaffolds by splitting at every N. Use number_contigs=True to add .1, .2, etc onto end of each contig, instead of default to append coordinates.
pyfastaq/tasks.py
def scaffolds_to_contigs(infile, outfile, number_contigs=False): '''Makes a file of contigs from scaffolds by splitting at every N. Use number_contigs=True to add .1, .2, etc onto end of each contig, instead of default to append coordinates.''' seq_reader = sequences.file_reader(infile) fout =...
def scaffolds_to_contigs(infile, outfile, number_contigs=False): '''Makes a file of contigs from scaffolds by splitting at every N. Use number_contigs=True to add .1, .2, etc onto end of each contig, instead of default to append coordinates.''' seq_reader = sequences.file_reader(infile) fout =...
[ "Makes", "a", "file", "of", "contigs", "from", "scaffolds", "by", "splitting", "at", "every", "N", ".", "Use", "number_contigs", "=", "True", "to", "add", ".", "1", ".", "2", "etc", "onto", "end", "of", "each", "contig", "instead", "of", "default", "to...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L480-L498
[ "def", "scaffolds_to_contigs", "(", "infile", ",", "outfile", ",", "number_contigs", "=", "False", ")", ":", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "fout", "=", "utils", ".", "open_file_write", "(", "outfile", ")", "for", "se...
2c775c846d2491678a9637daa320592e02c26c72
valid
sort_by_size
Sorts input sequence file by biggest sequence first, writes sorted output file. Set smallest_first=True to have smallest first
pyfastaq/tasks.py
def sort_by_size(infile, outfile, smallest_first=False): '''Sorts input sequence file by biggest sequence first, writes sorted output file. Set smallest_first=True to have smallest first''' seqs = {} file_to_dict(infile, seqs) seqs = list(seqs.values()) seqs.sort(key=lambda x: len(x), reverse=not sm...
def sort_by_size(infile, outfile, smallest_first=False): '''Sorts input sequence file by biggest sequence first, writes sorted output file. Set smallest_first=True to have smallest first''' seqs = {} file_to_dict(infile, seqs) seqs = list(seqs.values()) seqs.sort(key=lambda x: len(x), reverse=not sm...
[ "Sorts", "input", "sequence", "file", "by", "biggest", "sequence", "first", "writes", "sorted", "output", "file", ".", "Set", "smallest_first", "=", "True", "to", "have", "smallest", "first" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L556-L565
[ "def", "sort_by_size", "(", "infile", ",", "outfile", ",", "smallest_first", "=", "False", ")", ":", "seqs", "=", "{", "}", "file_to_dict", "(", "infile", ",", "seqs", ")", "seqs", "=", "list", "(", "seqs", ".", "values", "(", ")", ")", "seqs", ".", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
sort_by_name
Sorts input sequence file by sort -d -k1,1, writes sorted output file.
pyfastaq/tasks.py
def sort_by_name(infile, outfile): '''Sorts input sequence file by sort -d -k1,1, writes sorted output file.''' seqs = {} file_to_dict(infile, seqs) #seqs = list(seqs.values()) #seqs.sort() fout = utils.open_file_write(outfile) for name in sorted(seqs): print(seqs[name], file=fout) ...
def sort_by_name(infile, outfile): '''Sorts input sequence file by sort -d -k1,1, writes sorted output file.''' seqs = {} file_to_dict(infile, seqs) #seqs = list(seqs.values()) #seqs.sort() fout = utils.open_file_write(outfile) for name in sorted(seqs): print(seqs[name], file=fout) ...
[ "Sorts", "input", "sequence", "file", "by", "sort", "-", "d", "-", "k1", "1", "writes", "sorted", "output", "file", "." ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L568-L577
[ "def", "sort_by_name", "(", "infile", ",", "outfile", ")", ":", "seqs", "=", "{", "}", "file_to_dict", "(", "infile", ",", "seqs", ")", "#seqs = list(seqs.values())", "#seqs.sort()", "fout", "=", "utils", ".", "open_file_write", "(", "outfile", ")", "for", "...
2c775c846d2491678a9637daa320592e02c26c72
valid
to_fastg
Writes a FASTG file in SPAdes format from input file. Currently only whether or not a sequence is circular is supported. Put circular=set of ids, or circular=filename to make those sequences circular in the output. Puts coverage=1 on all contigs
pyfastaq/tasks.py
def to_fastg(infile, outfile, circular=None): '''Writes a FASTG file in SPAdes format from input file. Currently only whether or not a sequence is circular is supported. Put circular=set of ids, or circular=filename to make those sequences circular in the output. Puts coverage=1 on all contigs''' if circular is...
def to_fastg(infile, outfile, circular=None): '''Writes a FASTG file in SPAdes format from input file. Currently only whether or not a sequence is circular is supported. Put circular=set of ids, or circular=filename to make those sequences circular in the output. Puts coverage=1 on all contigs''' if circular is...
[ "Writes", "a", "FASTG", "file", "in", "SPAdes", "format", "from", "input", "file", ".", "Currently", "only", "whether", "or", "not", "a", "sequence", "is", "circular", "is", "supported", ".", "Put", "circular", "=", "set", "of", "ids", "or", "circular", ...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L580-L618
[ "def", "to_fastg", "(", "infile", ",", "outfile", ",", "circular", "=", "None", ")", ":", "if", "circular", "is", "None", ":", "to_circularise", "=", "set", "(", ")", "elif", "type", "(", "circular", ")", "is", "not", "set", ":", "f", "=", "utils", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
length_offsets_from_fai
Returns a dictionary of positions of the start of each sequence, as if all the sequences were catted into one sequence. eg if file has three sequences, seq1 10bp, seq2 30bp, seq3 20bp, then the output would be: {'seq1': 0, 'seq2': 10, 'seq3': 40}
pyfastaq/tasks.py
def length_offsets_from_fai(fai_file): '''Returns a dictionary of positions of the start of each sequence, as if all the sequences were catted into one sequence. eg if file has three sequences, seq1 10bp, seq2 30bp, seq3 20bp, then the output would be: {'seq1': 0, 'seq2': 10, 'seq3': 40}''' ...
def length_offsets_from_fai(fai_file): '''Returns a dictionary of positions of the start of each sequence, as if all the sequences were catted into one sequence. eg if file has three sequences, seq1 10bp, seq2 30bp, seq3 20bp, then the output would be: {'seq1': 0, 'seq2': 10, 'seq3': 40}''' ...
[ "Returns", "a", "dictionary", "of", "positions", "of", "the", "start", "of", "each", "sequence", "as", "if", "all", "the", "sequences", "were", "catted", "into", "one", "sequence", ".", "eg", "if", "file", "has", "three", "sequences", "seq1", "10bp", "seq2...
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L663-L683
[ "def", "length_offsets_from_fai", "(", "fai_file", ")", ":", "positions", "=", "{", "}", "total_length", "=", "0", "f", "=", "utils", ".", "open_file_read", "(", "fai_file", ")", "for", "line", "in", "f", ":", "try", ":", "(", "name", ",", "length", ")...
2c775c846d2491678a9637daa320592e02c26c72
valid
split_by_base_count
Splits a fasta/q file into separate files, file size determined by number of bases. Puts <= max_bases in each split file The exception is a single sequence >=max_bases is put in its own file. This does not split sequences.
pyfastaq/tasks.py
def split_by_base_count(infile, outfiles_prefix, max_bases, max_seqs=None): '''Splits a fasta/q file into separate files, file size determined by number of bases. Puts <= max_bases in each split file The exception is a single sequence >=max_bases is put in its own file. This does not split sequences. ...
def split_by_base_count(infile, outfiles_prefix, max_bases, max_seqs=None): '''Splits a fasta/q file into separate files, file size determined by number of bases. Puts <= max_bases in each split file The exception is a single sequence >=max_bases is put in its own file. This does not split sequences. ...
[ "Splits", "a", "fasta", "/", "q", "file", "into", "separate", "files", "file", "size", "determined", "by", "number", "of", "bases", "." ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L686-L721
[ "def", "split_by_base_count", "(", "infile", ",", "outfiles_prefix", ",", "max_bases", ",", "max_seqs", "=", "None", ")", ":", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "base_count", "=", "0", "file_count", "=", "1", "seq_count", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
split_by_fixed_size
Splits fasta/q file into separate files, with up to (chunk_size + tolerance) bases in each file
pyfastaq/tasks.py
def split_by_fixed_size(infile, outfiles_prefix, chunk_size, tolerance, skip_if_all_Ns=False): '''Splits fasta/q file into separate files, with up to (chunk_size + tolerance) bases in each file''' file_count = 1 coords = [] small_sequences = [] # sequences shorter than chunk_size seq_reader = sequ...
def split_by_fixed_size(infile, outfiles_prefix, chunk_size, tolerance, skip_if_all_Ns=False): '''Splits fasta/q file into separate files, with up to (chunk_size + tolerance) bases in each file''' file_count = 1 coords = [] small_sequences = [] # sequences shorter than chunk_size seq_reader = sequ...
[ "Splits", "fasta", "/", "q", "file", "into", "separate", "files", "with", "up", "to", "(", "chunk_size", "+", "tolerance", ")", "bases", "in", "each", "file" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L724-L779
[ "def", "split_by_fixed_size", "(", "infile", ",", "outfiles_prefix", ",", "chunk_size", ",", "tolerance", ",", "skip_if_all_Ns", "=", "False", ")", ":", "file_count", "=", "1", "coords", "=", "[", "]", "small_sequences", "=", "[", "]", "# sequences shorter than ...
2c775c846d2491678a9637daa320592e02c26c72
valid
split_by_fixed_size_onefile
Splits each sequence in infile into chunks of fixed size, last chunk can be up to (chunk_size + tolerance) in length
pyfastaq/tasks.py
def split_by_fixed_size_onefile(infile, outfile, chunk_size, tolerance, skip_if_all_Ns=False): '''Splits each sequence in infile into chunks of fixed size, last chunk can be up to (chunk_size + tolerance) in length''' seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) ...
def split_by_fixed_size_onefile(infile, outfile, chunk_size, tolerance, skip_if_all_Ns=False): '''Splits each sequence in infile into chunks of fixed size, last chunk can be up to (chunk_size + tolerance) in length''' seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) ...
[ "Splits", "each", "sequence", "in", "infile", "into", "chunks", "of", "fixed", "size", "last", "chunk", "can", "be", "up", "to", "(", "chunk_size", "+", "tolerance", ")", "in", "length" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L782-L802
[ "def", "split_by_fixed_size_onefile", "(", "infile", ",", "outfile", ",", "chunk_size", ",", "tolerance", ",", "skip_if_all_Ns", "=", "False", ")", ":", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "f_out", "=", "utils", ".", "open_f...
2c775c846d2491678a9637daa320592e02c26c72
valid
stats_from_fai
Returns dictionary of length stats from an fai file. Keys are: longest, shortest, mean, total_length, N50, number
pyfastaq/tasks.py
def stats_from_fai(infile): '''Returns dictionary of length stats from an fai file. Keys are: longest, shortest, mean, total_length, N50, number''' f = utils.open_file_read(infile) try: lengths = sorted([int(line.split('\t')[1]) for line in f], reverse=True) except: raise Error('Error ge...
def stats_from_fai(infile): '''Returns dictionary of length stats from an fai file. Keys are: longest, shortest, mean, total_length, N50, number''' f = utils.open_file_read(infile) try: lengths = sorted([int(line.split('\t')[1]) for line in f], reverse=True) except: raise Error('Error ge...
[ "Returns", "dictionary", "of", "length", "stats", "from", "an", "fai", "file", ".", "Keys", "are", ":", "longest", "shortest", "mean", "total_length", "N50", "number" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L827-L853
[ "def", "stats_from_fai", "(", "infile", ")", ":", "f", "=", "utils", ".", "open_file_read", "(", "infile", ")", "try", ":", "lengths", "=", "sorted", "(", "[", "int", "(", "line", ".", "split", "(", "'\\t'", ")", "[", "1", "]", ")", "for", "line", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
to_boulderio
Converts input sequence file into a "Boulder-IO format", as used by primer3
pyfastaq/tasks.py
def to_boulderio(infile, outfile): '''Converts input sequence file into a "Boulder-IO format", as used by primer3''' seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) for sequence in seq_reader: print("SEQUENCE_ID=" + sequence.id, file=f_out) print("SEQUE...
def to_boulderio(infile, outfile): '''Converts input sequence file into a "Boulder-IO format", as used by primer3''' seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) for sequence in seq_reader: print("SEQUENCE_ID=" + sequence.id, file=f_out) print("SEQUE...
[ "Converts", "input", "sequence", "file", "into", "a", "Boulder", "-", "IO", "format", "as", "used", "by", "primer3" ]
sanger-pathogens/Fastaq
python
https://github.com/sanger-pathogens/Fastaq/blob/2c775c846d2491678a9637daa320592e02c26c72/pyfastaq/tasks.py#L856-L866
[ "def", "to_boulderio", "(", "infile", ",", "outfile", ")", ":", "seq_reader", "=", "sequences", ".", "file_reader", "(", "infile", ")", "f_out", "=", "utils", ".", "open_file_write", "(", "outfile", ")", "for", "sequence", "in", "seq_reader", ":", "print", ...
2c775c846d2491678a9637daa320592e02c26c72
valid
salted_hmac
Returns the HMAC-HASH of 'value', using a key generated from key_salt and a secret (which defaults to settings.SECRET_KEY). A different key_salt should be passed in for every application of HMAC. :type key_salt: any :type value: any :type secret: any :rtype: HMAC
django_cryptography/utils/crypto.py
def salted_hmac(key_salt, value, secret=None): """ Returns the HMAC-HASH of 'value', using a key generated from key_salt and a secret (which defaults to settings.SECRET_KEY). A different key_salt should be passed in for every application of HMAC. :type key_salt: any :type value: any :type ...
def salted_hmac(key_salt, value, secret=None): """ Returns the HMAC-HASH of 'value', using a key generated from key_salt and a secret (which defaults to settings.SECRET_KEY). A different key_salt should be passed in for every application of HMAC. :type key_salt: any :type value: any :type ...
[ "Returns", "the", "HMAC", "-", "HASH", "of", "value", "using", "a", "key", "generated", "from", "key_salt", "and", "a", "secret", "(", "which", "defaults", "to", "settings", ".", "SECRET_KEY", ")", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/crypto.py#L21-L56
[ "def", "salted_hmac", "(", "key_salt", ",", "value", ",", "secret", "=", "None", ")", ":", "if", "secret", "is", "None", ":", "secret", "=", "settings", ".", "SECRET_KEY", "key_salt", "=", "force_bytes", "(", "key_salt", ")", "secret", "=", "force_bytes", ...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
pbkdf2
Implements PBKDF2 with the same API as Django's existing implementation, using cryptography. :type password: any :type salt: any :type iterations: int :type dklen: int :type digest: cryptography.hazmat.primitives.hashes.HashAlgorithm
django_cryptography/utils/crypto.py
def pbkdf2(password, salt, iterations, dklen=0, digest=None): """ Implements PBKDF2 with the same API as Django's existing implementation, using cryptography. :type password: any :type salt: any :type iterations: int :type dklen: int :type digest: cryptography.hazmat.primitives.hashes.H...
def pbkdf2(password, salt, iterations, dklen=0, digest=None): """ Implements PBKDF2 with the same API as Django's existing implementation, using cryptography. :type password: any :type salt: any :type iterations: int :type dklen: int :type digest: cryptography.hazmat.primitives.hashes.H...
[ "Implements", "PBKDF2", "with", "the", "same", "API", "as", "Django", "s", "existing", "implementation", "using", "cryptography", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/crypto.py#L71-L94
[ "def", "pbkdf2", "(", "password", ",", "salt", ",", "iterations", ",", "dklen", "=", "0", ",", "digest", "=", "None", ")", ":", "if", "digest", "is", "None", ":", "digest", "=", "settings", ".", "CRYPTOGRAPHY_DIGEST", "if", "not", "dklen", ":", "dklen"...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
FernetBytes.encrypt
:type data: any :rtype: any
django_cryptography/utils/crypto.py
def encrypt(self, data): """ :type data: any :rtype: any """ data = force_bytes(data) iv = os.urandom(16) return self._encrypt_from_parts(data, iv)
def encrypt(self, data): """ :type data: any :rtype: any """ data = force_bytes(data) iv = os.urandom(16) return self._encrypt_from_parts(data, iv)
[ ":", "type", "data", ":", "any", ":", "rtype", ":", "any" ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/crypto.py#L113-L120
[ "def", "encrypt", "(", "self", ",", "data", ")", ":", "data", "=", "force_bytes", "(", "data", ")", "iv", "=", "os", ".", "urandom", "(", "16", ")", "return", "self", ".", "_encrypt_from_parts", "(", "data", ",", "iv", ")" ]
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
FernetBytes._encrypt_from_parts
:type data: bytes :type iv: bytes :rtype: any
django_cryptography/utils/crypto.py
def _encrypt_from_parts(self, data, iv): """ :type data: bytes :type iv: bytes :rtype: any """ padder = padding.PKCS7(algorithms.AES.block_size).padder() padded_data = padder.update(data) + padder.finalize() encryptor = Cipher( algorithms.AES(s...
def _encrypt_from_parts(self, data, iv): """ :type data: bytes :type iv: bytes :rtype: any """ padder = padding.PKCS7(algorithms.AES.block_size).padder() padded_data = padder.update(data) + padder.finalize() encryptor = Cipher( algorithms.AES(s...
[ ":", "type", "data", ":", "bytes", ":", "type", "iv", ":", "bytes", ":", "rtype", ":", "any" ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/crypto.py#L122-L135
[ "def", "_encrypt_from_parts", "(", "self", ",", "data", ",", "iv", ")", ":", "padder", "=", "padding", ".", "PKCS7", "(", "algorithms", ".", "AES", ".", "block_size", ")", ".", "padder", "(", ")", "padded_data", "=", "padder", ".", "update", "(", "data...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
FernetBytes.decrypt
:type data: bytes :type ttl: int :rtype: bytes
django_cryptography/utils/crypto.py
def decrypt(self, data, ttl=None): """ :type data: bytes :type ttl: int :rtype: bytes """ data = self._signer.unsign(data, ttl) iv = data[:16] ciphertext = data[16:] decryptor = Cipher( algorithms.AES(self._encryption_key), modes.CBC(i...
def decrypt(self, data, ttl=None): """ :type data: bytes :type ttl: int :rtype: bytes """ data = self._signer.unsign(data, ttl) iv = data[:16] ciphertext = data[16:] decryptor = Cipher( algorithms.AES(self._encryption_key), modes.CBC(i...
[ ":", "type", "data", ":", "bytes", ":", "type", "ttl", ":", "int", ":", "rtype", ":", "bytes" ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/crypto.py#L137-L163
[ "def", "decrypt", "(", "self", ",", "data", ",", "ttl", "=", "None", ")", ":", "data", "=", "self", ".", "_signer", ".", "unsign", "(", "data", ",", "ttl", ")", "iv", "=", "data", "[", ":", "16", "]", "ciphertext", "=", "data", "[", "16", ":", ...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
get_encrypted_field
A get or create method for encrypted fields, we cache the field in the module to avoid recreation. This also allows us to always return the same class reference for a field. :type base_class: models.Field[T] :rtype: models.Field[EncryptedMixin, T]
django_cryptography/fields.py
def get_encrypted_field(base_class): """ A get or create method for encrypted fields, we cache the field in the module to avoid recreation. This also allows us to always return the same class reference for a field. :type base_class: models.Field[T] :rtype: models.Field[EncryptedMixin, T] ""...
def get_encrypted_field(base_class): """ A get or create method for encrypted fields, we cache the field in the module to avoid recreation. This also allows us to always return the same class reference for a field. :type base_class: models.Field[T] :rtype: models.Field[EncryptedMixin, T] ""...
[ "A", "get", "or", "create", "method", "for", "encrypted", "fields", "we", "cache", "the", "field", "in", "the", "module", "to", "avoid", "recreation", ".", "This", "also", "allows", "us", "to", "always", "return", "the", "same", "class", "reference", "for"...
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/fields.py#L184-L200
[ "def", "get_encrypted_field", "(", "base_class", ")", ":", "assert", "not", "isinstance", "(", "base_class", ",", "models", ".", "Field", ")", "field_name", "=", "'Encrypted'", "+", "base_class", ".", "__name__", "if", "base_class", "not", "in", "FIELD_CACHE", ...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
encrypt
A decorator for creating encrypted model fields. :type base_field: models.Field[T] :param bytes key: This is an optional argument. Allows for specifying an instance specific encryption key. :param int ttl: This is an optional argument. The amount of time in seconds that a value can be sto...
django_cryptography/fields.py
def encrypt(base_field, key=None, ttl=None): """ A decorator for creating encrypted model fields. :type base_field: models.Field[T] :param bytes key: This is an optional argument. Allows for specifying an instance specific encryption key. :param int ttl: This is an optional argument. ...
def encrypt(base_field, key=None, ttl=None): """ A decorator for creating encrypted model fields. :type base_field: models.Field[T] :param bytes key: This is an optional argument. Allows for specifying an instance specific encryption key. :param int ttl: This is an optional argument. ...
[ "A", "decorator", "for", "creating", "encrypted", "model", "fields", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/fields.py#L203-L225
[ "def", "encrypt", "(", "base_field", ",", "key", "=", "None", ",", "ttl", "=", "None", ")", ":", "if", "not", "isinstance", "(", "base_field", ",", "models", ".", "Field", ")", ":", "assert", "key", "is", "None", "assert", "ttl", "is", "None", "retur...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
PickledField.value_to_string
Pickled data is serialized as base64
django_cryptography/fields.py
def value_to_string(self, obj): """Pickled data is serialized as base64""" value = self.value_from_object(obj) return b64encode(self._dump(value)).decode('ascii')
def value_to_string(self, obj): """Pickled data is serialized as base64""" value = self.value_from_object(obj) return b64encode(self._dump(value)).decode('ascii')
[ "Pickled", "data", "is", "serialized", "as", "base64" ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/fields.py#L78-L81
[ "def", "value_to_string", "(", "self", ",", "obj", ")", ":", "value", "=", "self", ".", "value_from_object", "(", "obj", ")", "return", "b64encode", "(", "self", ".", "_dump", "(", "value", ")", ")", ".", "decode", "(", "'ascii'", ")" ]
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
dumps
Returns URL-safe, sha1 signed base64 compressed JSON string. If key is None, settings.SECRET_KEY is used instead. If compress is True (not the default) checks if compressing using zlib can save some space. Prepends a '.' to signify compression. This is included in the signature, to protect against zip ...
django_cryptography/core/signing.py
def dumps(obj, key=None, salt='django.core.signing', serializer=JSONSerializer, compress=False): """ Returns URL-safe, sha1 signed base64 compressed JSON string. If key is None, settings.SECRET_KEY is used instead. If compress is True (not the default) checks if ...
def dumps(obj, key=None, salt='django.core.signing', serializer=JSONSerializer, compress=False): """ Returns URL-safe, sha1 signed base64 compressed JSON string. If key is None, settings.SECRET_KEY is used instead. If compress is True (not the default) checks if ...
[ "Returns", "URL", "-", "safe", "sha1", "signed", "base64", "compressed", "JSON", "string", ".", "If", "key", "is", "None", "settings", ".", "SECRET_KEY", "is", "used", "instead", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/core/signing.py#L36-L70
[ "def", "dumps", "(", "obj", ",", "key", "=", "None", ",", "salt", "=", "'django.core.signing'", ",", "serializer", "=", "JSONSerializer", ",", "compress", "=", "False", ")", ":", "data", "=", "serializer", "(", ")", ".", "dumps", "(", "obj", ")", "# Fl...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
FernetSigner.signature
:type value: any :rtype: HMAC
django_cryptography/core/signing.py
def signature(self, value): """ :type value: any :rtype: HMAC """ h = HMAC(self.key, self.digest, backend=settings.CRYPTOGRAPHY_BACKEND) h.update(force_bytes(value)) return h
def signature(self, value): """ :type value: any :rtype: HMAC """ h = HMAC(self.key, self.digest, backend=settings.CRYPTOGRAPHY_BACKEND) h.update(force_bytes(value)) return h
[ ":", "type", "value", ":", "any", ":", "rtype", ":", "HMAC" ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/core/signing.py#L194-L201
[ "def", "signature", "(", "self", ",", "value", ")", ":", "h", "=", "HMAC", "(", "self", ".", "key", ",", "self", ".", "digest", ",", "backend", "=", "settings", ".", "CRYPTOGRAPHY_BACKEND", ")", "h", ".", "update", "(", "force_bytes", "(", "value", "...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
FernetSigner.sign
:type value: any :rtype: bytes
django_cryptography/core/signing.py
def sign(self, value): """ :type value: any :rtype: bytes """ payload = struct.pack('>cQ', self.version, int(time.time())) payload += force_bytes(value) return payload + self.signature(payload).finalize()
def sign(self, value): """ :type value: any :rtype: bytes """ payload = struct.pack('>cQ', self.version, int(time.time())) payload += force_bytes(value) return payload + self.signature(payload).finalize()
[ ":", "type", "value", ":", "any", ":", "rtype", ":", "bytes" ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/core/signing.py#L203-L210
[ "def", "sign", "(", "self", ",", "value", ")", ":", "payload", "=", "struct", ".", "pack", "(", "'>cQ'", ",", "self", ".", "version", ",", "int", "(", "time", ".", "time", "(", ")", ")", ")", "payload", "+=", "force_bytes", "(", "value", ")", "re...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
FernetSigner.unsign
Retrieve original value and check it wasn't signed more than max_age seconds ago. :type signed_value: bytes :type ttl: int | datetime.timedelta
django_cryptography/core/signing.py
def unsign(self, signed_value, ttl=None): """ Retrieve original value and check it wasn't signed more than max_age seconds ago. :type signed_value: bytes :type ttl: int | datetime.timedelta """ h_size, d_size = struct.calcsize('>cQ'), self.digest.digest_size ...
def unsign(self, signed_value, ttl=None): """ Retrieve original value and check it wasn't signed more than max_age seconds ago. :type signed_value: bytes :type ttl: int | datetime.timedelta """ h_size, d_size = struct.calcsize('>cQ'), self.digest.digest_size ...
[ "Retrieve", "original", "value", "and", "check", "it", "wasn", "t", "signed", "more", "than", "max_age", "seconds", "ago", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/core/signing.py#L212-L241
[ "def", "unsign", "(", "self", ",", "signed_value", ",", "ttl", "=", "None", ")", ":", "h_size", ",", "d_size", "=", "struct", ".", "calcsize", "(", "'>cQ'", ")", ",", "self", ".", "digest", ".", "digest_size", "fmt", "=", "'>cQ%ds%ds'", "%", "(", "le...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
get_version
Returns a PEP 386-compliant version number from VERSION.
django_cryptography/utils/version.py
def get_version(version=None): """ Returns a PEP 386-compliant version number from VERSION. """ version = get_complete_version(version) # Now build the two parts of the version number: # main = X.Y[.Z] # sub = .devN - for pre-alpha releases # | {a|b|c}N - for alpha, beta and rc rele...
def get_version(version=None): """ Returns a PEP 386-compliant version number from VERSION. """ version = get_complete_version(version) # Now build the two parts of the version number: # main = X.Y[.Z] # sub = .devN - for pre-alpha releases # | {a|b|c}N - for alpha, beta and rc rele...
[ "Returns", "a", "PEP", "386", "-", "compliant", "version", "number", "from", "VERSION", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/version.py#L6-L29
[ "def", "get_version", "(", "version", "=", "None", ")", ":", "version", "=", "get_complete_version", "(", "version", ")", "# Now build the two parts of the version number:", "# main = X.Y[.Z]", "# sub = .devN - for pre-alpha releases", "# | {a|b|c}N - for alpha, beta and rc rel...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
get_complete_version
Returns a tuple of the django_cryptography version. If version argument is non-empty, then checks for correctness of the tuple provided.
django_cryptography/utils/version.py
def get_complete_version(version=None): """ Returns a tuple of the django_cryptography version. If version argument is non-empty, then checks for correctness of the tuple provided. """ if version is None: from django_cryptography import VERSION as version else: assert len(ver...
def get_complete_version(version=None): """ Returns a tuple of the django_cryptography version. If version argument is non-empty, then checks for correctness of the tuple provided. """ if version is None: from django_cryptography import VERSION as version else: assert len(ver...
[ "Returns", "a", "tuple", "of", "the", "django_cryptography", "version", ".", "If", "version", "argument", "is", "non", "-", "empty", "then", "checks", "for", "correctness", "of", "the", "tuple", "provided", "." ]
georgemarshall/django-cryptography
python
https://github.com/georgemarshall/django-cryptography/blob/4c5f60fec98bcf71495d6084f801ea9c01c9a725/django_cryptography/utils/version.py#L41-L53
[ "def", "get_complete_version", "(", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "from", "django_cryptography", "import", "VERSION", "as", "version", "else", ":", "assert", "len", "(", "version", ")", "==", "5", "assert", "version", ...
4c5f60fec98bcf71495d6084f801ea9c01c9a725
valid
enumeration
Return a value check function which raises a value error if the value is not in a pre-defined enumeration of values. If you pass in a list, tuple or set as the single argument, it is assumed that the list/tuple/set defines the membership of the enumeration. If you pass in more than on argument, it is ...
csvvalidator.py
def enumeration(*args): """ Return a value check function which raises a value error if the value is not in a pre-defined enumeration of values. If you pass in a list, tuple or set as the single argument, it is assumed that the list/tuple/set defines the membership of the enumeration. If you p...
def enumeration(*args): """ Return a value check function which raises a value error if the value is not in a pre-defined enumeration of values. If you pass in a list, tuple or set as the single argument, it is assumed that the list/tuple/set defines the membership of the enumeration. If you p...
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "value", "error", "if", "the", "value", "is", "not", "in", "a", "pre", "-", "defined", "enumeration", "of", "values", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L917-L940
[ "def", "enumeration", "(", "*", "args", ")", ":", "assert", "len", "(", "args", ")", ">", "0", ",", "'at least one argument is required'", "if", "len", "(", "args", ")", "==", "1", ":", "# assume the first argument defines the membership", "members", "=", "args"...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
match_pattern
Return a value check function which raises a ValueError if the value does not match the supplied regular expression, see also `re.match`.
csvvalidator.py
def match_pattern(regex): """ Return a value check function which raises a ValueError if the value does not match the supplied regular expression, see also `re.match`. """ prog = re.compile(regex) def checker(v): result = prog.match(v) if result is None: raise Value...
def match_pattern(regex): """ Return a value check function which raises a ValueError if the value does not match the supplied regular expression, see also `re.match`. """ prog = re.compile(regex) def checker(v): result = prog.match(v) if result is None: raise Value...
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "ValueError", "if", "the", "value", "does", "not", "match", "the", "supplied", "regular", "expression", "see", "also", "re", ".", "match", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L943-L955
[ "def", "match_pattern", "(", "regex", ")", ":", "prog", "=", "re", ".", "compile", "(", "regex", ")", "def", "checker", "(", "v", ")", ":", "result", "=", "prog", ".", "match", "(", "v", ")", "if", "result", "is", "None", ":", "raise", "ValueError"...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
search_pattern
Return a value check function which raises a ValueError if the supplied regular expression does not match anywhere in the value, see also `re.search`.
csvvalidator.py
def search_pattern(regex): """ Return a value check function which raises a ValueError if the supplied regular expression does not match anywhere in the value, see also `re.search`. """ prog = re.compile(regex) def checker(v): result = prog.search(v) if result is None: ...
def search_pattern(regex): """ Return a value check function which raises a ValueError if the supplied regular expression does not match anywhere in the value, see also `re.search`. """ prog = re.compile(regex) def checker(v): result = prog.search(v) if result is None: ...
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "ValueError", "if", "the", "supplied", "regular", "expression", "does", "not", "match", "anywhere", "in", "the", "value", "see", "also", "re", ".", "search", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L958-L971
[ "def", "search_pattern", "(", "regex", ")", ":", "prog", "=", "re", ".", "compile", "(", "regex", ")", "def", "checker", "(", "v", ")", ":", "result", "=", "prog", ".", "search", "(", "v", ")", "if", "result", "is", "None", ":", "raise", "ValueErro...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
number_range_inclusive
Return a value check function which raises a ValueError if the supplied value when cast as `type` is less than `min` or greater than `max`.
csvvalidator.py
def number_range_inclusive(min, max, type=float): """ Return a value check function which raises a ValueError if the supplied value when cast as `type` is less than `min` or greater than `max`. """ def checker(v): if type(v) < min or type(v) > max: raise ValueError(v) retur...
def number_range_inclusive(min, max, type=float): """ Return a value check function which raises a ValueError if the supplied value when cast as `type` is less than `min` or greater than `max`. """ def checker(v): if type(v) < min or type(v) > max: raise ValueError(v) retur...
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "ValueError", "if", "the", "supplied", "value", "when", "cast", "as", "type", "is", "less", "than", "min", "or", "greater", "than", "max", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L974-L984
[ "def", "number_range_inclusive", "(", "min", ",", "max", ",", "type", "=", "float", ")", ":", "def", "checker", "(", "v", ")", ":", "if", "type", "(", "v", ")", "<", "min", "or", "type", "(", "v", ")", ">", "max", ":", "raise", "ValueError", "(",...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
number_range_exclusive
Return a value check function which raises a ValueError if the supplied value when cast as `type` is less than or equal to `min` or greater than or equal to `max`.
csvvalidator.py
def number_range_exclusive(min, max, type=float): """ Return a value check function which raises a ValueError if the supplied value when cast as `type` is less than or equal to `min` or greater than or equal to `max`. """ def checker(v): if type(v) <= min or type(v) >= max: ...
def number_range_exclusive(min, max, type=float): """ Return a value check function which raises a ValueError if the supplied value when cast as `type` is less than or equal to `min` or greater than or equal to `max`. """ def checker(v): if type(v) <= min or type(v) >= max: ...
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "ValueError", "if", "the", "supplied", "value", "when", "cast", "as", "type", "is", "less", "than", "or", "equal", "to", "min", "or", "greater", "than", "or", "equal", "to", "max", "." ...
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L987-L998
[ "def", "number_range_exclusive", "(", "min", ",", "max", ",", "type", "=", "float", ")", ":", "def", "checker", "(", "v", ")", ":", "if", "type", "(", "v", ")", "<=", "min", "or", "type", "(", "v", ")", ">=", "max", ":", "raise", "ValueError", "(...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
datetime_range_inclusive
Return a value check function which raises a ValueError if the supplied value when converted to a datetime using the supplied `format` string is less than `min` or greater than `max`.
csvvalidator.py
def datetime_range_inclusive(min, max, format): """ Return a value check function which raises a ValueError if the supplied value when converted to a datetime using the supplied `format` string is less than `min` or greater than `max`. """ dmin = datetime.strptime(min, format) dmax = datet...
def datetime_range_inclusive(min, max, format): """ Return a value check function which raises a ValueError if the supplied value when converted to a datetime using the supplied `format` string is less than `min` or greater than `max`. """ dmin = datetime.strptime(min, format) dmax = datet...
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "ValueError", "if", "the", "supplied", "value", "when", "converted", "to", "a", "datetime", "using", "the", "supplied", "format", "string", "is", "less", "than", "min", "or", "greater", "th...
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L1015-L1029
[ "def", "datetime_range_inclusive", "(", "min", ",", "max", ",", "format", ")", ":", "dmin", "=", "datetime", ".", "strptime", "(", "min", ",", "format", ")", "dmax", "=", "datetime", ".", "strptime", "(", "max", ",", "format", ")", "def", "checker", "(...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
write_problems
Write problems as restructured text to a file (or stdout/stderr).
csvvalidator.py
def write_problems(problems, file, summarize=False, limit=0): """ Write problems as restructured text to a file (or stdout/stderr). """ w = file.write # convenience variable w(""" ================= Validation Report ================= """) counts = dict() # store problem counts per problem code ...
def write_problems(problems, file, summarize=False, limit=0): """ Write problems as restructured text to a file (or stdout/stderr). """ w = file.write # convenience variable w(""" ================= Validation Report ================= """) counts = dict() # store problem counts per problem code ...
[ "Write", "problems", "as", "restructured", "text", "to", "a", "file", "(", "or", "stdout", "/", "stderr", ")", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L1049-L1100
[ "def", "write_problems", "(", "problems", ",", "file", ",", "summarize", "=", "False", ",", "limit", "=", "0", ")", ":", "w", "=", "file", ".", "write", "# convenience variable", "w", "(", "\"\"\"\n=================\nValidation Report\n=================\n\"\"\"", ")...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_header_check
Add a header check, i.e., check whether the header record is consistent with the expected field names. Arguments --------- `code` - problem code to report if the header record is not valid, defaults to `HEADER_CHECK_FAILED` `message` - problem message to report if a va...
csvvalidator.py
def add_header_check(self, code=HEADER_CHECK_FAILED, message=MESSAGES[HEADER_CHECK_FAILED]): """ Add a header check, i.e., check whether the header record is consistent with the expected field names. Arguments --------- ...
def add_header_check(self, code=HEADER_CHECK_FAILED, message=MESSAGES[HEADER_CHECK_FAILED]): """ Add a header check, i.e., check whether the header record is consistent with the expected field names. Arguments --------- ...
[ "Add", "a", "header", "check", "i", ".", "e", ".", "check", "whether", "the", "header", "record", "is", "consistent", "with", "the", "expected", "field", "names", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L154-L172
[ "def", "add_header_check", "(", "self", ",", "code", "=", "HEADER_CHECK_FAILED", ",", "message", "=", "MESSAGES", "[", "HEADER_CHECK_FAILED", "]", ")", ":", "t", "=", "code", ",", "message", "self", ".", "_header_checks", ".", "append", "(", "t", ")" ]
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_record_length_check
Add a record length check, i.e., check whether the length of a record is consistent with the number of expected fields. Arguments --------- `code` - problem code to report if a record is not valid, defaults to `RECORD_LENGTH_CHECK_FAILED` `message` - problem message to...
csvvalidator.py
def add_record_length_check(self, code=RECORD_LENGTH_CHECK_FAILED, message=MESSAGES[RECORD_LENGTH_CHECK_FAILED], modulus=1): """ Add a record length check, i.e., check whether the length of a record is consistent with the...
def add_record_length_check(self, code=RECORD_LENGTH_CHECK_FAILED, message=MESSAGES[RECORD_LENGTH_CHECK_FAILED], modulus=1): """ Add a record length check, i.e., check whether the length of a record is consistent with the...
[ "Add", "a", "record", "length", "check", "i", ".", "e", ".", "check", "whether", "the", "length", "of", "a", "record", "is", "consistent", "with", "the", "number", "of", "expected", "fields", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L175-L197
[ "def", "add_record_length_check", "(", "self", ",", "code", "=", "RECORD_LENGTH_CHECK_FAILED", ",", "message", "=", "MESSAGES", "[", "RECORD_LENGTH_CHECK_FAILED", "]", ",", "modulus", "=", "1", ")", ":", "t", "=", "code", ",", "message", ",", "modulus", "self"...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_value_check
Add a value check function for the specified field. Arguments --------- `field_name` - the name of the field to attach the value check function to `value_check` - a function that accepts a single argument (a value) and raises a `ValueError` if the value is not valid ...
csvvalidator.py
def add_value_check(self, field_name, value_check, code=VALUE_CHECK_FAILED, message=MESSAGES[VALUE_CHECK_FAILED], modulus=1): """ Add a value check function for the specified field. Arguments --------- `fie...
def add_value_check(self, field_name, value_check, code=VALUE_CHECK_FAILED, message=MESSAGES[VALUE_CHECK_FAILED], modulus=1): """ Add a value check function for the specified field. Arguments --------- `fie...
[ "Add", "a", "value", "check", "function", "for", "the", "specified", "field", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L200-L231
[ "def", "add_value_check", "(", "self", ",", "field_name", ",", "value_check", ",", "code", "=", "VALUE_CHECK_FAILED", ",", "message", "=", "MESSAGES", "[", "VALUE_CHECK_FAILED", "]", ",", "modulus", "=", "1", ")", ":", "# guard conditions", "assert", "field_name...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_value_predicate
Add a value predicate function for the specified field. N.B., everything you can do with value predicates can also be done with value check functions, whether you use one or the other is a matter of style. Arguments --------- `field_name` - the name of the field to att...
csvvalidator.py
def add_value_predicate(self, field_name, value_predicate, code=VALUE_PREDICATE_FALSE, message=MESSAGES[VALUE_PREDICATE_FALSE], modulus=1): """ Add a value predicate function for the specified field. N.B., everything you ca...
def add_value_predicate(self, field_name, value_predicate, code=VALUE_PREDICATE_FALSE, message=MESSAGES[VALUE_PREDICATE_FALSE], modulus=1): """ Add a value predicate function for the specified field. N.B., everything you ca...
[ "Add", "a", "value", "predicate", "function", "for", "the", "specified", "field", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L234-L268
[ "def", "add_value_predicate", "(", "self", ",", "field_name", ",", "value_predicate", ",", "code", "=", "VALUE_PREDICATE_FALSE", ",", "message", "=", "MESSAGES", "[", "VALUE_PREDICATE_FALSE", "]", ",", "modulus", "=", "1", ")", ":", "assert", "field_name", "in",...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_record_check
Add a record check function. Arguments --------- `record_check` - a function that accepts a single argument (a record as a dictionary of values indexed by field name) and raises a `RecordError` if the record is not valid `modulus` - apply the check to every nth record,...
csvvalidator.py
def add_record_check(self, record_check, modulus=1): """ Add a record check function. Arguments --------- `record_check` - a function that accepts a single argument (a record as a dictionary of values indexed by field name) and raises a `RecordError` if the reco...
def add_record_check(self, record_check, modulus=1): """ Add a record check function. Arguments --------- `record_check` - a function that accepts a single argument (a record as a dictionary of values indexed by field name) and raises a `RecordError` if the reco...
[ "Add", "a", "record", "check", "function", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L271-L290
[ "def", "add_record_check", "(", "self", ",", "record_check", ",", "modulus", "=", "1", ")", ":", "assert", "callable", "(", "record_check", ")", ",", "'record check must be a callable function'", "t", "=", "record_check", ",", "modulus", "self", ".", "_record_chec...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_record_predicate
Add a record predicate function. N.B., everything you can do with record predicates can also be done with record check functions, whether you use one or the other is a matter of style. Arguments --------- `record_predicate` - a function that accepts a single argument (...
csvvalidator.py
def add_record_predicate(self, record_predicate, code=RECORD_PREDICATE_FALSE, message=MESSAGES[RECORD_PREDICATE_FALSE], modulus=1): """ Add a record predicate function. N.B., everything you can do with record predicates can...
def add_record_predicate(self, record_predicate, code=RECORD_PREDICATE_FALSE, message=MESSAGES[RECORD_PREDICATE_FALSE], modulus=1): """ Add a record predicate function. N.B., everything you can do with record predicates can...
[ "Add", "a", "record", "predicate", "function", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L293-L324
[ "def", "add_record_predicate", "(", "self", ",", "record_predicate", ",", "code", "=", "RECORD_PREDICATE_FALSE", ",", "message", "=", "MESSAGES", "[", "RECORD_PREDICATE_FALSE", "]", ",", "modulus", "=", "1", ")", ":", "assert", "callable", "(", "record_predicate",...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.add_unique_check
Add a unique check on a single column or combination of columns. Arguments --------- `key` - a single field name (string) specifying a field in which all values are expected to be unique, or a sequence of field names (tuple or list of strings) specifying a compound key ...
csvvalidator.py
def add_unique_check(self, key, code=UNIQUE_CHECK_FAILED, message=MESSAGES[UNIQUE_CHECK_FAILED]): """ Add a unique check on a single column or combination of columns. Arguments --------- `key` - a single field name (string) specif...
def add_unique_check(self, key, code=UNIQUE_CHECK_FAILED, message=MESSAGES[UNIQUE_CHECK_FAILED]): """ Add a unique check on a single column or combination of columns. Arguments --------- `key` - a single field name (string) specif...
[ "Add", "a", "unique", "check", "on", "a", "single", "column", "or", "combination", "of", "columns", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L327-L353
[ "def", "add_unique_check", "(", "self", ",", "key", ",", "code", "=", "UNIQUE_CHECK_FAILED", ",", "message", "=", "MESSAGES", "[", "UNIQUE_CHECK_FAILED", "]", ")", ":", "if", "isinstance", "(", "key", ",", "basestring", ")", ":", "assert", "key", "in", "se...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.validate
Validate `data` and return a list of validation problems found. Arguments --------- `data` - any source of row-oriented data, e.g., as provided by a `csv.reader`, or a list of lists of strings, or ... `expect_header_row` - does the data contain a header row (i.e., the ...
csvvalidator.py
def validate(self, data, expect_header_row=True, ignore_lines=0, summarize=False, limit=0, context=None, report_unexpected_exceptions=True): """ Validate `data` and return a list of validation problems ...
def validate(self, data, expect_header_row=True, ignore_lines=0, summarize=False, limit=0, context=None, report_unexpected_exceptions=True): """ Validate `data` and return a list of validation problems ...
[ "Validate", "data", "and", "return", "a", "list", "of", "validation", "problems", "found", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L368-L412
[ "def", "validate", "(", "self", ",", "data", ",", "expect_header_row", "=", "True", ",", "ignore_lines", "=", "0", ",", "summarize", "=", "False", ",", "limit", "=", "0", ",", "context", "=", "None", ",", "report_unexpected_exceptions", "=", "True", ")", ...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator.ivalidate
Validate `data` and return a iterator over problems found. Use this function rather than validate() if you expect a large number of problems. Arguments --------- `data` - any source of row-oriented data, e.g., as provided by a `csv.reader`, or a list of lists of string...
csvvalidator.py
def ivalidate(self, data, expect_header_row=True, ignore_lines=0, summarize=False, context=None, report_unexpected_exceptions=True): """ Validate `data` and return a iterator over problems found. Use this funct...
def ivalidate(self, data, expect_header_row=True, ignore_lines=0, summarize=False, context=None, report_unexpected_exceptions=True): """ Validate `data` and return a iterator over problems found. Use this funct...
[ "Validate", "data", "and", "return", "a", "iterator", "over", "problems", "found", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L415-L505
[ "def", "ivalidate", "(", "self", ",", "data", ",", "expect_header_row", "=", "True", ",", "ignore_lines", "=", "0", ",", "summarize", "=", "False", ",", "context", "=", "None", ",", "report_unexpected_exceptions", "=", "True", ")", ":", "unique_sets", "=", ...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._init_unique_sets
Initialise sets used for uniqueness checking.
csvvalidator.py
def _init_unique_sets(self): """Initialise sets used for uniqueness checking.""" ks = dict() for t in self._unique_checks: key = t[0] ks[key] = set() # empty set return ks
def _init_unique_sets(self): """Initialise sets used for uniqueness checking.""" ks = dict() for t in self._unique_checks: key = t[0] ks[key] = set() # empty set return ks
[ "Initialise", "sets", "used", "for", "uniqueness", "checking", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L508-L515
[ "def", "_init_unique_sets", "(", "self", ")", ":", "ks", "=", "dict", "(", ")", "for", "t", "in", "self", ".", "_unique_checks", ":", "key", "=", "t", "[", "0", "]", "ks", "[", "key", "]", "=", "set", "(", ")", "# empty set", "return", "ks" ]
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_value_checks
Apply value check functions on the given record `r`.
csvvalidator.py
def _apply_value_checks(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply value check functions on the given record `r`.""" for field_name, check, code, message, modulus in self._va...
def _apply_value_checks(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply value check functions on the given record `r`.""" for field_name, check, code, message, modulus in self._va...
[ "Apply", "value", "check", "functions", "on", "the", "given", "record", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L518-L556
[ "def", "_apply_value_checks", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "field_name", ",", "check", ",", "code", ",", "message", ",", "...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_header_checks
Apply header checks on the given record `r`.
csvvalidator.py
def _apply_header_checks(self, i, r, summarize=False, context=None): """Apply header checks on the given record `r`.""" for code, message in self._header_checks: if tuple(r) != self._field_names: p = {'code': code} if not summarize: p['mes...
def _apply_header_checks(self, i, r, summarize=False, context=None): """Apply header checks on the given record `r`.""" for code, message in self._header_checks: if tuple(r) != self._field_names: p = {'code': code} if not summarize: p['mes...
[ "Apply", "header", "checks", "on", "the", "given", "record", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L559-L572
[ "def", "_apply_header_checks", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "context", "=", "None", ")", ":", "for", "code", ",", "message", "in", "self", ".", "_header_checks", ":", "if", "tuple", "(", "r", ")", "!=", "self"...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_record_length_checks
Apply record length checks on the given record `r`.
csvvalidator.py
def _apply_record_length_checks(self, i, r, summarize=False, context=None): """Apply record length checks on the given record `r`.""" for code, message, modulus in self._record_length_checks: if i % modulus == 0: # support sampling if len(r) != len(self._field_names): ...
def _apply_record_length_checks(self, i, r, summarize=False, context=None): """Apply record length checks on the given record `r`.""" for code, message, modulus in self._record_length_checks: if i % modulus == 0: # support sampling if len(r) != len(self._field_names): ...
[ "Apply", "record", "length", "checks", "on", "the", "given", "record", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L575-L588
[ "def", "_apply_record_length_checks", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "context", "=", "None", ")", ":", "for", "code", ",", "message", ",", "modulus", "in", "self", ".", "_record_length_checks", ":", "if", "i", "%", ...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_value_predicates
Apply value predicates on the given record `r`.
csvvalidator.py
def _apply_value_predicates(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply value predicates on the given record `r`.""" for field_name, predicate, code, message, modu...
def _apply_value_predicates(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply value predicates on the given record `r`.""" for field_name, predicate, code, message, modu...
[ "Apply", "value", "predicates", "on", "the", "given", "record", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L591-L629
[ "def", "_apply_value_predicates", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "field_name", ",", "predicate", ",", "code", ",", "message", ...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_record_checks
Apply record checks on `r`.
csvvalidator.py
def _apply_record_checks(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply record checks on `r`.""" for check, modulus in self._record_checks: if i % modu...
def _apply_record_checks(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply record checks on `r`.""" for check, modulus in self._record_checks: if i % modu...
[ "Apply", "record", "checks", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L632-L665
[ "def", "_apply_record_checks", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "check", ",", "modulus", "in", "self", ".", "_record_checks", ":...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_record_predicates
Apply record predicates on `r`.
csvvalidator.py
def _apply_record_predicates(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply record predicates on `r`.""" for predicate, code, message, modulus in self._record_pred...
def _apply_record_predicates(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply record predicates on `r`.""" for predicate, code, message, modulus in self._record_pred...
[ "Apply", "record", "predicates", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L668-L698
[ "def", "_apply_record_predicates", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "predicate", ",", "code", ",", "message", ",", "modulus", "i...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_unique_checks
Apply unique checks on `r`.
csvvalidator.py
def _apply_unique_checks(self, i, r, unique_sets, summarize=False, context=None): """Apply unique checks on `r`.""" for key, code, message in self._unique_checks: value = None values = unique_sets[key] if isin...
def _apply_unique_checks(self, i, r, unique_sets, summarize=False, context=None): """Apply unique checks on `r`.""" for key, code, message in self._unique_checks: value = None values = unique_sets[key] if isin...
[ "Apply", "unique", "checks", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L701-L732
[ "def", "_apply_unique_checks", "(", "self", ",", "i", ",", "r", ",", "unique_sets", ",", "summarize", "=", "False", ",", "context", "=", "None", ")", ":", "for", "key", ",", "code", ",", "message", "in", "self", ".", "_unique_checks", ":", "value", "="...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_each_methods
Invoke 'each' methods on `r`.
csvvalidator.py
def _apply_each_methods(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Invoke 'each' methods on `r`.""" for a in dir(self): if a.startswith('each'): rdict =...
def _apply_each_methods(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Invoke 'each' methods on `r`.""" for a in dir(self): if a.startswith('each'): rdict =...
[ "Invoke", "each", "methods", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L735-L758
[ "def", "_apply_each_methods", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "a", "in", "dir", "(", "self", ")", ":", "if", "a", ".", "s...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_assert_methods
Apply 'assert' methods on `r`.
csvvalidator.py
def _apply_assert_methods(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply 'assert' methods on `r`.""" for a in dir(self): if a.startswith('assert'): ...
def _apply_assert_methods(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply 'assert' methods on `r`.""" for a in dir(self): if a.startswith('assert'): ...
[ "Apply", "assert", "methods", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L761-L803
[ "def", "_apply_assert_methods", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "a", "in", "dir", "(", "self", ")", ":", "if", "a", ".", ...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_check_methods
Apply 'check' methods on `r`.
csvvalidator.py
def _apply_check_methods(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply 'check' methods on `r`.""" for a in dir(self): if a.startswith('check'): ...
def _apply_check_methods(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply 'check' methods on `r`.""" for a in dir(self): if a.startswith('check'): ...
[ "Apply", "check", "methods", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L806-L840
[ "def", "_apply_check_methods", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "a", "in", "dir", "(", "self", ")", ":", "if", "a", ".", "...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._apply_skips
Apply skip functions on `r`.
csvvalidator.py
def _apply_skips(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply skip functions on `r`.""" for skip in self._skips: try: result = skip(r) if result is True:...
def _apply_skips(self, i, r, summarize=False, report_unexpected_exceptions=True, context=None): """Apply skip functions on `r`.""" for skip in self._skips: try: result = skip(r) if result is True:...
[ "Apply", "skip", "functions", "on", "r", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L883-L905
[ "def", "_apply_skips", "(", "self", ",", "i", ",", "r", ",", "summarize", "=", "False", ",", "report_unexpected_exceptions", "=", "True", ",", "context", "=", "None", ")", ":", "for", "skip", "in", "self", ".", "_skips", ":", "try", ":", "result", "=",...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
CSVValidator._as_dict
Convert the record to a dictionary using field names as keys.
csvvalidator.py
def _as_dict(self, r): """Convert the record to a dictionary using field names as keys.""" d = dict() for i, f in enumerate(self._field_names): d[f] = r[i] if i < len(r) else None return d
def _as_dict(self, r): """Convert the record to a dictionary using field names as keys.""" d = dict() for i, f in enumerate(self._field_names): d[f] = r[i] if i < len(r) else None return d
[ "Convert", "the", "record", "to", "a", "dictionary", "using", "field", "names", "as", "keys", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L908-L914
[ "def", "_as_dict", "(", "self", ",", "r", ")", ":", "d", "=", "dict", "(", ")", "for", "i", ",", "f", "in", "enumerate", "(", "self", ".", "_field_names", ")", ":", "d", "[", "f", "]", "=", "r", "[", "i", "]", "if", "i", "<", "len", "(", ...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
create_validator
Create an example CSV validator for patient demographic data.
example.py
def create_validator(): """Create an example CSV validator for patient demographic data.""" field_names = ( 'study_id', 'patient_id', 'gender', 'age_years', 'age_months', 'date_inclusion' ...
def create_validator(): """Create an example CSV validator for patient demographic data.""" field_names = ( 'study_id', 'patient_id', 'gender', 'age_years', 'age_months', 'date_inclusion' ...
[ "Create", "an", "example", "CSV", "validator", "for", "patient", "demographic", "data", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/example.py#L18-L57
[ "def", "create_validator", "(", ")", ":", "field_names", "=", "(", "'study_id'", ",", "'patient_id'", ",", "'gender'", ",", "'age_years'", ",", "'age_months'", ",", "'date_inclusion'", ")", "validator", "=", "CSVValidator", "(", "field_names", ")", "# basic header...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
main
Main function.
example.py
def main(): """Main function.""" # define a command-line argument parser description = 'Validate a CSV data file.' parser = argparse.ArgumentParser(description=description) parser.add_argument('file', metavar='FILE', help='a file to be validated') ...
def main(): """Main function.""" # define a command-line argument parser description = 'Validate a CSV data file.' parser = argparse.ArgumentParser(description=description) parser.add_argument('file', metavar='FILE', help='a file to be validated') ...
[ "Main", "function", "." ]
alimanfoo/csvvalidator
python
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/example.py#L60-L124
[ "def", "main", "(", ")", ":", "# define a command-line argument parser", "description", "=", "'Validate a CSV data file.'", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "description", ")", "parser", ".", "add_argument", "(", "'file'", ","...
50a86eefdc549c48f65a91a5c0a66099010ee65d
valid
process_tables
Convert markdown tables to html, since recommonmark can't. This requires 3 steps: Snip out table sections from the markdown Convert them to html Replace the old markdown table with an html table This function is called by sphinx for each document. `source` is a 1-item list. To update the do...
sphinx_markdown_tables/__init__.py
def process_tables(app, docname, source): """ Convert markdown tables to html, since recommonmark can't. This requires 3 steps: Snip out table sections from the markdown Convert them to html Replace the old markdown table with an html table This function is called by sphinx for each...
def process_tables(app, docname, source): """ Convert markdown tables to html, since recommonmark can't. This requires 3 steps: Snip out table sections from the markdown Convert them to html Replace the old markdown table with an html table This function is called by sphinx for each...
[ "Convert", "markdown", "tables", "to", "html", "since", "recommonmark", "can", "t", ".", "This", "requires", "3", "steps", ":", "Snip", "out", "table", "sections", "from", "the", "markdown", "Convert", "them", "to", "html", "Replace", "the", "old", "markdown...
ryanfox/sphinx-markdown-tables
python
https://github.com/ryanfox/sphinx-markdown-tables/blob/7a1386892023d2e63cd34e7767eb27af809148cc/sphinx_markdown_tables/__init__.py#L11-L36
[ "def", "process_tables", "(", "app", ",", "docname", ",", "source", ")", ":", "import", "markdown", "md", "=", "markdown", ".", "Markdown", "(", "extensions", "=", "[", "'markdown.extensions.tables'", "]", ")", "table_processor", "=", "markdown", ".", "extensi...
7a1386892023d2e63cd34e7767eb27af809148cc
valid
pack_into
Pack given values v1, v2, ... into given bytearray `buf`, starting at given bit offset `offset`. Pack according to given format string `fmt`. Give `fill_padding` as ``False`` to leave padding bits in `buf` unmodified.
bitstruct.py
def pack_into(fmt, buf, offset, *args, **kwargs): """Pack given values v1, v2, ... into given bytearray `buf`, starting at given bit offset `offset`. Pack according to given format string `fmt`. Give `fill_padding` as ``False`` to leave padding bits in `buf` unmodified. """ return CompiledForm...
def pack_into(fmt, buf, offset, *args, **kwargs): """Pack given values v1, v2, ... into given bytearray `buf`, starting at given bit offset `offset`. Pack according to given format string `fmt`. Give `fill_padding` as ``False`` to leave padding bits in `buf` unmodified. """ return CompiledForm...
[ "Pack", "given", "values", "v1", "v2", "...", "into", "given", "bytearray", "buf", "starting", "at", "given", "bit", "offset", "offset", ".", "Pack", "according", "to", "given", "format", "string", "fmt", ".", "Give", "fill_padding", "as", "False", "to", "...
eerimoq/bitstruct
python
https://github.com/eerimoq/bitstruct/blob/8e887c10241aa51c2a77c10e9923bb3978b15bcb/bitstruct.py#L523-L534
[ "def", "pack_into", "(", "fmt", ",", "buf", ",", "offset", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "CompiledFormat", "(", "fmt", ")", ".", "pack_into", "(", "buf", ",", "offset", ",", "*", "args", ",", "*", "*", "kwargs", "...
8e887c10241aa51c2a77c10e9923bb3978b15bcb