Пример #1
0
 def print_term(self):
   """
   >>> from mimi import mimi_fetch_interactions
   >>> from intdb import InteractionDB
   >>> test = mimi_fetch_interactions('1436');
   >>> db = InteractionDB();
   >>> db.add_gene_interactions(test);
   >>> db.print_term();
   """
   
   fields = [
     'Gene 1',
     'Gene 2',
     'Components',
     'Processes',
     'Functions',
     'Types',
     'Provenance',
     'PMIDs'
   ];
   
   table = PrettyTable(fields);
   for f in fields:
     table.set_field_align(f,'l');
    
   fracs = [0.05,0.05,0.15,0.15,0.15,0.15,0.15,0.15];
   term_width = int(terminal_size()[0]*1.35)
     
   widths = [];
   for i in fracs:
     widths.append(int(term_width * i));
   
   table.set_field_widths(widths);
   
   gene_root = self.root[InteractionDB._GENE_ROOT];
   for uid1 in gene_root:
     uid1_root = gene_root.get(uid1);
     for uid2 in uid1_root:
       inter = uid1_root.get(uid2);
       row = [
         uid1,
         uid2,
         ["%s [GO:%s]" % (i,j) for i,j in inter.components],
         ["%s [GO:%s]" % (i,j) for i,j in inter.processes],
         ["%s [GO:%s]" % (i,j) for i,j in inter.functions],
         list(inter.types),
         ",".join(inter.provenance),
         ",".join(inter.pmids)
       ];
       table.add_wrapped_row(row);
   
   table.printt(fields=['Gene 1','Gene 2','Types','Provenance','PMIDs']);
   table.printt(fields=['Gene 1','Gene 2','Processes','Components','Functions']);
Пример #2
0
	def download(self, logger=None):
		if logger is None:
			logger = logging.getLogger("pakfire")

		downloads = self.get_downloads()

		# If there are no downloads, we can just stop here.
		if not downloads:
			return

		# Get free space of the download location.
		path = os.path.realpath(REPO_CACHE_DIR)
		while not os.path.ismount(path):
			path = os.path.dirname(path)
		path_stat = os.statvfs(path)

		if self.download_size >= path_stat.f_bavail * path_stat.f_bsize:
			raise DownloadError, _("Not enough space to download %s of packages.") \
				% util.format_size(self.download_size)

		logger.info(_("Downloading packages:"))
		time_start = time.time()

		counter = 0
		counter_downloads = len(downloads)
		for step in downloads:
			counter += 1

			# Download the package file.
			step.binary_pkg = step.pkg.download(
				text="(%d/%d): " % (counter, counter_downloads),
				logger=logger)

		# Write an empty line to the console when there have been any downloads.
		width, height = util.terminal_size()

		# Print a nice line.
		logger.info("-" * width)

		# Format and calculate download information.
		time_stop = time.time()
		download_time = time_stop - time_start
		download_speed = self.download_size / download_time
		download_speed = util.format_speed(download_speed)
		download_size = util.format_size(self.download_size)
		download_time = util.format_time(download_time)

		line = "%s | %5sB     %s     " % \
			(download_speed, self.download_size, download_time)
		line = " " * (width - len(line)) + line
		logger.info(line)
		logger.info("")
Пример #3
0
    def download(self, logger=None):
        if logger is None:
            logger = logging.getLogger("pakfire")

        downloads = self.get_downloads()

        # If there are no downloads, we can just stop here.
        if not downloads:
            return

        # Get free space of the download location.
        path = os.path.realpath(REPO_CACHE_DIR)
        while not os.path.ismount(path):
            path = os.path.dirname(path)
        path_stat = os.statvfs(path)

        if self.download_size >= path_stat.f_bavail * path_stat.f_bsize:
            raise DownloadError, _("Not enough space to download %s of packages.") \
             % util.format_size(self.download_size)

        logger.info(_("Downloading packages:"))
        time_start = time.time()

        counter = 0
        counter_downloads = len(downloads)
        for step in downloads:
            counter += 1

            # Download the package file.
            step.binary_pkg = step.pkg.download(text="(%d/%d): " %
                                                (counter, counter_downloads),
                                                logger=logger)

        # Write an empty line to the console when there have been any downloads.
        width, height = util.terminal_size()

        # Print a nice line.
        logger.info("-" * width)

        # Format and calculate download information.
        time_stop = time.time()
        download_time = time_stop - time_start
        download_speed = self.download_size / download_time
        download_speed = util.format_speed(download_speed)
        download_size = util.format_size(self.download_size)
        download_time = util.format_time(download_time)

        line = "%s | %5sB     %s     " % \
         (download_speed, self.download_size, download_time)
        line = " " * (width - len(line)) + line
        logger.info(line)
        logger.info("")
Пример #4
0
    def print_term(self):
        """
    >>> from mimi import mimi_fetch_interactions
    >>> from intdb import InteractionDB
    >>> test = mimi_fetch_interactions('1436');
    >>> db = InteractionDB();
    >>> db.add_gene_interactions(test);
    >>> db.print_term();
    """

        fields = [
            'Gene 1', 'Gene 2', 'Components', 'Processes', 'Functions',
            'Types', 'Provenance', 'PMIDs'
        ]

        table = PrettyTable(fields)
        for f in fields:
            table.set_field_align(f, 'l')

        fracs = [0.05, 0.05, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15]
        term_width = int(terminal_size()[0] * 1.35)

        widths = []
        for i in fracs:
            widths.append(int(term_width * i))

        table.set_field_widths(widths)

        gene_root = self.root[InteractionDB._GENE_ROOT]
        for uid1 in gene_root:
            uid1_root = gene_root.get(uid1)
            for uid2 in uid1_root:
                inter = uid1_root.get(uid2)
                row = [
                    uid1, uid2,
                    ["%s [GO:%s]" % (i, j) for i, j in inter.components],
                    ["%s [GO:%s]" % (i, j) for i, j in inter.processes],
                    ["%s [GO:%s]" % (i, j) for i, j in inter.functions],
                    list(inter.types), ",".join(inter.provenance),
                    ",".join(inter.pmids)
                ]
                table.add_wrapped_row(row)

        table.printt(
            fields=['Gene 1', 'Gene 2', 'Types', 'Provenance', 'PMIDs'])
        table.printt(fields=[
            'Gene 1', 'Gene 2', 'Processes', 'Components', 'Functions'
        ])