text_prompt stringlengths 157 13.1k | code_prompt stringlengths 7 19.8k ⌀ |
|---|---|
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run_scwrl(pdb, sequence, path=True):
"""Runs SCWRL on input PDB strong or path to PDB and a sequence string. Parameters pdb : str PDB string or a path to a P... |
if path:
with open(pdb, 'r') as inf:
pdb = inf.read()
pdb = pdb.encode()
sequence = sequence.encode()
try:
with tempfile.NamedTemporaryFile(delete=False) as scwrl_tmp,\
tempfile.NamedTemporaryFile(delete=False) as scwrl_seq,\
tempfile.NamedTem... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def parse_scwrl_out(scwrl_std_out, scwrl_pdb):
"""Parses SCWRL output and returns PDB and SCWRL score. Parameters scwrl_std_out : str Std out from SCWRL. scwrl_p... |
score = re.findall(
r'Total minimal energy of the graph = ([-0-9.]+)', scwrl_std_out)[0]
# Add temperature factors to SCWRL out
split_scwrl = scwrl_pdb.splitlines()
fixed_scwrl = []
for line in split_scwrl:
if len(line) < 80:
line += ' ' * (80 - len(line))
if re.... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def pack_sidechains(pdb, sequence, path=False):
"""Packs sidechains onto a given PDB file or string. Parameters pdb : str PDB string or a path to a PDB file. seq... |
scwrl_std_out, scwrl_pdb = run_scwrl(pdb, sequence, path=path)
return parse_scwrl_out(scwrl_std_out, scwrl_pdb) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def parse_pdb_file(self):
"""Runs the PDB parser.""" |
self.pdb_parse_tree = {'info': {},
'data': {
self.state: {}}
}
try:
for line in self.pdb_lines:
self.current_line = line
record_name = line[:6].strip()
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def proc_atom(self):
"""Processes an "ATOM" or "HETATM" record.""" |
atom_data = self.proc_line_coordinate(self.current_line)
(at_type, at_ser, at_name, alt_loc, res_name, chain_id, res_seq,
i_code, x, y, z, occupancy, temp_factor, element, charge) = atom_data
# currently active state
a_state = self.pdb_parse_tree['data'][self.state]
res... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def make_ampal(self):
"""Generates an AMPAL object from the parse tree. Notes ----- Will create an `Assembly` if there is a single state in the parese tree or an... |
data = self.pdb_parse_tree['data']
if len(data) > 1:
ac = AmpalContainer(id=self.id)
for state, chains in sorted(data.items()):
if chains:
ac.append(self.proc_state(chains, self.id +
'_state_{}'.fo... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def proc_state(self, state_data, state_id):
"""Processes a state into an `Assembly`. Parameters state_data : dict Contains information about the state, including... |
assembly = Assembly(assembly_id=state_id)
for k, chain in sorted(state_data.items()):
assembly._molecules.append(self.proc_chain(chain, assembly))
return assembly |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def proc_chain(self, chain_info, parent):
"""Converts a chain into a `Polymer` type object. Parameters chain_info : (set, OrderedDict) Contains a set of chain la... |
hetatom_filters = {
'nc_aas': self.check_for_non_canonical
}
polymer = False
chain_labels, chain_data = chain_info
chain_label = list(chain_labels)[0]
monomer_types = {x[2] for x in chain_labels if x[2]}
if ('P' in monomer_types) and ('N' in monomer_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def proc_monomer(self, monomer_info, parent, mon_cls=False):
"""Processes a records into a `Monomer`. Parameters monomer_info : (set, OrderedDict) Labels and dat... |
monomer_labels, monomer_data = monomer_info
if len(monomer_labels) > 1:
raise ValueError(
'Malformed PDB, single monomer id with '
'multiple labels. {}'.format(monomer_labels))
else:
monomer_label = list(monomer_labels)[0]
if mon_c... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def generate_antisense_sequence(sequence):
"""Creates the antisense sequence of a DNA strand.""" |
dna_antisense = {
'A': 'T',
'T': 'A',
'C': 'G',
'G': 'C'
}
antisense = [dna_antisense[x] for x in sequence[::-1]]
return ''.join(antisense) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_sequence(cls, sequence, phos_3_prime=False):
"""Creates a DNA duplex from a nucleotide sequence. Parameters sequence: str Nucleotide sequence. phos_3_pr... |
strand1 = NucleicAcidStrand(sequence, phos_3_prime=phos_3_prime)
duplex = cls(strand1)
return duplex |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_start_and_end(cls, start, end, sequence, phos_3_prime=False):
"""Creates a DNA duplex from a start and end point. Parameters start: [float, float, float... |
strand1 = NucleicAcidStrand.from_start_and_end(
start, end, sequence, phos_3_prime=phos_3_prime)
duplex = cls(strand1)
return duplex |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def generate_complementary_strand(strand1):
"""Takes a SingleStrandHelix and creates the antisense strand.""" |
rise_adjust = (
strand1.rise_per_nucleotide * strand1.axis.unit_tangent) * 2
strand2 = NucleicAcidStrand.from_start_and_end(
strand1.helix_end - rise_adjust, strand1.helix_start - rise_adjust,
generate_antisense_sequence(strand1.base_sequence),
phos_3_pri... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def total_accessibility(in_rsa, path=True):
"""Parses rsa file for the total surface accessibility data. Parameters in_rsa : str Path to naccess rsa file. path :... |
if path:
with open(in_rsa, 'r') as inf:
rsa = inf.read()
else:
rsa = in_rsa[:]
all_atoms, side_chains, main_chain, non_polar, polar = [
float(x) for x in rsa.splitlines()[-1].split()[1:]]
return all_atoms, side_chains, main_chain, non_polar, polar |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_aa_code(aa_letter):
""" Get three-letter aa code if possible. If not, return None. If three-letter code is None, will have to find this later from the fi... |
aa_code = None
if aa_letter != 'X':
for key, val in standard_amino_acids.items():
if key == aa_letter:
aa_code = val
return aa_code |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_aa_letter(aa_code):
""" Get one-letter version of aa_code if possible. If not, return 'X'. Parameters aa_code : str Three-letter amino acid code. Returns... |
aa_letter = 'X'
for key, val in standard_amino_acids.items():
if val == aa_code:
aa_letter = key
return aa_letter |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_aa_info(code):
"""Get dictionary of information relating to a new amino acid code not currently in the database. Notes ----- Use this function to get a d... |
letter = 'X'
# Try to get content from PDBE.
url_string = 'http://www.ebi.ac.uk/pdbe-srv/pdbechem/chemicalCompound/show/{0}'.format(code)
r = requests.get(url_string)
# Raise error if content not obtained.
if not r.ok:
raise IOError("Could not get to url {0}".format(url_string))
# ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_amino_acid_to_json(code, description, letter='X', modified=None, force_add=False):
""" Add an amino acid to the amino_acids.json file used to populate th... |
# If code is already in the dictionary, raise an error
if (not force_add) and code in amino_acids_dict.keys():
raise IOError("{0} is already in the amino_acids dictionary, with values: {1}".format(
code, amino_acids_dict[code]))
# Prepare data to be added.
add_code = code
add_c... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_polymers(cls, polymers):
"""Creates a `CoiledCoil` from a list of `HelicalHelices`. Parameters polymers : [HelicalHelix] List of `HelicalHelices`. """ |
n = len(polymers)
instance = cls(n=n, auto_build=False)
instance.major_radii = [x.major_radius for x in polymers]
instance.major_pitches = [x.major_pitch for x in polymers]
instance.major_handedness = [x.major_handedness for x in polymers]
instance.aas = [x.num_monomers ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_parameters(cls, n, aa=28, major_radius=None, major_pitch=None, phi_c_alpha=26.42, minor_helix_type='alpha', auto_build=True):
"""Creates a `CoiledCoil` ... |
instance = cls(n=n, auto_build=False)
instance.aas = [aa] * n
instance.phi_c_alphas = [phi_c_alpha] * n
instance.minor_helix_types = [minor_helix_type] * n
if major_pitch is not None:
instance.major_pitches = [major_pitch] * n
if major_radius is not None:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def tropocollagen( cls, aa=28, major_radius=5.0, major_pitch=85.0, auto_build=True):
"""Creates a model of a collagen triple helix. Parameters aa : int, optional... |
instance = cls.from_parameters(
n=3, aa=aa, major_radius=major_radius, major_pitch=major_pitch,
phi_c_alpha=0.0, minor_helix_type='collagen', auto_build=False)
instance.major_handedness = ['r'] * 3
# default z-shifts taken from rise_per_residue of collagen helix
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build(self):
"""Builds a model of a coiled coil protein using input parameters.""" |
monomers = [HelicalHelix(major_pitch=self.major_pitches[i],
major_radius=self.major_radii[i],
major_handedness=self.major_handedness[i],
aa=self.aas[i],
minor_helix_type=self.mino... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def find_max_rad_npnp(self):
"""Finds the maximum radius and npnp in the force field. Returns ------- (max_rad, max_npnp):
(float, float) Maximum radius and npn... |
max_rad = 0
max_npnp = 0
for res, atoms in self.items():
if res != 'KEY':
for atom, ff_params in self[res].items():
if max_rad < ff_params[1]:
max_rad = ff_params[1]
if max_npnp < ff_params[4]:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def parameter_struct_dict(self):
"""Dictionary containing PyAtomData structs for the force field.""" |
if self._parameter_struct_dict is None:
self._parameter_struct_dict = self._make_ff_params_dict()
elif self.auto_update_f_params:
new_hash = hash(
tuple([tuple(item)
for sublist in self.values()
for item in sublist.va... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run_reduce(input_file, path=True):
""" Runs reduce on a pdb or mmol file at the specified path. Notes ----- Runs Reduce programme to add missing protons to a... |
if path:
input_path = Path(input_file)
if not input_path.exists():
print('No file found at', path)
return None, None
else:
pathf = tempfile.NamedTemporaryFile()
encoded_input = input_file.encode()
pathf.write(encoded_input)
pathf.seek(0)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def reduce_output_path(path=None, pdb_name=None):
"""Defines location of Reduce output files relative to input files.""" |
if not path:
if not pdb_name:
raise NameError(
"Cannot save an output for a temporary file without a PDB"
"code specified")
pdb_name = pdb_name.lower()
output_path = Path(global_settings['structural_database']['path'],
p... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def output_reduce(input_file, path=True, pdb_name=None, force=False):
"""Runs Reduce on a pdb or mmol file and creates a new file with the output. Parameters inp... |
if path:
output_path = reduce_output_path(path=input_file)
else:
output_path = reduce_output_path(pdb_name=pdb_name)
if output_path.exists() and not force:
return output_path
reduce_mmol, reduce_message = run_reduce(input_file, path=path)
if not reduce_mmol:
return N... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def output_reduce_list(path_list, force=False):
"""Generates structure file with protons from a list of structure files.""" |
output_paths = []
for path in path_list:
output_path = output_reduce(path, force=force)
if output_path:
output_paths.append(output_path)
return output_paths |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def assembly_plus_protons(input_file, path=True, pdb_name=None, save_output=False, force_save=False):
"""Returns an Assembly with protons added by Reduce. Notes ... |
from ampal.pdb_parser import convert_pdb_to_ampal
if path:
input_path = Path(input_file)
if not pdb_name:
pdb_name = input_path.stem[:4]
reduced_path = reduce_output_path(path=input_path)
if reduced_path.exists() and not save_output and not force_save:
r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_start_and_end(cls, start, end, aa=None, helix_type='alpha'):
"""Creates a `Helix` between `start` and `end`. Parameters start : 3D Vector (tuple or list... |
start = numpy.array(start)
end = numpy.array(end)
if aa is None:
rise_per_residue = _helix_parameters[helix_type][1]
aa = int((numpy.linalg.norm(end - start) / rise_per_residue) + 1)
instance = cls(aa=aa, helix_type=helix_type)
instance.move_to(start=star... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build(self):
"""Build straight helix along z-axis, starting with CA1 on x-axis""" |
ang_per_res = (2 * numpy.pi) / self.residues_per_turn
atom_offsets = _atom_offsets[self.helix_type]
if self.handedness == 'l':
handedness = -1
else:
handedness = 1
atom_labels = ['N', 'CA', 'C', 'O']
if all([x in atom_offsets.keys() for x in atom... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_start_and_end(cls, start, end, aa=None, major_pitch=225.8, major_radius=5.07, major_handedness='l', minor_helix_type='alpha', orientation=1, phi_c_alpha=... |
start = numpy.array(start)
end = numpy.array(end)
if aa is None:
minor_rise_per_residue = _helix_parameters[minor_helix_type][1]
aa = int((numpy.linalg.norm(end - start) /
minor_rise_per_residue) + 1)
instance = cls(
aa=aa, major... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def curve(self):
"""Curve of the super helix.""" |
return HelicalCurve.pitch_and_radius(
self.major_pitch, self.major_radius,
handedness=self.major_handedness) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def curve_primitive(self):
"""`Primitive` of the super-helical curve.""" |
curve = self.curve
curve.axis_start = self.helix_start
curve.axis_end = self.helix_end
coords = curve.get_coords(
n_points=(self.num_monomers + 1), spacing=self.minor_rise_per_residue)
if self.orientation == -1:
coords.reverse()
return Primitive.f... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def major_rise_per_monomer(self):
"""Rise along super-helical axis per monomer.""" |
return numpy.cos(numpy.deg2rad(self.curve.alpha)) * self.minor_rise_per_residue |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def minor_residues_per_turn(self, minor_repeat=None):
"""Calculates the number of residues per turn of the minor helix. Parameters minor_repeat : float, optional... |
if minor_repeat is None:
minor_rpt = _helix_parameters[self.minor_helix_type][0]
else:
# precession angle in radians
precession = self.curve.t_from_arc_length(
minor_repeat * self.minor_rise_per_residue)
if self.orientation == -1:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build(self):
"""Builds the `HelicalHelix`.""" |
helical_helix = Polypeptide()
primitive_coords = self.curve_primitive.coordinates
helices = [Helix.from_start_and_end(start=primitive_coords[i],
end=primitive_coords[i + 1],
helix_type=self.minor_helix_type,... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def rotate_monomers(self, angle, radians=False):
""" Rotates each Residue in the Polypeptide. Notes ----- Each monomer is rotated about the axis formed between i... |
if radians:
angle = numpy.rad2deg(angle)
for i in range(len(self.primitive) - 1):
axis = self.primitive[i + 1]['CA'] - self.primitive[i]['CA']
point = self.primitive[i]['CA']._vector
self[i].rotate(angle=angle, axis=axis, point=point)
return |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def side_chain_centres(assembly, masses=False):
""" PseudoGroup containing side_chain centres of each Residue in each Polypeptide in Assembly. Notes ----- Each P... |
if masses:
elts = set([x.element for x in assembly.get_atoms()])
masses_dict = {e: element_data[e]['atomic mass'] for e in elts}
pseudo_monomers = []
for chain in assembly:
if isinstance(chain, Polypeptide):
centres = OrderedDict()
for r in chain.get_monomers... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def cluster_helices(helices, cluster_distance=12.0):
""" Clusters helices according to the minimum distance between the line segments representing their backbone... |
condensed_distance_matrix = []
for h1, h2 in itertools.combinations(helices, 2):
md = minimal_distance_between_lines(h1[0]['CA']._vector, h1[-1]['CA']._vector,
h2[0]['CA']._vector, h2[-1]['CA']._vector, segments=True)
condensed_distance_matrix.append(... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def find_kihs(assembly, hole_size=4, cutoff=7.0):
""" KnobIntoHoles between residues of different chains in assembly. Notes ----- A KnobIntoHole is a found when ... |
pseudo_group = side_chain_centres(assembly=assembly, masses=False)
pairs = itertools.permutations(pseudo_group, 2)
kihs = []
for pp_1, pp_2 in pairs:
for r in pp_1:
close_atoms = pp_2.is_within(cutoff, r)
# kihs occur between residue and (hole_size) closest side-chains o... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def find_contiguous_packing_segments(polypeptide, residues, max_dist=10.0):
""" Assembly containing segments of polypeptide, divided according to separation of c... |
segments = Assembly(assembly_id=polypeptide.ampal_parent.id)
residues_in_polypeptide = list(sorted(residues.intersection(set(polypeptide.get_monomers())),
key=lambda x: int(x.id)))
if not residues_in_polypeptide:
return segments
# residue_pots contains ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def gen_reference_primitive(polypeptide, start, end):
""" Generates a reference Primitive for a Polypeptide given start and end coordinates. Notes ----- Uses the... |
prim = polypeptide.primitive
q = find_foot(a=start, b=end, p=prim.coordinates[0])
ax = Axis(start=q, end=end)
# flip axis if antiparallel to polypeptide_vector
if not is_acute(polypeptide_vector(polypeptide), ax.unit_tangent):
ax = Axis(start=end, end=q)
arc_length = 0
points = [ax.... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_helices(cls, assembly, cutoff=7.0, min_helix_length=8):
""" Generate KnobGroup from the helices in the assembly - classic socket functionality. Notes --... |
cutoff = float(cutoff)
helices = Assembly([x for x in assembly.helices if len(x) >= min_helix_length])
if len(helices) <= 1:
return None
# reassign ampal_parents
helices.relabel_polymers([x.ampal_parent.id for x in helices])
for i, h in enumerate(helices):
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def knob_subgroup(self, cutoff=7.0):
""" KnobGroup where all KnobsIntoHoles have max_kh_distance <= cutoff. """ |
if cutoff > self.cutoff:
raise ValueError("cutoff supplied ({0}) cannot be greater than self.cutoff ({1})".format(cutoff,
self.cutoff))
return KnobGroup(monomers=[x for x in self.get_monomer... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def graph(self):
""" Returns MultiDiGraph from kihs. Nodes are helices and edges are kihs. """ |
g = networkx.MultiDiGraph()
edge_list = [(x.knob_helix, x.hole_helix, x.id, {'kih': x}) for x in self.get_monomers()]
g.add_edges_from(edge_list)
return g |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def filter_graph(g, cutoff=7.0, min_kihs=2):
""" Get subgraph formed from edges that have max_kh_distance < cutoff. Parameters g : MultiDiGraph representing KIHs... |
edge_list = [e for e in g.edges(keys=True, data=True) if e[3]['kih'].max_kh_distance <= cutoff]
if min_kihs > 0:
c = Counter([(e[0], e[1]) for e in edge_list])
# list of nodes that share > min_kihs edges with at least one other node.
node_list = set(list(itertools.ch... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_coiledcoil_region(self, cc_number=0, cutoff=7.0, min_kihs=2):
""" Assembly containing only assigned regions (i.e. regions with contiguous KnobsIntoHoles.... |
g = self.filter_graph(self.graph, cutoff=cutoff, min_kihs=min_kihs)
ccs = sorted(networkx.connected_component_subgraphs(g, copy=True),
key=lambda x: len(x.nodes()), reverse=True)
cc = ccs[cc_number]
helices = [x for x in g.nodes() if x.number in cc.nodes... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def daisy_chain_graph(self):
""" Directed graph with edges from knob residue to each hole residue for each KnobIntoHole in self. """ |
g = networkx.DiGraph()
for x in self.get_monomers():
for h in x.hole:
g.add_edge(x.knob, h)
return g |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def knob_end(self):
""" Coordinates of the end of the knob residue (atom in side-chain furthest from CB atom. Returns CA coordinates for GLY. """ |
side_chain_atoms = self.knob_residue.side_chain
if not side_chain_atoms:
return self.knob_residue['CA']
distances = [distance(self.knob_residue['CB'], x) for x in side_chain_atoms]
max_d = max(distances)
knob_end_atoms = [atom for atom, d in zip(side_chain_atoms, dis... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def max_knob_end_distance(self):
""" Maximum distance between knob_end and each of the hole side-chain centres. """ |
return max([distance(self.knob_end, h) for h in self.hole]) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def base_install():
"""Generates configuration setting for required functionality of ISAMBARD.""" |
# scwrl
scwrl = {}
print('{BOLD}{HEADER}Generating configuration files for ISAMBARD.{END_C}\n'
'All required input can use tab completion for paths.\n'
'{BOLD}Setting up SCWRL 4.0 (Recommended){END_C}'.format(**text_colours))
scwrl_path = get_user_path('Please provide a path to your... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def optional_install():
"""Generates configuration settings for optional functionality of ISAMBARD.""" |
# reduce
print('{BOLD}Setting up Reduce (optional){END_C}'.format(**text_colours))
reduce = {}
reduce_path = get_user_path('Please provide a path to your reduce executable.', required=False)
reduce['path'] = str(reduce_path)
reduce['folder'] = str(reduce_path.parent) if reduce_path else ''
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def pdb(self):
"""Generates a PDB string for the `PseudoMonomer`.""" |
pdb_str = write_pdb(
[self], ' ' if not self.tags['chain_id'] else self.tags['chain_id'])
return pdb_str |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def from_coordinates(cls, coordinates):
"""Creates a `Primitive` from a list of coordinates.""" |
prim = cls()
for coord in coordinates:
pm = PseudoMonomer(ampal_parent=prim)
pa = PseudoAtom(coord, ampal_parent=pm)
pm.atoms = OrderedDict([('CA', pa)])
prim.append(pm)
prim.relabel_all()
return prim |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def rise_per_residue(self):
"""The rise per residue at each point on the Primitive. Notes ----- Each element of the returned list is the rise per residue, at a p... |
rprs = [distance(self[i]['CA'], self[i + 1]['CA'])
for i in range(len(self) - 1)]
rprs.append(None)
return rprs |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def sequence(self):
"""Returns the sequence of the `Polynucleotide` as a string. Returns ------- sequence : str String of the monomer sequence of the `Polynucleo... |
seq = [x.mol_code for x in self._monomers]
return ' '.join(seq) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run_dssp(pdb, path=True, outfile=None):
"""Uses DSSP to find helices and extracts helices from a pdb file or string. Parameters pdb : str Path to pdb file or... |
if not path:
if type(pdb) == str:
pdb = pdb.encode()
try:
temp_pdb = tempfile.NamedTemporaryFile(delete=False)
temp_pdb.write(pdb)
temp_pdb.seek(0)
dssp_out = subprocess.check_output(
[global_settings['dssp']['path'], temp_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def extract_solvent_accessibility_dssp(in_dssp, path=True):
"""Uses DSSP to extract solvent accessibilty information on every residue. Notes ----- For more infor... |
if path:
with open(in_dssp, 'r') as inf:
dssp_out = inf.read()
else:
dssp_out = in_dssp[:]
dssp_residues = []
go = False
for line in dssp_out.splitlines():
if go:
try:
res_num = int(line[5:10].strip())
chain = line[10:1... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def extract_helices_dssp(in_pdb):
"""Uses DSSP to find alpha-helices and extracts helices from a pdb file. Returns a length 3 list with a helix id, the chain id ... |
from ampal.pdb_parser import split_pdb_lines
dssp_out = subprocess.check_output(
[global_settings['dssp']['path'], in_pdb])
helix = 0
helices = []
h_on = False
for line in dssp_out.splitlines():
dssp_line = line.split()
try:
if dssp_line[4] == 'H':
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def extract_pp_helices(in_pdb):
"""Uses DSSP to find polyproline helices in a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containi... |
t_phi = -75.0
t_phi_d = 29.0
t_psi = 145.0
t_psi_d = 29.0
pph_dssp = subprocess.check_output(
[global_settings['dssp']['path'], in_pdb])
dssp_residues = []
go = False
for line in pph_dssp.splitlines():
if go:
res_num = int(line[:5].strip())
chain... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def main():
""" This will offer a step by step guide to create a new run in TestRail, update tests in the run with results, and close the run """ |
# Parse command line arguments
args = get_args()
# Instantiate the TestRail client
# Use the CLI argument to identify which project to work with
tr = TestRail(project_dict[args.project])
# Get a reference to the current project
project = tr.project(project_dict[args.project])
# To cr... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def memory():
"""Determine the machine's memory specifications. Returns ------- mem_info : dictonary Holds the current values for the total, free and used memory... |
mem_info = {}
if platform.linux_distribution()[0]:
with open('/proc/meminfo') as file:
c = 0
for line in file:
lst = line.split()
if str(lst[0]) == 'MemTotal:':
mem_info['total'] = int(lst[1])
elif str(lst[0])... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_chunk_size(N, n):
"""Given a dimension of size 'N', determine the number of rows or columns that can fit into memory. Parameters N : int The size of one ... |
mem_free = memory()['free']
if mem_free > 60000000:
chunks_size = int(((mem_free - 10000000) * 1000) / (4 * n * N))
return chunks_size
elif mem_free > 40000000:
chunks_size = int(((mem_free - 7000000) * 1000) / (4 * n * N))
return chunks_size
elif mem_free > 14000000:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def all_floating_ips(self):
""" Lists all of the Floating IPs available on the account. """ |
if self.api_version == 2:
json = self.request('/floating_ips')
return json['floating_ips']
else:
raise DoError(v2_api_required_str) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def new_floating_ip(self, **kwargs):
""" Creates a Floating IP and assigns it to a Droplet or reserves it to a region. """ |
droplet_id = kwargs.get('droplet_id')
region = kwargs.get('region')
if self.api_version == 2:
if droplet_id is not None and region is not None:
raise DoError('Only one of droplet_id and region is required to create a Floating IP. ' \
'Set one of ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def destroy_floating_ip(self, ip_addr):
""" Deletes a Floating IP and removes it from the account. """ |
if self.api_version == 2:
self.request('/floating_ips/' + ip_addr, method='DELETE')
else:
raise DoError(v2_api_required_str) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def assign_floating_ip(self, ip_addr, droplet_id):
""" Assigns a Floating IP to a Droplet. """ |
if self.api_version == 2:
params = {'type': 'assign','droplet_id': droplet_id}
json = self.request('/floating_ips/' + ip_addr + '/actions', params=params, method='POST')
return json['action']
else:
raise DoError(v2_api_required_str) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def unassign_floating_ip(self, ip_addr):
""" Unassign a Floating IP from a Droplet. The Floating IP will be reserved in the region but not assigned to a Droplet.... |
if self.api_version == 2:
params = {'type': 'unassign'}
json = self.request('/floating_ips/' + ip_addr + '/actions', params=params, method='POST')
return json['action']
else:
raise DoError(v2_api_required_str) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_floating_ip_actions(self, ip_addr):
""" Retrieve a list of all actions that have been executed on a Floating IP. """ |
if self.api_version == 2:
json = self.request('/floating_ips/' + ip_addr + '/actions')
return json['actions']
else:
raise DoError(v2_api_required_str) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_floating_ip_action(self, ip_addr, action_id):
""" Retrieve the status of a Floating IP action. """ |
if self.api_version == 2:
json = self.request('/floating_ips/' + ip_addr + '/actions/' + action_id)
return json['action']
else:
raise DoError(v2_api_required_str) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def raw_sign(message, secret):
"""Sign a message.""" |
digest = hmac.new(secret, message, hashlib.sha256).digest()
return base64.b64encode(digest) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_signature_from_signature_string(self, signature):
"""Return the signature from the signature header or None.""" |
match = self.SIGNATURE_RE.search(signature)
if not match:
return None
return match.group(1) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_headers_from_signature(self, signature):
"""Returns a list of headers fields to sign. According to http://tools.ietf.org/html/draft-cavage-http-signature... |
match = self.SIGNATURE_HEADERS_RE.search(signature)
if not match:
return ['date']
headers_string = match.group(1)
return headers_string.split() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def header_canonical(self, header_name):
"""Translate HTTP headers to Django header names.""" |
# Translate as stated in the docs:
# https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.META
header_name = header_name.lower()
if header_name == 'content-type':
return 'CONTENT-TYPE'
elif header_name == 'content-length':
r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build_dict_to_sign(self, request, signature_headers):
"""Build a dict with headers and values used in the signature. "signature_headers" is a list of lowerca... |
d = {}
for header in signature_headers:
if header == '(request-target)':
continue
d[header] = request.META.get(self.header_canonical(header))
return d |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def build_signature(self, user_api_key, user_secret, request):
"""Return the signature for the request.""" |
path = request.get_full_path()
sent_signature = request.META.get(
self.header_canonical('Authorization'))
signature_headers = self.get_headers_from_signature(sent_signature)
unsigned = self.build_dict_to_sign(request, signature_headers)
# Sign string and compare.
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def camel_to_snake_case(string):
"""Converts 'string' presented in camel case to snake case. e.g.: CamelCase => snake_case """ |
s = _1.sub(r'\1_\2', string)
return _2.sub(r'\1_\2', s).lower() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def url_assembler(query_string, no_redirect=0, no_html=0, skip_disambig=0):
"""Assembler of parameters for building request query. Args: query_string: Query to b... |
params = [('q', query_string.encode("utf-8")), ('format', 'json')]
if no_redirect:
params.append(('no_redirect', 1))
if no_html:
params.append(('no_html', 1))
if skip_disambig:
params.append(('skip_disambig', 1))
return '/?' + urlencode(params) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def query(query_string, secure=False, container='namedtuple', verbose=False, user_agent=api.USER_AGENT, no_redirect=False, no_html=False, skip_disambig=False):
"... |
if container not in Hook.containers:
raise exc.DuckDuckArgumentError(
"Argument 'container' must be one of the values: "
"{0}".format(', '.join(Hook.containers)))
headers = {"User-Agent": user_agent}
url = url_assembler(
query_string,
no_redirect=no_redirect... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create(type_dict, *type_parameters):
""" Construct a List containing type 'klazz'. """ |
assert len(type_parameters) == 1
klazz = TypeFactory.new(type_dict, *type_parameters[0])
assert isclass(klazz)
assert issubclass(klazz, Object)
return TypeMetaclass('%sList' % klazz.__name__, (ListContainer,), {'TYPE': klazz}) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
| def load_file(filename):
"Runs the given scent.py file."
mod_name = '.'.join(os.path.basename(filename).split('.')[:-1])
mod_path = os.path.dirname(filename)
if mod_name in sys.modules:
del sys.modules[mod_name]
if mod_path not in set(sys.modules.keys()):
sys.path.insert(0, mod_path... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def new(type_dict, type_factory, *type_parameters):
""" Create a fully reified type from a type schema. """ |
type_tuple = (type_factory,) + type_parameters
if type_tuple not in type_dict:
factory = TypeFactory.get_factory(type_factory)
reified_type = factory.create(type_dict, *type_parameters)
type_dict[type_tuple] = reified_type
return type_dict[type_tuple] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def wrap(sig):
"""Convert a Python class into a type signature.""" |
if isclass(sig) and issubclass(sig, Object):
return TypeSignature(sig)
elif isinstance(sig, TypeSignature):
return sig |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def trigger_modified(self, filepath):
"""Triggers modified event if the given filepath mod time is newer.""" |
mod_time = self._get_modified_time(filepath)
if mod_time > self._watched_files.get(filepath, 0):
self._trigger('modified', filepath)
self._watched_files[filepath] = mod_time |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def trigger_created(self, filepath):
"""Triggers created event if file exists.""" |
if os.path.exists(filepath):
self._trigger('created', filepath) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def trigger_deleted(self, filepath):
"""Triggers deleted event if the flie doesn't exist.""" |
if not os.path.exists(filepath):
self._trigger('deleted', filepath) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def log(self, *message):
""" Logs a messate to a defined io stream if available. """ |
if self._logger is None:
return
s = " ".join([str(m) for m in message])
self._logger.write(s+'\n')
self._logger.flush() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def in_repo(self, filepath):
""" This excludes repository directories because they cause some exceptions occationally. """ |
filepath = set(filepath.replace('\\', '/').split('/'))
for p in ('.git', '.hg', '.svn', '.cvs', '.bzr'):
if p in filepath:
return True
return False |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _modify_event(self, event_name, method, func):
""" Wrapper to call a list's method from one of the events """ |
if event_name not in self.ALL_EVENTS:
raise TypeError(('event_name ("%s") can only be one of the '
'following: %s') % (event_name,
repr(self.ALL_EVENTS)))
if not isinstance(func, collections.Callable):
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _watch_file(self, filepath, trigger_event=True):
"""Adds the file's modified time into its internal watchlist.""" |
is_new = filepath not in self._watched_files
if trigger_event:
if is_new:
self.trigger_created(filepath)
else:
self.trigger_modified(filepath)
try:
self._watched_files[filepath] = self._get_modified_time(filepath)
excep... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _unwatch_file(self, filepath, trigger_event=True):
""" Removes the file from the internal watchlist if exists. """ |
if filepath not in self._watched_files:
return
if trigger_event:
self.trigger_deleted(filepath)
del self._watched_files[filepath] |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _is_modified(self, filepath):
""" Returns True if the file has been modified since last seen. Will return False if the file has not been seen before. """ |
if self._is_new(filepath):
return False
mtime = self._get_modified_time(filepath)
return self._watched_files[filepath] < mtime |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def loop(self, sleep_time=1, callback=None):
""" Goes into a blocking IO loop. If polling is used, the sleep_time is the interval, in seconds, between polls. """ |
self.log("No supported libraries found: using polling-method.")
self._running = True
self.trigger_init()
self._scan(trigger=False) # put after the trigger
if self._warn:
print("""
You should install a third-party library so I don't eat CPU.
Supported libraries are:... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run(sniffer_instance=None, wait_time=0.5, clear=True, args=(), debug=False):
""" Runs the auto tester loop. Internally, the runner instanciates the sniffer_c... |
if sniffer_instance is None:
sniffer_instance = ScentSniffer()
if debug:
scanner = Scanner(
sniffer_instance.watch_paths,
scent=sniffer_instance.scent, logger=sys.stdout)
else:
scanner = Scanner(
sniffer_instance.watch_paths, scent=sniffer_instan... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def main(sniffer_instance=None, test_args=(), progname=sys.argv[0], args=sys.argv[1:]):
""" Runs the program. This is used when you want to run this program stan... |
parser = OptionParser(version="%prog " + __version__)
parser.add_option('-w', '--wait', dest="wait_time", metavar="TIME",
default=0.5, type="float",
help="Wait time, in seconds, before possibly rerunning"
"tests. (default: %default)")
parser... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set_up(self, test_args=(), clear=True, debug=False):
""" Sets properties right before calling run. ``test_args`` The arguments to pass to the test runner. ``... |
self.test_args = test_args
self.debug, self.clear = debug, clear |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def observe_scanner(self, scanner):
""" Hooks into multiple events of a scanner. """ |
scanner.observe(scanner.ALL_EVENTS,
self.absorb_args(self.modules.restore))
if self.clear:
scanner.observe(scanner.ALL_EVENTS,
self.absorb_args(self.clear_on_run))
scanner.observe(scanner.ALL_EVENTS, self.absorb_args(self._run))
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def clear_on_run(self, prefix="Running Tests:"):
"""Clears console before running the tests.""" |
if platform.system() == 'Windows':
os.system('cls')
else:
os.system('clear')
if prefix:
print(prefix) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def run(self):
""" Runs the unit test framework. Can be overridden to run anything. Returns True on passing and False on failure. """ |
try:
import nose
arguments = [sys.argv[0]] + list(self.test_args)
return nose.run(argv=arguments)
except ImportError:
print()
print("*** Nose library missing. Please install it. ***")
print()
raise |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.