Ejemplo n.º 1
0
 def handle_mouse_click(self, event):
     """
     Ottaa vastaan pygamen mouse click -eventin.
     Luo seedin
     """
     if self.rect.collidepoint(event.pos):
         if event.button == 1:
             seed.Seed(self.x, self.y, main=self.main)
         elif event.button == 3:
             pass
Ejemplo n.º 2
0
 def BringSeeds(self):
   for r in (0.03, 0.06), (0.07, 0.08), (0.08, 0.09):
     for i in range(20):
       s = seed.Seed(0, 0)
       s.final_rot = math.pi * 2 * i / 20 + random.uniform(-0.06, 0.06) - math.pi
       s.final_length = random.uniform(*r)
       s.length = 0
       self.seeds.append(s)
   self.seeds = random.sample(self.seeds, min(self.seed_count, len(self.seeds)))
   self.seeding_time = self.age
   for x in self.petals + self.leaves:
     x.Detach(self.game, self)
   self.petals = []
   self.leaves = []
Ejemplo n.º 3
0
def main():
    _, confs = parse_args()

    #load spider.conf
    crawl_timeout = float(confs['spider']['crawl_timeout'])
    crawl_interval = float(confs['spider']['crawl_interval'])
    max_depth = int(confs['spider']['max_depth'])
    target_url = confs['spider']['target_url']
    store_page_dir = confs['spider']['store_page_dir']
    bf_file = confs["BloomFilter"]['bf_file']
    thread_num = int(confs['spider']['thread_count'])

    #bloom filter
    bf = pybloomfilter.BloomFilter(100000, 0.0001, bf_file)

    #initialize task queue from input seeds
    tasks = gevent.queue.Queue()
    for line in utils.read_file(confs['spider']['url_list_file']):
        line = line.strip()
        #logger.info('queue in url:%s' %line)
        log.info('queue in url:%s' % line)
        tasks.put_nowait(seed.Seed(0, line))

    #work thread function
    def worker(n):
        while not tasks.empty():
            depth, url = tasks.get()
            if depth > max_depth:
                log.info("worker%s url:%s exceed max depth %s." %
                         (n, url, max_depth))
                continue
            if url in bf:
                log.info('worker%s url:%s already accessed' % (n, url))
            else:
                bf.add(url)
                log.info('worker%s fetching url:%s' % (n, url))
                url_list = utils.save_and_fetch(url, re.compile(target_url),
                                                store_page_dir, crawl_timeout)
                for u in url_list:
                    tasks.put_nowait(seed.Seed(depth + 1, u))
                    log.info('queue in url:%s' % u)
                gevent.sleep(crawl_interval)
        log.info('worker%s quit.' % n)

    #start work thread
    threads = [gevent.spawn(worker, i) for i in range(thread_num)]

    #wait all work threads quit elegantly. :)
    gevent.joinall(threads)
Ejemplo n.º 4
0
    def createJunction(self):
        if not self.isJunction():
            return

        # We're going to lay claim to some points during this process. Update
        # their ownership when we're done so we don't let ones we've already
        # claimed convince us that it's okay to take more.
        claimedPoints = set()

        center = self.start.toGridspace()
        radius = int(self.getJunctionRadius() / constants.blockSize)

        # Iterate over points in the accepted area, claiming them if they belong
        # to edges that we're related to.
        for x in xrange(max(center.ix - radius, 1),
                        min(center.ix + radius, game.map.numCols - 1)):
            for y in xrange(max(center.iy - radius, 1),
                            min(center.iy + radius, game.map.numRows - 1)):
                point = Vector2D(x, y)
                if point in game.map.deadSeeds:
                    if self.start.isEdgeRelated(
                            game.map.deadSeeds[point].owner):
                        claimedPoints.add(point)

        # Convert each claimed point into open space. Then check its neighbors,
        # and fill them with walls if they aren't related to us.
        for point in claimedPoints:
            game.map.assignSpace(point, self)
            if game.map.blocks[point.ix][point.iy] != generator.BLOCK_EMPTY:
                game.map.blocks[point.ix][point.iy] = generator.BLOCK_EMPTY
                # Patch walls around the deleted space
                for nearPoint in point.perimeter():
                    if not game.map.getIsInBounds(nearPoint):
                        continue
                    # If we hit a space that's not a wall or open space, or
                    # if we hit a space that's owned by a node of the graph
                    # that we aren't connected to, put a wall in.
                    altEdge = None
                    if nearPoint in game.map.deadSeeds:
                        altEdge = game.map.deadSeeds[nearPoint].owner
                    if (game.map.blocks[nearPoint.ix][nearPoint.iy]
                            == generator.BLOCK_UNALLOCATED
                            or (altEdge is not None
                                and not self.start.isEdgeRelated(altEdge))):
                        game.map.blocks[nearPoint.ix][
                            nearPoint.iy] = generator.BLOCK_WALL
                        game.map.deadSeeds[nearPoint] = seed.Seed(
                            self, 0, constants.BIGNUM)
Ejemplo n.º 5
0
    def sprout_seeds(self):
        """ Viskoo siemeniä niin paljon kuin energiaa riittää """
        self.seeds_sprouted = 1

        while True:
            # for i in range(int(self.genome['seeds_number'])):
            new_x = random.randint(int(self.x - self.genome['seeds_distance']),
                                   int(self.x + self.genome['seeds_distance']))
            new_y = random.randint(int(self.y - self.genome['seeds_distance']),
                                   int(self.y + self.genome['seeds_distance']))

            if self.energy >= self.genome['energy_cost_per_seed']:
                # Energiaa on, spawnataan siemen
                seed.Seed(new_x, new_y, parent=self, main=self.main)
                self.energy -= self.genome['energy_cost_per_seed']
            else:
                # Energia loppu, ei spawnata enää
                break
Ejemplo n.º 6
0
 def worker(n):
     while not tasks.empty():
         depth, url = tasks.get()
         if depth > max_depth:
             log.info("worker%s url:%s exceed max depth %s." %
                      (n, url, max_depth))
             continue
         if url in bf:
             log.info('worker%s url:%s already accessed' % (n, url))
         else:
             bf.add(url)
             log.info('worker%s fetching url:%s' % (n, url))
             url_list = utils.save_and_fetch(url, re.compile(target_url),
                                             store_page_dir, crawl_timeout)
             for u in url_list:
                 tasks.put_nowait(seed.Seed(depth + 1, u))
                 log.info('queue in url:%s' % u)
             gevent.sleep(crawl_interval)
     log.info('worker%s quit.' % n)
Ejemplo n.º 7
0
additive_68_2 = [a.Additive("F-68", "F-68", 0.005, surfact_concs2)]
additive_P84_P108 = [
    a.Additive("P-84", "P-84", 0.005, surfact_concs3),
    a.Additive("F-108", "F-108", 0.005, surfact_concs3[1:])
]
additive_Tetronic_F127 = [
    a.Additive("Tetronic", "Tetronic", 0.005, surfact_concs3),
    a.Additive("F-127", "F-127", 0.005, surfact_concs3[1:])
]
additive_blank = [a.Additive("Blank", "Blank", 1, [0])]
additive_F127 = [a.Additive("F-127", "F-127", 0.005, surfact_concs4)]

buffermixes_S.append(b.BufferMix("wilham", "RTQuIC buffer mix", wilham))

seeds_M = [
    se.Seed("Water", "Water as control", 9, 2),
    se.Seed("MM1 (10^-3)", "MM1 sCJD seed diluted 1 in 1000", 3, 2)
]
seeds_M2 = [
    se.Seed("Water", "Water as control", 3, 2),
    se.Seed("MM1 (10^-3)", "MM1 sCJD seed diluted 1 in 1000", 3, 2)
]
seeds_M3 = [
    se.Seed("Water", "Water as control", 2, 2),
    se.Seed("MM1(1e-3)", "MM1 sCJD seed diluted 1 in 1000", 2, 2)
]
seeds_65 = [
    se.Seed("SD31 FC", "(1e-3) Ex#21.051 diluted 1 in 1000", 2, 2),
    se.Seed("SD31 CB", "(1e-3) Ex#21.054 diluted 1 in 1000", 2, 2),
    se.Seed("MM", "Ex#15.317(10^-3) MM diluted 1 in 1000", 2, 2),
    se.Seed("MV", "Ex#15.320(10^-3), MV diluted 1 in 1000", 2, 2),
Ejemplo n.º 8
0
from models.alert import db
import seed

__author__ = 'frodriguez'

logging.basicConfig(level=logging.INFO)

connexionApp = connexion.App(__name__, specification_dir='./swagger/')
args = {'title': 'Flood alert API'}
connexionApp.add_api('swagger.yaml', arguments=args)

app = connexionApp.app

app.json_encoder = FlaskJSONEncoder
app.config.from_object('config')

# Initialize and create the database.
db.init_app(app)
db.create_all(app=app)

migrate = Migrate(app, db)

manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.add_command('runserver', Server(port='8888'))
manager.add_command('seed', seed.Seed())

if __name__ == '__main__':
    manager.run()
Ejemplo n.º 9
0
mw = {"HamFLPrP": 22803.23,
      "abeta_42":4514.10,
      "abeta_40:":4329.86}

additives_S, buffermixes_S = [],[]

for surf in surfactants[:1]:
    buff = a.Additive(surf, surf, 0.05, surfact_concs)
    additives_S.append(buff)
additive_68 = [a.Additive("F-68", "F-68", 0.05, surfact_concs)]
additive_68_2 = [a.Additive("F-68", "F-68", 0.005, surfact_concs2)]
additive_P84_P108 = [a.Additive("P-84", "P-84", 0.005, surfact_concs3), a.Additive("F-108", "F-108", 0.005, surfact_concs3[1:])]

buffermixes_S.append(b.BufferMix("wilham","RTQuIC buffer mix", wilham)) 

seeds_M = [se.Seed("Water","Water as control", 9,2), se.Seed("MM1 (10^-3)", "MM1 sCJD seed diluted 1 in 1000", 3,2)]
seeds_M2 = [se.Seed("Water","Water as control", 3,2), se.Seed("MM1 (10^-3)", "MM1 sCJD seed diluted 1 in 1000", 3,2)]
substrates_M = [su.Substrate("HS23NM 140111", "Hu recPrP substrate M at codon 129", (0.1/0.52))]


##ex5 = RTQuICplate(substrates_M, buffermixes_S, additives_S, seeds_M, "9-12-20")
##ex6 = RTQuICplate(substrates_M, buffermixes_S, additive_68, seeds_M, "10-12-20")
##ex7 = RTQuICplate(substrates_M, buffermixes_S, additive_68_2, seeds_M, "18-02-21")
##ex8 = RTQuICplate(substrates_M, buffermixes_S, additive_68, seeds_M, "?-12-20")
ex9 = r.RTQuICplate(substrates_M, buffermixes_S, additive_P84_P108, seeds_M2, "?-5-21")
print(ex9)
ex9.get_mastermixes()
##print(ex10)
##ex10.get_mastermixes()

##set up datfram for adding data