Exemplo n.º 1
0
def get_motifs(model, data_x, data_y, protein_name):
    model.trainable = False
    pos_x = get_pos(data_x, data_y)
    data_x = pos_x.reshape(pos_x.shape[0], pos_x.shape[1], pos_x.shape[2], 1)
    features = get_feature(model=model, data=data_x)
    features = features.reshape(features.shape[0], features.shape[1], features.shape[3])
    if os.path.exists('./' + protein_name + '.fa'):
        os.remove('./' + protein_name + '.fa')
    fp = open('./' + protein_name + '.fa', 'w')

    count = 0
    for i in range(features.shape[0]):
        seq = get_seq(data_x[i])
        for j in range(features.shape[1]):
            count_1 = 0
            for k in range(features.shape[2]):
                if features[i][j][k] > 0:
                    count_1 += 1
            if count_1 < 33 + int(len(data_y) / 4000):
                continue
            else:
                for k in range(features.shape[2]):
                    if features[i][j][k] > 0.4:
                        fp.write('>' + 'seq_' + str(i) + '_' + 'filter' + str(j) + '_' + str(k) + '\n')
                        fp.write(seq[j:j + 7] + '\n')
                        count += 1
    fp.close()
    print('count:', count)
    print('{}start get {} logo{}'.format('*' * 10, protein_name, '*' * 10))
    get_logo(protein_name)
    print('{}draw {} logo done{}'.format('*' * 10, protein_name, '*' * 10))
Exemplo n.º 2
0
def channels(sl):
    channels = utils.call(sl, lambda: sl.channels(False))
    today = datetime.datetime.now()
    epg = utils.call(
        sl, lambda: sl.epg(channels, today, today + datetime.timedelta(days=1),
                           False))
    xbmcplugin.setPluginCategory(_handle, _addon.getLocalizedString(30600))
    if channels:
        for channel in channels:
            stationid = str(channel['stationid'])  #because it is long
            plot = generate_plot([x for x in epg
                                  if stationid in x][0][stationid],
                                 channel['title'], 4) if epg else u''
            list_item = xbmcgui.ListItem(label=channel['title'])
            list_item.setInfo('video', {
                'title': channel['title'],
                'plot': plot
            })
            list_item.setArt(
                {'thumb': utils.get_logo(channel['title'], sl._api_url)})
            list_item.setProperty('IsPlayable', 'true')
            link = get_url(live='play',
                           lid=channel['id'],
                           stationid=stationid,
                           askpin=channel['pin'])
            is_folder = False
            xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)
    xbmcplugin.endOfDirectory(_handle)
Exemplo n.º 3
0
def channels(sl):
    channels = utils.call(sl, lambda: sl.channels())
    xbmcplugin.setPluginCategory(_handle, _addon.getLocalizedString(30600))
    if channels:
        for channel in channels:
            if channel['replayable']:
                list_item = xbmcgui.ListItem(label=channel['title'])
                list_item.setInfo('video', {'title': channel['title']})  # TODO - genre?
                list_item.setArt({'thumb': utils.get_logo(channel['title'], sl._api_url)})
                link = get_url(replay='days', stationid=channel['stationid'], channel=channel['title'],
                               askpin=channel['pin'])
                is_folder = True
                xbmcplugin.addDirectoryItem(_handle, link, list_item, is_folder)
    xbmcplugin.endOfDirectory(_handle)
Exemplo n.º 4
0
def main():
    '''Main Function'''
    # Print our logo
    print(utils.get_logo())
    print("Welcome to TensorBrute, NOOB.\n")
    # Show options
    print(utils.show_ops(), end='')
    # input
    opt = input()
    if opt.strip() == '1':
        newSession()
    elif opt.strip() == '2':
        existingSession()
    elif opt.strip() == '3':
        cleanUp()
    elif opt.strip() == '4':
        getDBinfo()
    else:
        print("Exiting...")
Exemplo n.º 5
0
    def Playlistparser(self):
        try:
           s = requests.Session()
           s.mount('file://', FileAdapter())
           for index in range(3):
               try:
                   logging.info("[%s]: get: %s" % (self.__class__.__name__, config.url))
                   with s.get(config.url, headers=self.headers, proxies=config.proxies, stream=False, timeout=(5,30)) as playlist:
                      if playlist.status_code != 304:
                         if playlist.encoding is None: playlist.encoding = 'utf-8'
                         playlist = playlist.json()
                         self.headers['If-Modified-Since'] = gevent.time.strftime('%a, %d %b %Y %H:%M:%S %Z', gevent.time.gmtime(self.playlisttime))
                         self.playlist = PlaylistGenerator(m3uchanneltemplate=config.m3uchanneltemplate)
                         self.picons = picons.logomap
                         self.channels = {}
                         m = requests.auth.hashlib.md5()
                         logging.info('[%s]: playlist %s downloaded' % (self.__class__.__name__, config.url))
                         try:
                            for item in playlist:
                                channel = {}
                                name = item['name']
                                channel['name'] = name
                                channel['url'] = 'infohash://{}'.format(item['infohash'])
                                if 'categories' in item:
                                    channel['group'] = item['categories'][0]
                                else:
                                    channel['group'] = u'tv'
                                    print('No category: ', item)
                                channel['logo'] = self.picons[name] = channel.get('logo', get_logo(picons.logomap, name))
                                channel['availability'] = item['availability']
                                print("Added: ", channel)
                                self.playlist.addItem(channel)
                                m.update(ensure_binary(name))

                            #urlpattern = requests.utils.re.compile(r'^(acestream|infohash)://[0-9a-f]{40}$|^(http|https)://.*.(acelive|acestream|acemedia|torrent)$')
                            #for channel in playlist['channels']:
                            #   name = channel['name']
                            #   url = 'acestream://{url}'.format(**channel)
                            #   channel['group'] = channel.pop('cat')
                            #   channel['logo'] = self.picons[name] = channel.get('logo', get_logo(picons.logomap, name))
                            #
                            #   if requests.utils.re.search(urlpattern, url):
                            #      self.channels[name] = url
                            #      channel['url'] = quote(ensure_str(name),'')
                            #
                            #   self.playlist.addItem(channel)
                            #   m.update(ensure_binary(name))

                         except Exception as e:
                            print("Exception1: ", e)
                            logging.error("[%s]: can't parse JSON! %s" % (self.__class__.__name__, repr(e)))
                            return False

                         self.etag = '"' + m.hexdigest() + '"'
                         logging.debug('[%s]: plugin playlist generated' % self.__class__.__name__)

                      self.playlisttime = gevent.time.time()
                      logging.info("Return True")
                      print("Return True")
                      return True
               except ValueError as e:
                   print("Exception2: ", e)
                   logging.error("[%s]: can't parse %s playlist, attempt: %d" % (self.__class__.__name__, config.url, index + 1))
                   if index + 1 < 3:
                       logging.error("Sleeping")
                       time.sleep((index + 1) * 2)
                       logging.error("Sleeping end")
                   else:
                       logging.error("Return False")
                       return False

        except requests.exceptions.RequestException:
           logging.error("[%s]: can't download %s playlist!" % (self.__class__.__name__, config.url))
           return False
        except:
            logging.error("[%s]: can't parse %s playlist!" % (self.__class__.__name__, config.url))
            logging.error(traceback.format_exc())
            return False
Exemplo n.º 6
0
    def Playlistparser(self):
        try:
            s = requests.Session()
            s.mount('file://', FileAdapter())
            with s.get(config.url,
                       headers=self.headers,
                       proxies=config.proxies,
                       stream=False,
                       timeout=30) as r:
                if r.status_code != 304:
                    if r.encoding is None: r.encoding = 'utf-8'
                    self.headers['If-Modified-Since'] = gevent.time.strftime(
                        '%a, %d %b %Y %H:%M:%S %Z',
                        gevent.time.gmtime(self.playlisttime))
                    self.playlist = PlaylistGenerator(
                        m3uchanneltemplate=config.m3uchanneltemplate)
                    self.picons = picons.logomap
                    self.channels = {}
                    m = requests.auth.hashlib.md5()
                    logging.info('[%s]: playlist %s downloaded' %
                                 (self.__class__.__name__, config.url))
                    pattern = requests.utils.re.compile(
                        r',(?P<name>.+)[\r\n].+[\r\n].+[\r\n](?P<url>[^\r\n]+)?'
                    )
                    urlpattern = requests.utils.re.compile(
                        r'^(http|https)://.*id=([0-9a-f]{40}).*$')
                    group_pattern = requests.utils.re.compile(r'(.*)\((.*)\)$')
                    for match in pattern.finditer(r.text,
                                                  requests.auth.re.MULTILINE):
                        itemdict = match.groupdict()
                        name = itemdict.get('name', '')
                        url = itemdict['url']

                        group_search_pattern = requests.utils.re.search(
                            group_pattern, name)
                        if group_search_pattern:
                            name = group_search_pattern.group(1).strip()
                            itemdict['name'] = name
                            itemdict['group'] = group_search_pattern.group(2)

                        itemdict['logo'] = self.picons[name] = itemdict.get(
                            'logo', get_logo(picons.logomap, name))

                        url_search_pattern = requests.utils.re.search(
                            urlpattern, url)
                        if url_search_pattern:
                            #url = 'acestream://{}'.format(url_search_pattern.group(2))
                            self.channels[name] = url
                            itemdict['url'] = quote(ensure_str(name), '')

                        self.playlist.addItem(itemdict)
                        m.update(ensure_binary(name))

                    self.etag = '"' + m.hexdigest() + '"'
                    logging.debug('[%s]: plugin playlist generated' %
                                  self.__class__.__name__)

                self.playlisttime = gevent.time.time()

        except requests.exceptions.RequestException:
            logging.error("[%s]: can't download %s playlist!" %
                          (self.__class__.__name__, config.url))
            return False
        except:
            logging.error(traceback.format_exc())
            return False

        return True