示例#1
0
def station_metadata(stations):
    network_file = get_resource('asos_networks')
    station_mapping = pd.read_csv(network_file)
    network_query = (station_mapping.iem_network.str.contains('ASOS')) | (
        station_mapping.iem_network == 'AWOS')
    query = (station_mapping.stid.isin(stations)) & network_query
    return station_mapping[query]
示例#2
0
    def build_info_panel(self, data):
        html_win = ClickableHtmlWindow(self.lst, size=(-1, 180))
        html_win.attach_to_frame(self, 0)
                #style=wx.html.HW_SCROLLBAR_NEVER)

        html_text = u"<table><tr>"
        img_file = os.path.join(config.images_folder, data['filename'] + '.jpg')
        if os.path.exists(img_file):
            html_text += u'<td width="100" rowspan="2">\
                    <img src="{0}"></td>\n'.format(img_file)
        else:
            html_text += u'<td width="100" rowspan="2"></td>'

        # imdb icon
        html_text += u'<td><a href="http://imdb.com/title/{0}">\
                <img src="{1}"></a></td></tr>'.format(data['imdbID'],
                        config.get_resource('images', 'imdb-logo.png'))
        print html_text

        # details
        html_text += u"<tr><td>" + self.generate_label_text(data) + u"</td></tr>"
        html_text += u"</table>"

        html_win.SetPage(html_text)

        return html_win
示例#3
0
	def __init__(self, input, output, *args, **kwargs):
		self.init('macse')
		self.version_jar()
		self.check_input('-i', input)
		self.args += ('-o', output)
		self.args += args
		mem = 0.9 * utils.mem_to_mb(config.get_resource('memory'))
		self.run_jar('%dM' % mem)
示例#4
0
	def __init__(self, input, *args, **kwargs):
		self.init('insert_stats', **kwargs)
		self.version('-v')
		self.check_input('-i', input)
		self.args += ('-m', kwargs.get('max_insert',
		                               config.get_resource('max_insert_size')))
		self.args += args
		self.run()
示例#5
0
    def create_policy(self):
        rule_declarations = config.get_resource('authz')
        policy = authz.Policy(error_factory=errors.AuthzError, aspect='server')
        for decl in rule_declarations:
            policy.declare(decl)

        policy.context.update({'s': self})
        return policy
示例#6
0
	def add_openmp(self):
		"""
		Indicates that this wrapper should use OpenMP by setting the
		$OMP_NUM_THREADS environment variable equal to the number of threads
		specified in the BioLite configuration file.
		"""
		threads = min(int(config.get_resource('threads')), self.max_concurrency)
		self.env['OMP_NUM_THREADS'] = str(threads)
    def generate(self, path):
        path = self.path + path
        bower_versions = config.bower_versions()

        decls = config.get_resource('js_manifest')
        decls = config.deep_interpolate(decls, bower_versions)
        for decl in decls:
            if 'min-href' in decl and decl['min-href'] == path:
                return 'text/javascript', self.minify_js(decl)

        decls = config.get_resource('css_manifest')
        decls = config.deep_interpolate(decls, bower_versions)
        for decl in decls:
            if 'min-href' in decl and decl['min-href'] == path:
                return 'text/css', self.minify_css(decl)

        raise tornado.web.HTTPError(400,
                                    "No matching minification declaration.")
示例#8
0
	def __init__(self, input, iworm, *args, **kwargs):
		self.init('chrysalis', **kwargs)
		self.add_threading('-cpu')
		self.add_openmp()
		self.check_input('-i', input)
		self.check_input('-iworm', iworm)
		mem = utils.mem_to_mb(config.get_resource('memory'))
		self.args += ('-sort_buffer_size', '%dM' % int(0.8 * mem))
		self.args += args
		self.run()
示例#9
0
	def add_threading(self, flag):
		"""
		Indicates that this wrapper should use threading by appending an
		argument with the specified `flag` followed by the number of threads
		specified in the BioLite configuration file.
		"""
		threads = min(int(config.get_resource('threads')), self.max_concurrency)
		if threads > 1:
			self.args.append(flag)
			self.args.append(threads)
示例#10
0
	def __init__(self, commands, *args, **kwargs):
		self.init('parallel', **kwargs)
		self.version('--version')
		self.args += (
			'--gnu', '-a', commands, '-j',
			kwargs.get('threads', config.get_resource('threads')))
		hostlist = config.get_resource_default('hostlist', None)
		if hostlist:
			self.args += ('-S', hostlist)
			if self.cwd:
				self.args += ('--wd', self.cwd)
			else:
				self.args += ('--wd', os.getcwd())
		self.args += args
		self.run()
示例#11
0
	def __init__(self, inputs, *args, **kwargs):
		self.init("spades.py", **kwargs)
		self.name = "spades"
		self.version()
		self.add_threading("-t")
		mem = 0.9 * utils.mem_to_mb(config.get_resource('memory')) / 1024
		self.args += ("-m", max(1, int(mem)))
		# Detect inputs
		if isinstance(inputs, basestring):
			self.check_input('-s', inputs)
		elif len(inputs) == 1:
			self.check_input('-s', inputs[0])
		elif len(inputs) == 2:
			self.check_input('-1', inputs[0])
			self.check_input('-2', inputs[1])
		else:
			utils.die("expected either 1 (SE) or 2 (PE) inputs")
		self.args += args
		self.run()
示例#12
0
	def __init__(self, input, kmer, *args, **kwargs):
		self.init('jellyfish', **kwargs)
		self.version('--version')
		#
		# From the Jellyfish manual (section 2.3), hash size in bytes is:
		#
		#   2^l * (2k-l+r+1)/8
		#
		# s = 2^l is the hash size parameter given by -s. By default, r=5 and
		# letting l be 0:
		#
		#   s ~= 8 * mem / (2k + 6)
		#
		mem = 1048576 * utils.mem_to_mb(config.get_resource('memory'))
		mem = 2 ** int(math.log(8 * mem / (2*kmer + 6) , 2))
		self.args += ('count', '-m', kmer, '-s', mem)
		self.add_threading('-t')
		self.check_input(None, input)
		self.args += args
		self.run()
示例#13
0
	def __init__(self, inputs, *args, **kwargs):
		self.init('trinity', **kwargs)
		self.version('--version')

		# Detect inputs
		if isinstance(inputs, basestring):
			self.check_input('--single', inputs)
		elif len(inputs) == 1:
			self.check_input('--single', inputs[0])
		elif len(inputs) == 2:
			self.check_input('--left', inputs[0])
			self.check_input('--right', inputs[1])
		else:
			utils.die("expected either 1 (SE) or 2 (PE) inputs")

		# Detect file type
		ext = os.path.splitext(self.args[-1])[1]
		if ext == '.fa':
			self.args += ('--seqType', 'fa')
		elif ext == '.fq':
			self.args += ('--seqType', 'fq')
		else:
			utils.info("warning: could not determine sequence type of inputs")

		# Java uses roughly 2 CPUs per Butterfly call with GC etc. so reduce
		# the number of threads by half.
		#threads = kwargs.get('threads', int(config.get_resource('threads')))
		#self.max_concurrency = max(1, threads/2)

		mem = utils.mem_to_mb(config.get_resource('memory'))
		self.args += ("--JM", "%dG" % max(1, int(0.8*mem/1024)))
		max_insert = kwargs.get(
							'max_insert',
							diagnostics.lookup_insert_size().max)
		if max_insert:
			self.args += ('--group_pairs_distance', int(max_insert))
		self.add_threading('--CPU')
		self.args += args
		self.run()
示例#14
0
	def __init__(self, **kwargs):
		self.init('oma', **kwargs)
		parameters = """
			ReuseCachedResults := true;
			NP := %d;
			MinScore := 181;
			LengthTol := 0.61;
			StablePairTol := 1.81;
			VerifiedPairTol := 1.53;
			MinSeqLen := 50;
			StableIdsForGroups := false;
			DoHierarchicalGroups := true;
			MaxTimePerLevel := 1200;
			SpeciesTree := 'estimate';
			ReachabilityCutoff := 0.65;
			UseEsprit := false;
			DistConfLevel := 2;
			MinProbContig := 0.4;
			MaxContigOverlap := 5;
			MinSeqLenContig := 20;
			MinBestScore := 250;
		""" % int(config.get_resource('threads'))
		open(os.path.join(self.cwd, 'parameters.drw'), 'w').write(parameters)
		self.run()
示例#15
0
def find_class(name):
    cls = get_resource(name)
    if not cls:
        raise ConfigurationException('Could not find APIResource class %r' % name)
    return cls
示例#16
0
 def set_icon(self):
     ib = wx.IconBundle()
     ib.AddIconFromFile(config.get_resource('images', 'MDB_all.ico'),
         wx.BITMAP_TYPE_ICO)
     self.SetIcons(ib)
示例#17
0
 def authz_declarations(self):
     decls = config.get_resource('authz')
     return json_encode(decls)
示例#18
0
 def stylesheets(self):
     bower_versions = config.bower_versions()
     decls = config.get_resource('css_manifest')
     decls = config.deep_interpolate(decls, bower_versions)
     return self.prepare_resources(decls)