rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
paramaters = ['API_KEY', 'method', 'auth_token'] for item in params.items(): paramaters.append(item[0]) paramaters.sort() api_string = [API_SECRET] for item in paramaters: for chocolate in params.items(): if item == chocolate[0]: api_string.append(item) api_string.append(str(chocolate[1])) if item == 'method': api_str... | full_params = params full_params['method'] = method return '&auth_token=%s&api_sig=%s' % (token, _get_api_sig(full_params) ) | def _get_auth_url_suffix(method, auth, params): """Figure out whether we want to authorize, and if so, construct a suitable URL suffix to pass to the Flickr API.""" authentication = False # auth may be passed in via the API, AUTH may be set globally (in the same # manner as API_KEY, etc). We do a few more checks than ... |
url = '%s%s/%s' % (HOST, API, _get_auth_url_suffix(method, auth, params)) payload = 'api_key=%s&method=%s&%s'% \ (API_KEY, method, urlencode(params)) | url = '%s%s/?api_key=%s&method=%s&%s'% \ (HOST, API, API_KEY, method, _get_auth_url_suffix(method, auth, params)) payload = '%s' % (urlencode(params)) | def _dopost(method, auth=False, **params): #uncomment to check you aren't killing the flickr server #print "***** do post %s" % method params = _prepare_params(params) url = '%s%s/%s' % (HOST, API, _get_auth_url_suffix(method, auth, params)) payload = 'api_key=%s&method=%s&%s'% \ (API_KEY, method, urlencode(params)) ... |
print "\n".join(content) + "\n" | def getContent(self): """ """ content = ["%s: %s" % (k, v) for k,v in self.options.iteritems()] | |
if protein.pdb_date < pdb_date: data['pdb_date'] = pdb_date return True | data['pdb_date'] = pdb_date return protein.pdb_date < pdb_date | def pdb_file_is_newer(self, data): """ Compares if the pdb file used as an input is newer than data already in the database. This is used to prevent processing proteins if they do not need to be processed """ code = data['code'] path = './pdb/pdb%s.ent.gz' % code.lower() print path if os.path.exists(path): pdb_date =... |
print ' %s proteins' % len(residues) | print ' %s residues' % len(residues) | def process_pdb(self, data): """ Process an individual pdb file """ try: residue_props = None code = data['code'] chains_filter = data['chains'] if data.has_key('chains') else None print 'DATA', data filename = 'pdb%s.ent.gz' % code.lower() print ' Processing: ', code |
atoms = {} for atom in res.get_unpacked_list(): if atom.get_altloc() in ('A', ' '): atoms[atom.name] = atom | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... | |
N = res['N'].get_vector() CA = res['CA'].get_vector() C = res['C'].get_vector() CB = res['CB'].get_vector() if res.has_id('CB') else None O = res['O'].get_vector() | N = atoms['N'].get_vector() CA = atoms['CA'].get_vector() C = atoms['C'].get_vector() CB = atoms['CB'].get_vector() if atoms.has_key('CB') else None O = atoms['O'].get_vector() | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... |
for a in res.child_list: if a.name in ('N', 'CA', 'C', 'O','OXT'): main_chain.append(a.get_bfactor()) elif a.name in ('H'): | for name in atoms: if name in ('N', 'CA', 'C', 'O','OXT'): main_chain.append(atoms[name].get_bfactor()) elif name in ('H'): | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... |
side_chain.append(a.get_bfactor()) | side_chain.append(atoms[name].get_bfactor()) | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... |
sys.exit(0) | def process_pdb(self, data): """ Process an individual pdb file """ try: residue_props = None code = data['code'] chains_filter = data['chains'] if data.has_key('chains') else None filename = 'pdb%s.ent.gz' % code.lower() print ' Processing: ', code | |
all_mainchain = res.has_id('N') and res.has_id('CA') and res.has_id('C') and res.has_id('O') | all_mainchain = ('N' in atoms) and ('CA' in atoms) and ('C' in atoms) and ('O' in atoms) | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... |
if avg: | if avg and bin[avg]: | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
cases = ' '.join(['WHEN %s THEN %s' % (k,v) if v else '' for k,v in torsion_avgs[field[0]].items()]) avgs = "CASE CONCAT(FLOOR((%s-%s)/%s),':',FLOOR((%s-%s)/%s)) %s END" % (x_field, x, xbin, y_field, y, ybin, cases) annotations = {stddev:DirectionalStdDev(field[1], avg=avgs)} bin_where_clause = ['NOT %s.%s IS NULL' % (... | cases = ' '.join(['WHEN %s THEN %s' % (k,v) for k,v in filter(lambda x:x[1], torsion_avgs[field[0]].items())]) if cases: avgs = "CASE CONCAT(FLOOR((%s-%s)/%s),':',FLOOR((%s-%s)/%s)) %s END" % (x_field, x, xbin, y_field, y, ybin, cases) annotations = {stddev:DirectionalStdDev(field[1], avg=avgs)} bin_where_clause = ['NO... | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
if self.ref in ANGLES: meanPropAvg,stdPropAvg = getCircularStats([bin['%s_avg'%self.refString] for bin in self.bins.values()], len(self.bins)) stdPropAvgXSigma = 180 if stdPropAvg > 60 else sig*stdPropAvg | key = '%s_avg'%self.refString values = [bin[key] for bin in filter(lambda x:x[key], self.bins.values())] if len(values): if self.ref in ANGLES: meanPropAvg,stdPropAvg = getCircularStats(values, len(values)) stdPropAvgXSigma = 180 if stdPropAvg > 60 else sig*stdPropAvg else: meanPropAvg,stdPropAvg = getLinearStats(value... | def render_bins(self, svg, xOffset, yOffset, binWidth, binHeight): """ Renders the already calculated bins. """ #cache variables sig = self.sigmaVal |
meanPropAvg,stdPropAvg = getLinearStats([bin['%s_avg'%self.refString] for bin in self.bins.values()], len(self.bins)) minPropAvg = meanPropAvg - sig*stdPropAvg maxPropAvg = meanPropAvg + sig*stdPropAvg | stdPropAvgXSigma = 0 | def render_bins(self, svg, xOffset, yOffset, binWidth, binHeight): """ Renders the already calculated bins. """ #cache variables sig = self.sigmaVal |
residue = chain.residues.get(oldID=residue_props['oldID']) | residue = chain.residues.get(oldID=str(residue_props['oldID'])) | def process_pdb(self, data): """ Process an individual pdb file """ try: residue_props = None code = data['code'] chains_filter = data['chains'] if data.has_key('chains') else None print 'DATA', data filename = 'pdb%s.ent.gz' % code.lower() print ' Processing: ', code |
self.prefix = prefix | def __init__(self, angles, fields, prefix, queryset): self.angles = angles self.fields = fields self.combined = angles+fields | |
annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAvg(field) | annotations['min_%s' % field] = Min(p%field) annotations['max_%s' % field] = Max(p%field) annotations['avg_%s' % field] = DirectionalAvg(p%field) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = Avg(field) annotations['stddev_%s' % field] = StdDev(field) | annotations['min_%s' % field] = Min(p%field) annotations['max_%s' % field] = Max(p%field) annotations['avg_%s' % field] = Avg(p%field) annotations['stddev_%s' % field] = StdDev(p%field) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
query = query.values('aa') | query = query.values(p%'aa') | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
aa_rows[row['aa']] = row | aa_rows[row[aa_field]] = row | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
annotations['stddev_%s' % field] = DirectionalStdDev(field, avg=avg) | annotations['stddev_%s' % field] = DirectionalStdDev(p%field, avg=avg) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
outer_row['stddev_%s' % field] = None | row['stddev_%s' % field] = None | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
query = query.values('aa') | query = query.values(aa_field) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
outer_row = aa_rows[row['aa']] for field in self.angles: outer_row.update(row) | outer_row = aa_rows[row[aa_field]] outer_row.update(row) if self.prefix != '%s': for row in results: row['aa'] = row[aa_field] del row[aa_field] | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAvg(field) | annotations['min_%s' % field] = Min(p%field) annotations['max_%s' % field] = Max(p%field) annotations['avg_%s' % field] = DirectionalAvg(p%field) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = Avg(field) annotations['stddev_%s' % field] = StdDev(field) | annotations['min_%s' % field] = Min(p%field) annotations['max_%s' % field] = Max(p%field) annotations['avg_%s' % field] = Avg(p%field) annotations['stddev_%s' % field] = StdDev(p%field) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ annotations = {} aa_rows = {} # main aggregate functions for field in self.angles: annotations['min_%s' % field] = Min(field) annotations['max_%s' % field] = Max(field) annotations['avg_%s' % field] = DirectionalAv... |
residue_dict['%s_%s_%s' % (atom_names[0], atom_names[1], atom_names[2])] = sidechain_angle | angle_key = '%s_%s_%s' % (atom_names[0], atom_names[1], atom_names[2]) angle_key = angle_key.replace('-','_') residue_dict[angle_key] = sidechain_angle | def calc_sidechain_angles(residue, residue_prev, residue_dict): """ Calculates Values for sidechain bond angles. Uses a predefined list from sidechain.py, specifically bond_angles. """ try: mapping = bond_angles[residue.resname] for i in range(len(mapping)): atom_names = mapping[i] try: sidechain_atoms = [] for n in at... |
code = segment.__dict__[field] | code = residue.__dict__[field] | def run(self): self.parent |
parts.append(str(segment.__dict__[field])) | parts.append(str(residue.__dict__[field])) | def run(self): self.parent |
print 'PDBS TO PROCESS:', pdbs | def work(self, **kwargs): """ Work function - expects a list of pdb file prefixes. """ | |
print 'DATA', data | def process_pdb(self, data): """ Process an individual pdb file """ try: residue_props = None code = data['code'] chains_filter = data['chains'] if data.has_key('chains') else None print 'DATA', data filename = 'pdb%s.ent.gz' % code.lower() print ' Processing: ', code | |
logging.basicConfig(filename='ProcessPDB.log',level=logging.DEBUG) task.logger = logging | def process_args(args): return {'code':args[0], 'chains':[c for c in args[1]], 'threshold':float(args[2]), 'resolution':float(args[3]), 'rfactor':float(args[4]), 'rfree':float(args[5]) } | |
'SQRT(IF (((%(f)s+360)%%%%360 - avgs.avg_%(f)s) < 180,SUM(POW((%(f)s+360)%%%%360-avgs.avg_%(f)s, 2)),SUM(POW(360-((%(f)s+360)%%%%360-avgs.avg_%(f)s),2)))/(COUNT(%(f)s)-1))AS stddev_%(f)s' % {'f':field} | 'SQRT(IF (((%(f)s+360)MOD 360 - avgs.avg_%(f)s) < 180,SUM(POW((%(f)s+360) MOD 360-avgs.avg_%(f)s, 2)),SUM(POW(360-((%(f)s+360) MOD 360-avgs.avg_%(f)s),2)))/(COUNT(%(f)s)-1))AS stddev_%(f)s' % {'f':field} | def as_sql(self): outer_parts = [] inner_parts = [] for field in self.angles: inner_parts.append( 'ROUND(IF(DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) < 0,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) + 180,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))... |
params = { 'base': self.queryset.query.__str__(), | base_sql, base_params = self.queryset.query.as_sql() sql_params = { 'base': base_sql, | def as_sql(self): outer_parts = [] inner_parts = [] for field in self.angles: inner_parts.append( 'ROUND(IF(DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) < 0,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) + 180,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))... |
return 'SELECT residues.aa, %(outer)s FROM (%(base)s) AS residues, \ | sql = 'SELECT residues.aa, %(outer)s FROM (%(base)s) AS residues, \ | def as_sql(self): outer_parts = [] inner_parts = [] for field in self.angles: inner_parts.append( 'ROUND(IF(DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) < 0,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) + 180,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))... |
WITH ROLLUP' % params | WITH ROLLUP' % sql_params params = base_params + base_params return sql, params | def as_sql(self): outer_parts = [] inner_parts = [] for field in self.angles: inner_parts.append( 'ROUND(IF(DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) < 0,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))) + 180,DEGREES(ATAN2(-AVG(SIN(RADIANS(%(f)s))),-AVG(COS(RADIANS(%(f)s))))... |
cursor.execute(self.as_sql()) | cursor.execute(*self.as_sql()) | def _execute(self): """ Private method for executing query, always runs query and then updates cache """ from django.db import connection, transaction cursor = connection.cursor() cursor.execute(self.as_sql()) results = [] |
if xText in ANGLES: xModder = int(360/xbin) if xMax < xMin: xLimit = xLimit%360 if yText in ANGLES: yModder = int(360/ybin) if yMax < yMin: yLimit = yLimit%360 | def __init__(self, xSize, ySize, xMin, xMax, yMin, yMax, xbin, ybin, xText, yText, ref, sigmaVal, residue_attribute, residue_xproperty, residue_yproperty, querySet, color='green', background_color='#ffffff', graph_color='#222222', text_color='#000000', hash_color='#666666' ): """ Constructor Size: size of plot Padd... | |
}) if (x <= x1) else ( Q(**{'%s__gte'%self.xTextString: x}) | Q(**{'%s__lt'%self.xTextString: x1}) | }) if (xlinear) else ( Q(**{'%s__gte'%self.xTextString: self.x}) | Q(**{'%s__lt'%self.xTextString: x}) | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
}) if (y <= y1) else ( Q(**{'%s__gte'%self.yTextString: y}) | Q(**{'%s__lt'%self.yTextString: y1}) | }) if (ylinear) else ( Q(**{'%s__gte'%self.yTextString: self.y}) | Q(**{'%s__lt'%self.yTextString: y}) | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
for field in self.fields: | for field in self.stats_fields: | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
x_aggregate = 'FLOOR((%s-%s)/%s)' % (x_field, x, xbin) y_aggregate = 'FLOOR((%s-%s)/%s)' % (y_field, y, ybin) | if xlinear: x_aggregate = 'FLOOR((%s-%s)/%s)' % (x_field, x, xbin) else: x_aggregate = 'FLOOR((IF(%(f)s<0,360+%(f)s,%(f)s)-%(rx)s)/%(b)s)' \ % {'f':x_field, 'b':xbin, 'rx':self.x} if ylinear: y_aggregate = 'FLOOR((%s-%s)/%s)' % (y_field, y, ybin) else: y_aggregate = 'FLOOR((IF(%(f)s<0,360+%(f)s,%(f)s)-%(ry)s)/%(b)s)' \... | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
avgs = "CASE CONCAT(FLOOR((%s-%s)/%s),':',FLOOR((%s-%s)/%s)) %s END" % (x_field, x, xbin, y_field, y, ybin, cases) | avgs = "CASE CONCAT(%s,':',%s) %s END" % (x_aggregate, y_aggregate, cases) | def query_bins(self): """ Runs the query to calculate the bins and their relevent data """ # local vars x = self.x x1 = self.x1 y = self.y y1 = self.y1 xbin = self.xbin ybin = self.ybin |
xBinCount = math.ceil((float(x1)-x)/xbin) yBinCount = math.ceil((float(y1)-y)/ybin) | if x>0 and x1<0: xBinCount = math.ceil((360.0+x1-x)/xbin) else: xBinCount = math.ceil((float(x1)-x)/xbin) if y>0 and y1<0: yBinCount = math.ceil((360.0+y1-y)/ybin) else: yBinCount = math.ceil((float(y1)-y)/ybin) | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
calc_chi(res, res.prev, res_dict) | calc_chi(res, prev, res_dict) | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... |
calc_sidechain_angles(res, res.prev, sidechain) | calc_sidechain_angles(res, prev, sidechain) | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... |
if (n=='C-1'): chi_atoms.append(residue_prev['C'].get_vector()) | if residue_prev and n[-2:]=='-1': chi_atoms.append(residue_prev[n[:-2]].get_vector()) | def calc_chi(residue, residue_prev, residue_dict): """ Calculates Values for CHI using the predefined list of CHI angles in the CHI_MAP. CHI_MAP contains the list of all peptides and the atoms that make up their different chi values. This function will process the values known to exist, it will also skip chi values i... |
if(n=='C-1'): sidechain_atoms.append(residue_prev['C'].get_vector()) | if residue_prev and n[-2:]=='-1': sidechain_atoms.append(residue_prev[n[:-2]].get_vector()) | def calc_sidechain_angles(residue, residue_prev, residue_dict): """ Calculates Values for sidechain bond angles. Uses a predefined list from sidechain.py, specifically bond_angles. """ try: mapping = bond_angles[residue.resname] for i in range(len(mapping)): atom_names = mapping[i] try: sidechain_atoms = [] for n in at... |
self.logger.error('EXCEPTION in Residue: %s %s %s' % (code, e.__class__, e)) transaction.rollback() | print 'EXCEPTION in Residue: %s %s %s' % (code, e.__class__, e) | def process_pdb(self, data): """ Process an individual pdb file """ try: residue_props = None code = data['code'] chains_filter = data['chains'] if data.has_key('chains') else None print 'DATA', data filename = 'pdb%s.ent.gz' % code.lower() print ' Processing: ', code |
initialize_geometry(res_dict, sidechain_angle_list, 'angle') initialize_geometry(res_dict, sidechain_length_list, 'length') | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... | |
calc_sidechain_lengths(res, res_dict) calc_sidechain_angles(res, res_dict) | def parseWithBioPython(file, props, chains_filter=None): """ Parse values from file that can be parsed using BioPython library @return a dict containing the properties that were processed """ chains = props['chains'] decompressedFile = None tmp = './tmp' pdb = './pdb' try: #create tmp workspace if os.path.exists(tmp)... | |
residue_dict['%s_%s'% (sidechain_atoms[0],sidechain_atoms[1])] = sidechain_length | residue_dict['%s_%s'% (sidechain_atom_names[0],sidechain_atom_names[1])] = sidechain_length | def calc_sidechain_lengths(residue, residue_dict): """ NEEDS TESTING AND A GOOD LOOKING OVER""" """ Calculates Values for sidechain bond lengths. Uses a predefined list from sidechain.py, specifically bond_lengths. """ try: mapping = bond_lengths[residue.resname] for i in range(len(mapping)): sidechain_atom_names= mapp... |
mapping = bond_lengths[residue.resname] | mapping = bond_angles[residue.resname] | def calc_sidechain_angles(residue, residue_dict): """ NEEDS TESTING AND A GOOD LOOKING OVER""" """ Calculates Values for sidechain bond angles. Uses a predefined list from sidechain.py, specifically bond_angles. """ try: mapping = bond_lengths[residue.resname] for i in range(len(mapping)): sidechain_atom_names= mapping... |
residue_dict['%s_%s_%s'% (sidechain_atoms[0],sidechain_atoms[1],sidechain_atoms[2])] = sidechain_angle | residue_dict['%s_%s_%s'% (sidechain_atom_names[0],sidechain_atom_names[1],sidechain_atom_names[2])] = sidechain_angle | def calc_sidechain_angles(residue, residue_dict): """ NEEDS TESTING AND A GOOD LOOKING OVER""" """ Calculates Values for sidechain bond angles. Uses a predefined list from sidechain.py, specifically bond_angles. """ try: mapping = bond_lengths[residue.resname] for i in range(len(mapping)): sidechain_atom_names= mapping... |
query.connection.ops.check_aggregate_support(aggregate) | def add_to_query(self, query, alias, col, source, is_summary): """Add the aggregate to the nominated query. | |
for key in filter(lambda x: not data[x] or data[x] == '', data): | for key in filter(lambda x: data[x]==None or data[x] == '', data): | def search(request): """ Handler for search form. """ if request.method == 'POST': # If the form has been submitted form = SearchForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass #process search form into search object, remove any properties #that do not have values. dat... |
svg.rect(graph_x, graph_y, graph_height, graph_width, 0, self.graph_color, self.graph_color); | svg.rect(graph_x, graph_y, graph_height_used, graph_width_used, 0, self.graph_color, self.graph_color); | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
svg.rect(graph_x+0.5, graph_y+0.5, graph_height, graph_width, 1, hash_color); | svg.rect(graph_x+0.5, graph_y+0.5, graph_height_used, graph_width_used, 1, hash_color); | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
svg.line( graph_x+xZero, graph_y, graph_x+xZero, graph_y+graph_height, 1, hash_color); if y < 0 and x1 > 0: | svg.line( graph_x+xZero, graph_y, graph_x+xZero, graph_y+graph_height_used, 1, hash_color); print xZero elif x > x1 : xZero = (graph_width_used/(360-abs(x1)-x)) * (180-x) svg.line( graph_x+xZero, graph_y, graph_x+xZero, graph_y+graph_height_used, 1, hash_color); if y < 0 and y1 > 0: | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
svg.line( graph_x, yZero, graph_x+graph_width, yZero, 1, hash_color); | svg.line( graph_x, yZero, graph_x+graph_width_used, yZero, 1, hash_color); elif y > y1: yZero = (graph_height_used/(360-abs(y1)-y)) * (180-y) svg.line( graph_x, yZero, graph_x+graph_width_used, yZero, 1, hash_color); | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
xtext = ((x + xstep*i + 180)%360 - 180) if xText in ANGLES else (x + xstep*i) | xtext = ((x + xstep*i + 180)%360 - 180) if xText in ANGLES and x1 <= 180 else (x + xstep*i) | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
ytext = ((y + ystep*i + 180)%360 - 180) if yText in ANGLES else (y + ystep*i) | ytext = ((y + ystep*i + 180)%360 - 180) if yText in ANGLES and y1 <= 180 else (y + ystep*i) | def Plot(self): """ Calculates and renders the plot """ #cache local variables x = self.x y = self.y x1 = self.x1 y1 = self.y1 xbin = self.xbin ybin = self.ybin xText = self.xText yText = self.yText height = self.height width = self.width bg_color = self.background_color hash_color = self.hash_color text_color = self.... |
out.write('%(code)s %(chains)s %(rfactor)s %(rfree)s %(threshold)s %(resolution)s\n' % p) | out.write('%(code)s %(chains)s %(threshold)s %(resolution)s %(rfactor)s %(rfree)s\n' % p) | def null_print(txt): pass |
self.write_defaults(filename) | self.write_default(filename) | def __init__(self): """Read the config file. """ filename = expanduser('~/.viewdoc') if not isfile(filename): self.write_defaults(filename) |
def write_defaults(self, filename): | def write_default(self, filename): | def write_defaults(self, filename): """Write the default config file. """ try: f = open(filename, 'wt') try: f.write(CONFIG) finally: f.close() except (IOError, OSError), e: print >>sys.stderr, '%s: %s' % (e.strerror or e, filename) |
result = sudo("%(tomcat_stop)s" % env, term=not headless) | result = sudo("%(tomcat_stop)s" % env, shell=not headless) | def _managed_tomcat_restart(wait=5, headless=False): _needs_targetenv() result = sudo("%(tomcat_stop)s" % env, term=not headless) if result.failed: raise OSError(result) yield print "... restarting in", for i in range(wait, 0, -1): print "%d..." % i, time.sleep(1) print sudo("%(tomcat_start)s" % env, term=not headless)... |
sudo("%(tomcat_start)s" % env, term=not headless) | sudo("%(tomcat_start)s" % env, shell=not headless) | def _managed_tomcat_restart(wait=5, headless=False): _needs_targetenv() result = sudo("%(tomcat_stop)s" % env, term=not headless) if result.failed: raise OSError(result) yield print "... restarting in", for i in range(wait, 0, -1): print "%d..." % i, time.sleep(1) print sudo("%(tomcat_start)s" % env, term=not headless)... |
return re.sub(r'.*Repository Root: \w+://([^/]+?)/.*', r'\1', local("svn info").replace('\n', ' ')) | for l in local("svn info --xml").splitlines(): for svnhost in re.findall(r'\s*<root>\w+://([^/]+?)/.*</root>', l): return svnhost | def _get_svn_host(): return re.sub(r'.*Repository Root: \w+://([^/]+?)/.*', r'\1', local("svn info").replace('\n', ' ')) |
local("cd %(toolsdir)s &&" | local("cd %(toolsdir)s/rinfomain &&" | def package_admin(): local("cd %(toolsdir)s &&" "groovy base_as_feed.groovy -b ../../resources/base/" " -o %(adminbuild)s"%env) |
_deploy_war("%(local_sesame_dir)s/%(warname)s.war"%env, warname) | _deploy_war("%(local_sesame_dir)s/%(warname)s.war"%venv(), warname) | def deploy_sesame(): setup_service() package_sesame() for warname in ['openrdf-sesame', 'sesame-workbench']: _deploy_war("%(local_sesame_dir)s/%(warname)s.war"%env, warname) |
_mkdir_keep_prev("%(demodata_dir)s/%(dataset)s"%venv()) | def demo_data_to_depot(dataset): """Transforms the downloaded demo data to a depot.""" _can_handle_dataset(dataset) _mkdir_keep_prev("%(demodata_dir)s/%(dataset)s"%venv()) if dataset in lagen_nu_datasets: _transform_lagen_nu_data(dataset) elif dataset in riksdagen_se_datasets: _transform_riksdagen_data(dataset) | |
rsync_project(env.demo_data_root, "%(demodata_dir)s/%(dataset)s"%venv(), exclude=".*", delete=True) | rsync_project(env.demo_data_root, "%(demodata_dir)s/%(dataset)s-depot" % venv(), exclude=".*", delete=True) | def demo_data_upload(dataset): """Uploads the transformed demo data depot to the demo server.""" _can_handle_dataset(dataset) _needs_targetenv() rsync_project(env.demo_data_root, "%(demodata_dir)s/%(dataset)s"%venv(), exclude=".*", delete=True) |
if exists("%s-prev"%dir_path): | if p.isdir("%s-prev"%dir_path): | def _mkdir_keep_prev(dir_path): if exists("%s-prev"%dir_path): local("rm -rf %s-prev"%dir_path) if exists("%s"%dir_path): local("mv %s %s-prev"%(dir_path, dir_path)) local("mkdir -p %s"%dir_path) |
if exists("%s"%dir_path): | if p.isdir("%s"%dir_path): | def _mkdir_keep_prev(dir_path): if exists("%s-prev"%dir_path): local("rm -rf %s-prev"%dir_path) if exists("%s"%dir_path): local("mv %s %s-prev"%(dir_path, dir_path)) local("mkdir -p %s"%dir_path) |
" %(demodata_dir)s/%(dataset)s-download %(dataset)s -f" % venv()) | " %(demodata_dir)s/%(dataset)s-raw %(dataset)s -f" % venv()) | def _download_riksdagen_data(dataset): local("%(java_opts)s groovy %(demodata_tools)s/data_riksdagen_se/fetch_data_riksdagen_se.groovy " " %(demodata_dir)s/%(dataset)s-download %(dataset)s -f" % venv()) |
collector_url = "http://%s/collector/" % env.roledefs['main'][0] | collector_url = "http://%s/collector" % env.roledefs['main'][0] | def ping_main_collector(feed_url): #require('roledefs', provided_by=targetenvs) collector_url = "http://%s/collector/" % env.roledefs['main'][0] #feed_url = "http://%s:8182/feed/current" % env.roledefs['examples'][0] ping_main_collector(collector_url, feed_url) |
ping_main_collector(collector_url, feed_url) | ping_collector(collector_url, feed_url) | def ping_main_collector(feed_url): #require('roledefs', provided_by=targetenvs) collector_url = "http://%s/collector/" % env.roledefs['main'][0] #feed_url = "http://%s:8182/feed/current" % env.roledefs['examples'][0] ping_main_collector(collector_url, feed_url) |
sudo("mkdir -p %(admin_webroot)s"%env) sudo("chown %(user)s %(admin_webroot)s"%env) | def demo_admin(): # TODO: When should the /var/www/admin directory be created and chowned? adminbuild = p.join(env.demodata_dir, "rinfo-admin-demo") sources = p.join(env.projectroot, "resources", env.target, "datasources.n3") package_admin(sources, adminbuild) deploy_admin(adminbuild) | |
raise DataError("Sorting %s failed: %s" % (filename, e)) | raise DataError("Sorting %s failed: %s" % (filename, e), filename) | def disk_sort(self, filename): Status("Sorting %s..." % filename) try: subprocess.check_call(['sort', '-z', '-t', '\xff', '-k', '1,1', '-T', '.', '-S', self.sort_buffer_size, '-o', filename, filename]) except subprocess.CalledProcessError, e: raise DataError("Sorting %s failed: %s" % (filename, e)) Status("Finished sor... |
parser.values.jobdict = parser.jobdict parser.values.jobdict[name.strip('-')] = True if val is None else val | self.jobdict[name.strip('-')] = True if val is None else val | def update_jobdict(self, option, name, val, parser): parser.values.jobdict = parser.jobdict parser.values.jobdict[name.strip('-')] = True if val is None else val |
job.run(input=input, **program.options.jobdict) | job.run(input=input, **program.option_parser.jobdict) | def maybe_list(seq): return seq[0] if len(seq) == 1 else seq |
mod = __import__('disco.schemes.scheme_%s' % scheme, fromlist=['scheme_%s' % scheme]) | scheme_ = 'scheme_%s' % (scheme or 'file') mod = __import__('disco.schemes.%s' % scheme_, fromlist=[scheme_]) | def map_input_stream(stream, size, url, params): """ An :func:`input_stream` which looks at the scheme of ``url`` and tries to import a function named ``input_stream`` from the module ``disco.schemes.scheme_SCHEME``, where SCHEME is the parsed scheme. If no scheme is found in the url, ``file`` is used. The resulting in... |
def unpack(string, globals={}): | def unpack(string, globals={'__builtins__': __builtins__}): | def unpack(string, globals={}): try: return cPickle.loads(string) except Exception, err: try: code, defs = marshal.loads(string) defs = tuple([unpack(x) for x in defs]) if defs else None return FunctionType(code, globals, argdefs = defs) except: raise err |
ddfs.push(tag, blobs, retries=600, delayed=True) | ddfs.push(tag, blobs, retries=600, delayed=True, update=True) | def ddfs_save(blobs, name, master): from disco.ddfs import DDFS ddfs = DDFS(master) blobs = [(blob, ('discoblob:%s:%s' % (name, os.path.basename(blob)))) for blob in blobs] tag = ddfs_name(name) ddfs.push(tag, blobs, retries=600, delayed=True) return "tag://%s" % tag |
(len(k), k, len(v), str(v))) | (len(k), str(k), len(v), str(v))) | def encode_netstring_str(d): msg = StringIO.StringIO() for k, v in d: msg.write("%d %s %d %s\n" %\ (len(k), k, len(v), str(v))) return msg.getvalue() |
'nr_reduces': 1, | def __str__(self): return '{%s}' % ', '.join(self.jobnames) | |
self['partitions'] = self['nr_reduces'] if 'partitions' in kwargs: if 'map' in self: self['nr_reduces'] = self['partitions'] | if 'nr_reduces' in kwargs: self['partitions'] = self['nr_reduces'] if 'map' in self: if self['partitions']: if self['merge_partitions']: self['nr_reduces'] = 1 else: self['nr_reduces'] = self['partitions'] | def __init__(self, *args, **kwargs): super(JobDict, self).__init__(*args, **kwargs) |
raise DiscoError("Can't specify partitions without map") | self['nr_reduces'] = 0 elif 'partitions' in kwargs: raise DiscoError("Can't specify partitions without map") elif not ispartitioned and self['merge_partitions']: raise DiscoError("Can't merge non-partitioned inputs") elif ispartitioned and not self['merge_partitions']: self['nr_reduces'] = len(util.parse_dir(self['inp... | def __init__(self, *args, **kwargs): super(JobDict, self).__init__(*args, **kwargs) |
if 'map' not in self: if ispartitioned and not self['merge_partitions']: self['nr_reduces'] = len(util.parse_dir(self['input'][0])) if 'merge_partitions' in self: if 'map' in self or ispartitioned: self['nr_reduces'] = 1 else: raise DiscoError("Can't merge partitions without partitions") | self['nr_reduces'] = 1 | def __init__(self, *args, **kwargs): super(JobDict, self).__init__(*args, **kwargs) |
callable() | ret = callable() | def assertCommErrorCode(self, code, callable): from disco.error import CommError try: callable() except CommError, e: self.assertEquals(code, e.code) |
self.assertEquals(code, e.code) | return self.assertEquals(code, e.code) except Exception, e: raise AssertionError('CommError not raised, got %s' % e) raise AssertionError('CommError not raised (expected %d), ' 'returned %s' % (code, ret)) | def assertCommErrorCode(self, code, callable): from disco.error import CommError try: callable() except CommError, e: self.assertEquals(code, e.code) |
if isinstance(tag, list): if tag: return canonizetag(tag[0]) | if isiterable(tag): for tag in tag: return canonizetag(tag) | def canonizetag(tag): if isinstance(tag, list): if tag: return canonizetag(tag[0]) elif tag.startswith('tag://'): return tag elif '://' not in tag: return 'tag://%s' % tag raise InvalidTag("Invalid tag: %s" % tag) |
Default is ``256 * 1024**2``. | Default is ``0`` (due to issue | def __str__(self): return '{%s}' % ', '.join(self.jobnames) |
'mem_sort_limit': 256 * 1024**2, | 'mem_sort_limit': 0, | def __str__(self): return '{%s}' % ', '.join(self.jobnames) |
input_stream=[func.map_input_stream], | input_stream=(func.map_input_stream, ), | def result_iterator(results, notifier=None, reader=func.chain_reader, input_stream=[func.map_input_stream], params=None, ddfs=None, tempdir=None): """ Iterates the key-value pairs in job results. *results* is a list of results, as returned by :meth:`Disco.wait`. :param notifier: a function called when the iterator mov... |
task.input_stream = input_stream | task.input_stream = list(input_stream) | def notifier(url): ... |
if not len(r) or tot >= content_len: | if not len(r) or (content_len!=None and tot >= content_len): | def re_reader(item_re_str, fd, content_len, fname, output_tail = False, read_buffer_size=8192): item_re = re.compile(item_re_str) buf = "" tot = 0 while True: if content_len: r = fd.read(min(read_buffer_size, content_len - tot)) else: r = fd.read(read_buffer_size) tot += len(r) buf += r m = item_re.match(buf) while m:... |
return [(e + params['suffix'], 0)] | yield e + params['suffix'], 0 | def map_1(e, params): return [(e + params['suffix'], 0)] |
for fun in task.input_stream: fun.func_globals.setdefault('Task', task) | task.insert_globals(task.input_stream) | def notifier(url): ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.