_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2100 | TwitterStream.datagramReceived | train | def datagramReceived(self, data):
"""
Decode the JSON-encoded datagram and call the callback.
"""
try:
obj = json.loads(data)
except ValueError, e:
log.err(e, 'Invalid JSON in stream: %r' % data)
return
if u'text' in obj:
o... | python | {
"resource": ""
} |
q2101 | TwitterStream.connectionLost | train | def connectionLost(self, reason):
"""
Called when the body is complete or the connection was lost.
@note: As the body length is usually not known at the beginning of the
response we expect a L{PotentialDataLoss} when Twitter closes the
stream, instead of L{ResponseDone}. Other e... | python | {
"resource": ""
} |
q2102 | simpleListFactory | train | def simpleListFactory(list_type):
"""Used for simple parsers that support only one type of object"""
def create(delegate, extra_args=None):
"""Create a Parser object for the specific tag type, on the fly"""
return listParser(list_type, delegate, extra_args)
return create | python | {
"resource": ""
} |
q2103 | BaseXMLHandler.setSubDelegates | train | def setSubDelegates(self, namelist, before=None, after=None):
"""Set a delegate for a sub-sub-item, according to a list of names"""
if len(namelist) > 1:
def set_sub(i):
i.setSubDelegates(namelist[1:], before, after)
self.setBeforeDelegate(namelist[0], set_sub)
... | python | {
"resource": ""
} |
q2104 | _split_path | train | def _split_path(path):
"""split a path return by the api
return
- the sentinel:
- the rest of the path as a list.
- the original path stripped of / for normalisation.
"""
path = path.strip('/')
list_path = path.split('/')
sentinel = list_path.pop(0)
return sentinel, ... | python | {
"resource": ""
} |
q2105 | MixedContentsManager.path_dispatch_rename | train | def path_dispatch_rename(rename_like_method):
"""
decorator for rename-like function, that need dispatch on 2 arguments
"""
def _wrapper_method(self, old_path, new_path):
old_path, _old_path, old_sentinel = _split_path(old_path);
new_path, _new_path, new_sentine... | python | {
"resource": ""
} |
q2106 | deactivate | train | def deactivate(profile='default'):
"""should be a matter of just unsetting the above keys
"""
with jconfig(profile) as config:
deact = True;
if not getattr(config.NotebookApp.contents_manager_class, 'startswith',lambda x:False)('jupyterdrive'):
deact=False
if 'gdrive' not... | python | {
"resource": ""
} |
q2107 | sequence_type | train | def sequence_type(seq):
'''Validates a coral.sequence data type.
:param sequence_in: input DNA sequence.
:type sequence_in: any
:returns: The material - 'dna', 'rna', or 'peptide'.
:rtype: str
:raises: ValueError
'''
if isinstance(seq, coral.DNA):
material = 'dna'
elif isin... | python | {
"resource": ""
} |
q2108 | digest | train | def digest(dna, restriction_enzyme):
'''Restriction endonuclease reaction.
:param dna: DNA template to digest.
:type dna: coral.DNA
:param restriction_site: Restriction site to use.
:type restriction_site: RestrictionSite
:returns: list of digested DNA fragments.
:rtype: coral.DNA list
... | python | {
"resource": ""
} |
q2109 | _cut | train | def _cut(dna, index, restriction_enzyme):
'''Cuts template once at the specified index.
:param dna: DNA to cut
:type dna: coral.DNA
:param index: index at which to cut
:type index: int
:param restriction_enzyme: Enzyme with which to cut
:type restriction_enzyme: coral.RestrictionSite
:r... | python | {
"resource": ""
} |
q2110 | ipynb_to_rst | train | def ipynb_to_rst(directory, filename):
"""Converts a given file in a directory to an rst in the same directory."""
print(filename)
os.chdir(directory)
subprocess.Popen(["ipython", "nbconvert", "--to", "rst",
filename],
stdout=subprocess.PIPE,
... | python | {
"resource": ""
} |
q2111 | convert_ipynbs | train | def convert_ipynbs(directory):
"""Recursively converts all ipynb files in a directory into rst files in
the same directory."""
# The ipython_examples dir has to be in the same dir as this script
for root, subfolders, files in os.walk(os.path.abspath(directory)):
for f in files:
if ".... | python | {
"resource": ""
} |
q2112 | _context_walk | train | def _context_walk(dna, window_size, context_len, step):
'''Generate context-dependent 'non-boundedness' scores for a DNA sequence.
:param dna: Sequence to score.
:type dna: coral.DNA
:param window_size: Window size in base pairs.
:type window_size: int
:param context_len: The number of bases of... | python | {
"resource": ""
} |
q2113 | StructureWindows.plot | train | def plot(self):
'''Plot the results of the run method.'''
try:
from matplotlib import pylab
except ImportError:
raise ImportError('Optional dependency matplotlib not installed.')
if self.walked:
fig = pylab.figure()
ax1 = fig.add_subplot(1... | python | {
"resource": ""
} |
q2114 | primer | train | def primer(dna, tm=65, min_len=10, tm_undershoot=1, tm_overshoot=3,
end_gc=False, tm_parameters='cloning', overhang=None,
structure=False):
'''Design primer to a nearest-neighbor Tm setpoint.
:param dna: Sequence for which to design a primer.
:type dna: coral.DNA
:param tm: Ideal ... | python | {
"resource": ""
} |
q2115 | primers | train | def primers(dna, tm=65, min_len=10, tm_undershoot=1, tm_overshoot=3,
end_gc=False, tm_parameters='cloning', overhangs=None,
structure=False):
'''Design primers for PCR amplifying any arbitrary sequence.
:param dna: Input sequence.
:type dna: coral.DNA
:param tm: Ideal primer Tm ... | python | {
"resource": ""
} |
q2116 | Sanger.nonmatches | train | def nonmatches(self):
'''Report mismatches, indels, and coverage.'''
# For every result, keep a dictionary of mismatches, insertions, and
# deletions
report = []
for result in self.aligned_results:
report.append(self._analyze_single(self.aligned_reference, result))
... | python | {
"resource": ""
} |
q2117 | Sanger.plot | train | def plot(self):
'''Make a summary plot of the alignment and highlight nonmatches.'''
import matplotlib.pyplot as plt
import matplotlib.patches as patches
# Constants to use throughout drawing
n = len(self.results)
nbases = len(self.aligned_reference)
barheight = ... | python | {
"resource": ""
} |
q2118 | Sanger._remove_n | train | def _remove_n(self):
'''Remove terminal Ns from sequencing results.'''
for i, result in enumerate(self.results):
largest = max(str(result).split('N'), key=len)
start = result.locate(largest)[0][0]
stop = start + len(largest)
if start != stop:
... | python | {
"resource": ""
} |
q2119 | random_dna | train | def random_dna(n):
'''Generate a random DNA sequence.
:param n: Output sequence length.
:type n: int
:returns: Random DNA sequence of length n.
:rtype: coral.DNA
'''
return coral.DNA(''.join([random.choice('ATGC') for i in range(n)])) | python | {
"resource": ""
} |
q2120 | random_codons | train | def random_codons(peptide, frequency_cutoff=0.0, weighted=False, table=None):
'''Generate randomized codons given a peptide sequence.
:param peptide: Peptide sequence for which to generate randomized
codons.
:type peptide: coral.Peptide
:param frequency_cutoff: Relative codon usage ... | python | {
"resource": ""
} |
q2121 | _cutoff | train | def _cutoff(table, frequency_cutoff):
'''Generate new codon frequency table given a mean cutoff.
:param table: codon frequency table of form {amino acid: codon: frequency}
:type table: dict
:param frequency_cutoff: value between 0 and 1.0 for mean frequency cutoff
:type frequency_cutoff: float
... | python | {
"resource": ""
} |
q2122 | fetch_genome | train | def fetch_genome(genome_id):
'''Acquire a genome from Entrez
'''
# TODO: Can strandedness by found in fetched genome attributes?
# TODO: skip read/write step?
# Using a dummy email for now - does this violate NCBI guidelines?
email = 'loremipsum@gmail.com'
Entrez.email = email
print 'D... | python | {
"resource": ""
} |
q2123 | ViennaRNA.fold | train | def fold(self, strand, temp=37.0, dangles=2, nolp=False, nogu=False,
noclosinggu=False, constraints=None, canonicalbponly=False,
partition=False, pfscale=None, imfeelinglucky=False, gquad=False):
'''Run the RNAfold command and retrieve the result in a dictionary.
:param strand... | python | {
"resource": ""
} |
q2124 | dimers | train | def dimers(primer1, primer2, concentrations=[5e-7, 3e-11]):
'''Calculate expected fraction of primer dimers.
:param primer1: Forward primer.
:type primer1: coral.DNA
:param primer2: Reverse primer.
:type primer2: coral.DNA
:param template: DNA template.
:type template: coral.DNA
:param ... | python | {
"resource": ""
} |
q2125 | read_dna | train | def read_dna(path):
'''Read DNA from file. Uses BioPython and coerces to coral format.
:param path: Full path to input file.
:type path: str
:returns: DNA sequence.
:rtype: coral.DNA
'''
filename, ext = os.path.splitext(os.path.split(path)[-1])
genbank_exts = ['.gb', '.ape']
fasta... | python | {
"resource": ""
} |
q2126 | _seqfeature_to_coral | train | def _seqfeature_to_coral(feature):
'''Convert a Biopython SeqFeature to a coral.Feature.
:param feature: Biopython SeqFeature
:type feature: Bio.SeqFeature
'''
# Some genomic sequences don't have a label attribute
# TODO: handle genomic cases differently than others. Some features lack
# a... | python | {
"resource": ""
} |
q2127 | _coral_to_seqfeature | train | def _coral_to_seqfeature(feature):
'''Convert a coral.Feature to a Biopython SeqFeature.
:param feature: coral Feature.
:type feature: coral.Feature
'''
bio_strand = 1 if feature.strand == 1 else -1
ftype = _process_feature_type(feature.feature_type, bio_to_coral=False)
sublocations = []
... | python | {
"resource": ""
} |
q2128 | score_alignment | train | def score_alignment(a, b, gap_open, gap_extend, matrix):
'''Calculate the alignment score from two aligned sequences.
:param a: The first aligned sequence.
:type a: str
:param b: The second aligned sequence.
:type b: str
:param gap_open: The cost of opening a gap (negative number).
:type ga... | python | {
"resource": ""
} |
q2129 | build_docs | train | def build_docs(directory):
"""Builds sphinx docs from a given directory."""
os.chdir(directory)
process = subprocess.Popen(["make", "html"], cwd=directory)
process.communicate() | python | {
"resource": ""
} |
q2130 | gibson | train | def gibson(seq_list, circular=True, overlaps='mixed', overlap_tm=65,
maxlen=80, terminal_primers=True, primer_kwargs=None):
'''Design Gibson primers given a set of sequences
:param seq_list: List of DNA sequences to stitch together
:type seq_list: list containing coral.DNA
:param circular: I... | python | {
"resource": ""
} |
q2131 | reverse_complement | train | def reverse_complement(sequence, material):
'''Reverse complement a sequence.
:param sequence: Sequence to reverse complement
:type sequence: str
:param material: dna, rna, or peptide.
:type material: str
'''
code = dict(COMPLEMENTS[material])
reverse_sequence = sequence[::-1]
retur... | python | {
"resource": ""
} |
q2132 | check_alphabet | train | def check_alphabet(seq, material):
'''Verify that a given string is valid DNA, RNA, or peptide characters.
:param seq: DNA, RNA, or peptide sequence.
:type seq: str
:param material: Input material - 'dna', 'rna', or 'pepide'.
:type sequence: str
:returns: Whether the `seq` is a valid string of ... | python | {
"resource": ""
} |
q2133 | process_seq | train | def process_seq(seq, material):
'''Validate and process sequence inputs.
:param seq: input sequence
:type seq: str
:param material: DNA, RNA, or peptide
:type: str
:returns: Uppercase version of `seq` with the alphabet checked by
check_alphabet().
:rtype: str
'''
chec... | python | {
"resource": ""
} |
q2134 | palindrome | train | def palindrome(seq):
'''Test whether a sequence is palindrome.
:param seq: Sequence to analyze (DNA or RNA).
:type seq: coral.DNA or coral.RNA
:returns: Whether a sequence is a palindrome.
:rtype: bool
'''
seq_len = len(seq)
if seq_len % 2 == 0:
# Sequence has even number of ba... | python | {
"resource": ""
} |
q2135 | Feature.copy | train | def copy(self):
'''Return a copy of the Feature.
:returns: A safely editable copy of the current feature.
:rtype: coral.Feature
'''
return type(self)(self.name, self.start, self.stop, self.feature_type,
gene=self.gene, locus_tag=self.locus_tag,
... | python | {
"resource": ""
} |
q2136 | nupack_multi | train | def nupack_multi(seqs, material, cmd, arguments, report=True):
'''Split Nupack commands over processors.
:param inputs: List of sequences, same format as for coral.analysis.Nupack.
:type inpus: list
:param material: Input material: 'dna' or 'rna'.
:type material: str
:param cmd: Command: 'mfe',... | python | {
"resource": ""
} |
q2137 | run_nupack | train | def run_nupack(kwargs):
'''Run picklable Nupack command.
:param kwargs: keyword arguments to pass to Nupack as well as 'cmd'.
:returns: Variable - whatever `cmd` returns.
'''
run = NUPACK(kwargs['seq'])
output = getattr(run, kwargs['cmd'])(**kwargs['arguments'])
return output | python | {
"resource": ""
} |
q2138 | NUPACK.pfunc_multi | train | def pfunc_multi(self, strands, permutation=None, temp=37.0, pseudo=False,
material=None, dangles='some', sodium=1.0, magnesium=0.0):
'''Compute the partition function for an ordered complex of strands.
Runs the \'pfunc\' command.
:param strands: List of strands to use as inp... | python | {
"resource": ""
} |
q2139 | NUPACK.subopt | train | def subopt(self, strand, gap, temp=37.0, pseudo=False, material=None,
dangles='some', sodium=1.0, magnesium=0.0):
'''Compute the suboptimal structures within a defined energy gap of the
MFE. Runs the \'subopt\' command.
:param strand: Strand on which to run subopt. Strands must b... | python | {
"resource": ""
} |
q2140 | NUPACK.energy | train | def energy(self, strand, dotparens, temp=37.0, pseudo=False, material=None,
dangles='some', sodium=1.0, magnesium=0.0):
'''Calculate the free energy of a given sequence structure. Runs the
\'energy\' command.
:param strand: Strand on which to run energy. Strands must be either
... | python | {
"resource": ""
} |
q2141 | NUPACK.complexes_timeonly | train | def complexes_timeonly(self, strands, max_size):
'''Estimate the amount of time it will take to calculate all the
partition functions for each circular permutation - estimate the time
the actual \'complexes\' command will take to run.
:param strands: Strands on which to run energy. Stra... | python | {
"resource": ""
} |
q2142 | NUPACK._multi_lines | train | def _multi_lines(self, strands, permutation):
'''Prepares lines to write to file for pfunc command input.
:param strand: Strand input (cr.DNA or cr.RNA).
:type strand: cr.DNA or cr.DNA
:param permutation: Permutation (e.g. [1, 2, 3, 4]) of the type used
by pf... | python | {
"resource": ""
} |
q2143 | NUPACK._read_tempfile | train | def _read_tempfile(self, filename):
'''Read in and return file that's in the tempdir.
:param filename: Name of the file to read.
:type filename: str
'''
with open(os.path.join(self._tempdir, filename)) as f:
return f.read() | python | {
"resource": ""
} |
q2144 | NUPACK._pairs_to_np | train | def _pairs_to_np(self, pairlist, dim):
'''Given a set of pair probability lines, construct a numpy array.
:param pairlist: a list of pair probability triples
:type pairlist: list
:returns: An upper triangular matrix of pair probabilities augmented
with one extra column... | python | {
"resource": ""
} |
q2145 | _flip_feature | train | def _flip_feature(self, feature, parent_len):
'''Adjust a feature's location when flipping DNA.
:param feature: The feature to flip.
:type feature: coral.Feature
:param parent_len: The length of the sequence to which the feature belongs.
:type parent_len: int
'''
copy = feature.copy()
... | python | {
"resource": ""
} |
q2146 | DNA.ape | train | def ape(self, ape_path=None):
'''Open in ApE if `ApE` is in your command line path.'''
# TODO: simplify - make ApE look in PATH only
cmd = 'ApE'
if ape_path is None:
# Check for ApE in PATH
ape_executables = []
for path in os.environ['PATH'].split(os.p... | python | {
"resource": ""
} |
q2147 | DNA.circularize | train | def circularize(self):
'''Circularize linear DNA.
:returns: A circularized version of the current sequence.
:rtype: coral.DNA
'''
if self.top[-1].seq == '-' and self.bottom[0].seq == '-':
raise ValueError('Cannot circularize - termini disconnected.')
if self... | python | {
"resource": ""
} |
q2148 | DNA.flip | train | def flip(self):
'''Flip the DNA - swap the top and bottom strands.
:returns: Flipped DNA (bottom strand is now top strand, etc.).
:rtype: coral.DNA
'''
copy = self.copy()
copy.top, copy.bottom = copy.bottom, copy.top
copy.features = [_flip_feature(f, len(self)) ... | python | {
"resource": ""
} |
q2149 | DNA.linearize | train | def linearize(self, index=0):
'''Linearize circular DNA at an index.
:param index: index at which to linearize.
:type index: int
:returns: A linearized version of the current sequence.
:rtype: coral.DNA
:raises: ValueError if the input is linear DNA.
'''
... | python | {
"resource": ""
} |
q2150 | DNA.locate | train | def locate(self, pattern):
'''Find sequences matching a pattern. For a circular sequence, the
search extends over the origin.
:param pattern: str or NucleicAcidSequence for which to find matches.
:type pattern: str or coral.DNA
:returns: A list of top and bottom strand indices o... | python | {
"resource": ""
} |
q2151 | DNA.reverse_complement | train | def reverse_complement(self):
'''Reverse complement the DNA.
:returns: A reverse-complemented instance of the current sequence.
:rtype: coral.DNA
'''
copy = self.copy()
# Note: if sequence is double-stranded, swapping strand is basically
# (but not entirely) the... | python | {
"resource": ""
} |
q2152 | DNA.to_feature | train | def to_feature(self, name=None, feature_type='misc_feature'):
'''Create a feature from the current object.
:param name: Name for the new feature. Must be specified if the DNA
instance has no .name attribute.
:type name: str
:param feature_type: The type of feature (... | python | {
"resource": ""
} |
q2153 | RestrictionSite.cuts_outside | train | def cuts_outside(self):
'''Report whether the enzyme cuts outside its recognition site.
Cutting at the very end of the site returns True.
:returns: Whether the enzyme will cut outside its recognition site.
:rtype: bool
'''
for index in self.cut_site:
if inde... | python | {
"resource": ""
} |
q2154 | Primer.copy | train | def copy(self):
'''Generate a Primer copy.
:returns: A safely-editable copy of the current primer.
:rtype: coral.DNA
'''
return type(self)(self.anneal, self.tm, overhang=self.overhang,
name=self.name, note=self.note) | python | {
"resource": ""
} |
q2155 | _pair_deltas | train | def _pair_deltas(seq, pars):
'''Add up nearest-neighbor parameters for a given sequence.
:param seq: DNA sequence for which to sum nearest neighbors
:type seq: str
:param pars: parameter set to use
:type pars: dict
:returns: nearest-neighbor delta_H and delta_S sums.
:rtype: tuple of floats... | python | {
"resource": ""
} |
q2156 | breslauer_corrections | train | def breslauer_corrections(seq, pars_error):
'''Sum corrections for Breslauer '84 method.
:param seq: sequence for which to calculate corrections.
:type seq: str
:param pars_error: dictionary of error corrections
:type pars_error: dict
:returns: Corrected delta_H and delta_S parameters
:rtyp... | python | {
"resource": ""
} |
q2157 | MAFFT | train | def MAFFT(sequences, gap_open=1.53, gap_extension=0.0, retree=2):
'''A Coral wrapper for the MAFFT command line multiple sequence aligner.
:param sequences: A list of sequences to align.
:type sequences: List of homogeneous sequences (all DNA, or all RNA,
etc.)
:param gap_open: --o... | python | {
"resource": ""
} |
q2158 | repeats | train | def repeats(seq, size):
'''Count times that a sequence of a certain size is repeated.
:param seq: Input sequence.
:type seq: coral.DNA or coral.RNA
:param size: Size of the repeat to count.
:type size: int
:returns: Occurrences of repeats and how many
:rtype: tuple of the matched sequence a... | python | {
"resource": ""
} |
q2159 | gibson | train | def gibson(seq_list, linear=False, homology=10, tm=63.0):
'''Simulate a Gibson reaction.
:param seq_list: list of DNA sequences to Gibson
:type seq_list: list of coral.DNA
:param linear: Attempt to produce linear, rather than circular,
fragment from input fragments.
:type linear:... | python | {
"resource": ""
} |
q2160 | _fuse_last | train | def _fuse_last(working_list, homology, tm):
'''With one sequence left, attempt to fuse it to itself.
:param homology: length of terminal homology in bp.
:type homology: int
:raises: AmbiguousGibsonError if either of the termini are palindromic
(would bind self-self).
ValueErro... | python | {
"resource": ""
} |
q2161 | get_gene_id | train | def get_gene_id(gene_name):
'''Retrieve systematic yeast gene name from the common name.
:param gene_name: Common name for yeast gene (e.g. ADE2).
:type gene_name: str
:returns: Systematic name for yeast gene (e.g. YOR128C).
:rtype: str
'''
from intermine.webservice import Service
ser... | python | {
"resource": ""
} |
q2162 | _grow_overlaps | train | def _grow_overlaps(dna, melting_temp, require_even, length_max, overlap_min,
min_exception):
'''Grows equidistant overlaps until they meet specified constraints.
:param dna: Input sequence.
:type dna: coral.DNA
:param melting_temp: Ideal Tm of the overlaps, in degrees C.
:type me... | python | {
"resource": ""
} |
q2163 | _recalculate_overlaps | train | def _recalculate_overlaps(dna, overlaps, oligo_indices):
'''Recalculate overlap sequences based on the current overlap indices.
:param dna: Sequence being split into oligos.
:type dna: coral.DNA
:param overlaps: Current overlaps - a list of DNA sequences.
:type overlaps: coral.DNA list
:param o... | python | {
"resource": ""
} |
q2164 | _expand_overlap | train | def _expand_overlap(dna, oligo_indices, index, oligos, length_max):
'''Given an overlap to increase, increases smaller oligo.
:param dna: Sequence being split into oligos.
:type dna: coral.DNA
:param oligo_indices: index of oligo starts and stops
:type oligo_indices: list
:param index: index of... | python | {
"resource": ""
} |
q2165 | _adjust_overlap | train | def _adjust_overlap(positions_list, index, direction):
'''Increase overlap to the right or left of an index.
:param positions_list: list of overlap positions
:type positions_list: list
:param index: index of the overlap to increase.
:type index: int
:param direction: which side of the overlap t... | python | {
"resource": ""
} |
q2166 | OligoAssembly.design_assembly | train | def design_assembly(self):
'''Design the overlapping oligos.
:returns: Assembly oligos, and the sequences, Tms, and indices of their
overlapping regions.
:rtype: dict
'''
# Input parameters needed to design the oligos
length_range = self.kwargs['length... | python | {
"resource": ""
} |
q2167 | OligoAssembly.primers | train | def primers(self, tm=60):
'''Design primers for amplifying the assembled sequence.
:param tm: melting temperature (lower than overlaps is best).
:type tm: float
:returns: Primer list (the output of coral.design.primers).
:rtype: list
'''
self.primers = coral.des... | python | {
"resource": ""
} |
q2168 | OligoAssembly.write_map | train | def write_map(self, path):
'''Write genbank map that highlights overlaps.
:param path: full path to .gb file to write.
:type path: str
'''
starts = [index[0] for index in self.overlap_indices]
features = []
for i, start in enumerate(starts):
stop = s... | python | {
"resource": ""
} |
q2169 | coding_sequence | train | def coding_sequence(rna):
'''Extract coding sequence from an RNA template.
:param seq: Sequence from which to extract a coding sequence.
:type seq: coral.RNA
:param material: Type of sequence ('dna' or 'rna')
:type material: str
:returns: The first coding sequence (start codon -> stop codon) ma... | python | {
"resource": ""
} |
q2170 | Rebase.update | train | def update(self):
'''Update definitions.'''
# Download http://rebase.neb.com/rebase/link_withref to tmp
self._tmpdir = tempfile.mkdtemp()
try:
self._rebase_file = self._tmpdir + '/rebase_file'
print 'Downloading latest enzyme definitions'
url = 'http:/... | python | {
"resource": ""
} |
q2171 | Rebase._process_file | train | def _process_file(self):
'''Process rebase file into dict with name and cut site information.'''
print 'Processing file'
with open(self._rebase_file, 'r') as f:
raw = f.readlines()
names = [line.strip()[3:] for line in raw if line.startswith('<1>')]
seqs = [line.strip... | python | {
"resource": ""
} |
q2172 | tempdir | train | def tempdir(fun):
'''For use as a decorator of instance methods - creates a temporary dir
named self._tempdir and then deletes it after the method runs.
:param fun: function to decorate
:type fun: instance method
'''
def wrapper(*args, **kwargs):
self = args[0]
if os.path.isdir... | python | {
"resource": ""
} |
q2173 | convert_sequence | train | def convert_sequence(seq, to_material):
'''Translate a DNA sequence into peptide sequence.
The following conversions are supported:
Transcription (seq is DNA, to_material is 'rna')
Reverse transcription (seq is RNA, to_material is 'dna')
Translation (seq is RNA, to_material is 'peptide'... | python | {
"resource": ""
} |
q2174 | NucleicAcid.gc | train | def gc(self):
'''Find the frequency of G and C in the current sequence.'''
gc = len([base for base in self.seq if base == 'C' or base == 'G'])
return float(gc) / len(self) | python | {
"resource": ""
} |
q2175 | NucleicAcid.is_rotation | train | def is_rotation(self, other):
'''Determine whether two sequences are the same, just at different
rotations.
:param other: The sequence to check for rotational equality.
:type other: coral.sequence._sequence.Sequence
'''
if len(self) != len(other):
return Fal... | python | {
"resource": ""
} |
q2176 | NucleicAcid.linearize | train | def linearize(self, index=0):
'''Linearize the Sequence at an index.
:param index: index at which to linearize.
:type index: int
:returns: A linearized version of the current sequence.
:rtype: coral.sequence._sequence.Sequence
:raises: ValueError if the input is a linear... | python | {
"resource": ""
} |
q2177 | NucleicAcid.mw | train | def mw(self):
'''Calculate the molecular weight.
:returns: The molecular weight of the current sequence in amu.
:rtype: float
'''
counter = collections.Counter(self.seq.lower())
mw_a = counter['a'] * 313.2
mw_t = counter['t'] * 304.2
mw_g = counter['g'] ... | python | {
"resource": ""
} |
q2178 | five_resect | train | def five_resect(dna, n_bases):
'''Remove bases from 5' end of top strand.
:param dna: Sequence to resect.
:type dna: coral.DNA
:param n_bases: Number of bases cut back.
:type n_bases: int
:returns: DNA sequence resected at the 5' end by n_bases.
:rtype: coral.DNA
'''
new_instance =... | python | {
"resource": ""
} |
q2179 | _remove_end_gaps | train | def _remove_end_gaps(sequence):
'''Removes double-stranded gaps from ends of the sequence.
:returns: The current sequence with terminal double-strand gaps ('-')
removed.
:rtype: coral.DNA
'''
# Count terminal blank sequences
def count_end_gaps(seq):
gap = coral.DNA('-')
... | python | {
"resource": ""
} |
q2180 | needle | train | def needle(reference, query, gap_open=-15, gap_extend=0,
matrix=submat.DNA_SIMPLE):
'''Do a Needleman-Wunsch alignment.
:param reference: Reference sequence.
:type reference: coral.DNA
:param query: Sequence to align against the reference.
:type query: coral.DNA
:param gapopen: Penal... | python | {
"resource": ""
} |
q2181 | needle_msa | train | def needle_msa(reference, results, gap_open=-15, gap_extend=0,
matrix=submat.DNA_SIMPLE):
'''Create a multiple sequence alignment based on aligning every result
sequence against the reference, then inserting gaps until every aligned
reference is identical
'''
gap = '-'
# Convert ... | python | {
"resource": ""
} |
q2182 | needle_multi | train | def needle_multi(references, queries, gap_open=-15, gap_extend=0,
matrix=submat.DNA_SIMPLE):
'''Batch process of sequencing split over several cores. Acts just like
needle but sequence inputs are lists.
:param references: References sequence.
:type references: coral.DNA list
:param... | python | {
"resource": ""
} |
q2183 | import_global | train | def import_global(
name, modules=None, exceptions=DummyException, locals_=None,
globals_=None, level=-1):
'''Import the requested items into the global scope
WARNING! this method _will_ overwrite your global scope
If you have a variable named "path" and you call import_global('sys')
it ... | python | {
"resource": ""
} |
q2184 | camel_to_underscore | train | def camel_to_underscore(name):
'''Convert camel case style naming to underscore style naming
If there are existing underscores they will be collapsed with the
to-be-added underscores. Multiple consecutive capital letters will not be
split except for the last one.
>>> camel_to_underscore('SpamEggsA... | python | {
"resource": ""
} |
q2185 | timedelta_to_seconds | train | def timedelta_to_seconds(delta):
'''Convert a timedelta to seconds with the microseconds as fraction
Note that this method has become largely obsolete with the
`timedelta.total_seconds()` method introduced in Python 2.7.
>>> from datetime import timedelta
>>> '%d' % timedelta_to_seconds(timedelta(... | python | {
"resource": ""
} |
q2186 | get_terminal_size | train | def get_terminal_size(): # pragma: no cover
'''Get the current size of your terminal
Multiple returns are not always a good idea, but in this case it greatly
simplifies the code so I believe it's justified. It's not the prettiest
function but that's never really possible with cross-platform code.
... | python | {
"resource": ""
} |
q2187 | Skype.AsyncSearchUsers | train | def AsyncSearchUsers(self, Target):
"""Asynchronously searches for Skype users.
:Parameters:
Target : unicode
Search target (name or email address).
:return: A search identifier. It will be passed along with the results to the
`SkypeEvents.AsyncSearchUser... | python | {
"resource": ""
} |
q2188 | Skype.Attach | train | def Attach(self, Protocol=5, Wait=True):
"""Establishes a connection to Skype.
:Parameters:
Protocol : int
Minimal Skype protocol version.
Wait : bool
If set to False, blocks forever until the connection is established. Otherwise, timeouts
after t... | python | {
"resource": ""
} |
q2189 | Skype.Call | train | def Call(self, Id=0):
"""Queries a call object.
:Parameters:
Id : int
Call identifier.
:return: Call object.
:rtype: `call.Call`
"""
o = Call(self, Id)
o.Status # Test if such a call exists.
return o | python | {
"resource": ""
} |
q2190 | Skype.ChangeUserStatus | train | def ChangeUserStatus(self, Status):
"""Changes the online status for the current user.
:Parameters:
Status : `enums`.cus*
New online status for the user.
:note: This function waits until the online status changes. Alternatively, use the
`CurrentUserStatus` ... | python | {
"resource": ""
} |
q2191 | Skype.Chat | train | def Chat(self, Name=''):
"""Queries a chat object.
:Parameters:
Name : str
Chat name.
:return: A chat object.
:rtype: `chat.Chat`
"""
o = Chat(self, Name)
o.Status # Tests if such a chat really exists.
return o | python | {
"resource": ""
} |
q2192 | Skype.ClearCallHistory | train | def ClearCallHistory(self, Username='ALL', Type=chsAllCalls):
"""Clears the call history.
:Parameters:
Username : str
Skypename of the user. A special value of 'ALL' means that entries of all users should
be removed.
Type : `enums`.clt*
Call type.... | python | {
"resource": ""
} |
q2193 | Skype.Command | train | def Command(self, Command, Reply=u'', Block=False, Timeout=30000, Id=-1):
"""Creates an API command object.
:Parameters:
Command : unicode
Command string.
Reply : unicode
Expected reply. By default any reply is accepted (except errors which raise an
... | python | {
"resource": ""
} |
q2194 | Skype.Conference | train | def Conference(self, Id=0):
"""Queries a call conference object.
:Parameters:
Id : int
Conference Id.
:return: A conference object.
:rtype: `Conference`
"""
o = Conference(self, Id)
if Id <= 0 or not o.Calls:
raise SkypeError(0,... | python | {
"resource": ""
} |
q2195 | Skype.CreateChatWith | train | def CreateChatWith(self, *Usernames):
"""Creates a chat with one or more users.
:Parameters:
Usernames : str
One or more Skypenames of the users.
:return: A chat object
:rtype: `Chat`
:see: `Chat.AddMembers`
"""
return Chat(self, chop(self... | python | {
"resource": ""
} |
q2196 | Skype.CreateGroup | train | def CreateGroup(self, GroupName):
"""Creates a custom contact group.
:Parameters:
GroupName : unicode
Group name.
:return: A group object.
:rtype: `Group`
:see: `DeleteGroup`
"""
groups = self.CustomGroups
self._DoCommand('CREATE G... | python | {
"resource": ""
} |
q2197 | Skype.CreateSms | train | def CreateSms(self, MessageType, *TargetNumbers):
"""Creates an SMS message.
:Parameters:
MessageType : `enums`.smsMessageType*
Message type.
TargetNumbers : str
One or more target SMS numbers.
:return: An sms message object.
:rtype: `SmsMess... | python | {
"resource": ""
} |
q2198 | Skype.Greeting | train | def Greeting(self, Username=''):
"""Queries the greeting used as voicemail.
:Parameters:
Username : str
Skypename of the user.
:return: A voicemail object.
:rtype: `Voicemail`
"""
for v in self.Voicemails:
if Username and v.PartnerHandl... | python | {
"resource": ""
} |
q2199 | Skype.Message | train | def Message(self, Id=0):
"""Queries a chat message object.
:Parameters:
Id : int
Message Id.
:return: A chat message object.
:rtype: `ChatMessage`
"""
o = ChatMessage(self, Id)
o.Status # Test if such an id is known.
return o | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.