我对Python完全是新手,想看看它在Python中是如何工作的
我在下面有一个名为data.txt
的数据,我想从这个数据中检索四列。首先,我要检索类别,然后是p值,然后是Query:
前后的文本。所以结果应该是这样的:
Degardome Category: 4 Degradome p-value: 0.00120246641531374 3' AUUAAUAACCGGCCUGUUUGC 5' Seq_1950_218
Degardome Category: 4 Degradome p-value: 0.00360306320817827 3' ACUUUCUUUUCUUAA--UCUUUC 5' Seq_2171_593
data.txt文件:
Degardome Category: 4
Degradome p-value: 0.00120246641531374
T-Plot file: T-plots-IGR/Seq_5744_249_Supercontig_2.10_1257006_264_TPlot.pdf
Position Reads Category
264 1 4 <<<<<<<<<<
914 1 4
987 4 0
---------------------------------------------------
---------------------------------------------------
5' UUGGAGGUGGCUGGACGGAUG 3' Transcript: Supercontig_2.10_1395094:908-928 Slice Site:919
||||o||||oo|o|
3' AUUAAUAACCGGCCUGUUUGC 5' Query: Seq_1950_218
HV2.fasta_dd.txt
Degardome Category: 4
Degradome p-value: 0.00360306320817827
T-Plot file: T-plots-IGR/Seq_1950_218_Supercontig_2.10_1395094_919_TPlot.pdf
Position Reads Category
919 1 4 <<<<<<<<<<
---------------------------------------------------
---------------------------------------------------
5' AGAAGGGGAAGAGUGGAGGAGAG 3' Transcript: Supercontig_2.10_1543625:626-648 Slice Site:637
|||o|oo||||o| o||o||
3' ACUUUCUUUUCUUAA--UCUUUC 5' Query: Seq_2171_593
如果你用
将提供以下输出:
现在初始化一个空字符串并连接所有相关部分:
最后,根据新行拆分字符串:
使用模块
re
的解决方案:现在,您可以将这个
output
写入一个文件相关问题 更多 >
编程相关推荐