Elsa镇魂女孩 2019-07-01 23:04 采纳率: 62.5%
浏览 4246
已结题

如何用python,将print的结果导入到excel表格中

将printprint(ppi.scorePPITreesP(proteinsA, proteinsB))的结果导入到excel表格中

import numpy as np
from matplotlib import pyplot as plt
import PPI as ppi
from sklearn import manifold



# Fanconia Anemia proteins files, D2.fasta, L.fasta,
# shall exist in the sub-folder ./PPIData. These files contain the corresponding protein sequences from Fanconia Anemia
proteinNames = ['FANCE1020_1080', 'FANCD21_60', 'FANCD260_120']
n = len(proteinNames)
n = len(proteinNames)

distM = np.zeros([n, n])
distV = []

for i in range(0, n):
    nameA = proteinNames[i]
    proteinsA = ppi.getAllSequences(nameA)  # The Fanconi Anemia file: one file contain the same protein for different geneomes
    print(nameA, len(proteinsA))

    for j in range(0, n):
        nameB = proteinNames[j]
        proteinsB = ppi.getAllSequences(nameB)
        print(nameB, len(proteinsB))
        dist = 1 - ppi.scorePPITreesP(proteinsA, proteinsB)
        distV.append(dist)
        distM[i, j] = dist
        print(nameA, nameB, dist)
        print(ppi.scorePPITreesP(proteinsA, proteinsB))
print(distM)
print()


  • 写回答

2条回答 默认 最新

  • 张如鑫 2019-07-02 09:22
    关注

    使用xlwt模块

    1
    2
    3
    4
    import xlwt
    workbook = xlwt.Workbook()
    sheet = workbook.add_sheet("Sheet Name")
    sheet.write(0, 0, 'foobar') # row, column, value
    最后一行就是写入,把你要print的内容write进去就行了

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题