从输入文件中提取匹配模式并在Perl中打印到输出文件

问题描述 投票:0回答:1

我以这种形式从ncbi blastn获得了巨大的输入文件:

<ul id="msgFrm" class=" msg">
Job Title: otu0                  
Database: rRNA_typestrains/prokaryotic_16S_ribosomal_RNA 16S ribosomal RNA (Bacteria and Archaea)
Query #1: otu0 Query ID: lcl|Query_16950 Length: 460

Sequences producing significant alignments:
                                                                  Max    Total Query   E   Per.                  
Description                                                       Score  Score cover Value Ident  Accession        
Bacteroides dorei strain 175 16S ribosomal RNA, partial sequence  839    839   100%  0.0   99.57  NR_041351.1      

Alignments:
>Bacteroides dorei strain 175 16S ribosomal RNA, partial sequence
Sequence ID: NR_041351.1 Length: 1493 
Range 1: 341 to 800

Score:839 bits(454), Expect:0.0, 
Identities:458/460(99%),  Gaps:0/460(0%), Strand: Plus/Plus

Query  1    CCTACGGGGGGCAGCAGTGAGGAATATTGGTCAATGGGCGATGGCCTGAACCAGCCAAGT  60
            |||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||
Sbjct  341  CCTACGGGAGGCAGCAGTGAGGAATATTGGTCAATGGGCGATGGCCTGAACCAGCCAAGT  400


Query #2: otu1 Query ID: lcl|Query_16951 Length: 460

Sequences producing significant alignments:
                                                                  Max    Total Query   E   Per.                  
Description                                                       Score  Score cover Value Ident  Accession          
Bacteroides vulgatus ATCC 8482 16S ribosomal RNA, partial...      811    811   100%  0.0   98.48  NR_074515.1      
Bacteroides paurosaccharolyticus strain WK042 16S ribosomal RN... 673    673   100%  0.0   93.06  NR_112668.1      


Alignments:
>Bacteroides dorei strain 175 16S ribosomal RNA, partial sequence
Sequence ID: NR_041351.1 Length: 1493 
Range 1: 341 to 800

Score:833 bits(451), Expect:0.0, 
Identities:457/460(99%),  Gaps:0/460(0%), Strand: Plus/Plus

Query  1    CCTACGGGGGGCAGCAGTGAGGAATATTGGTCAATGGGCGATGGCCTGAACCAGCCAAGT  60
            |||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||
Sbjct  341  CCTACGGGAGGCAGCAGTGAGGAATATTGGTCAATGGGCGATGGCCTGAACCAGCCAAGT  400


Query #3: otu2 Query ID: lcl|Query_16952 Length: 460

Sequences producing significant alignments:
                                                                  Max    Total Query   E   Per.                  
Description                                                       Score  Score cover Value Ident  Accession             
Bacteroides sartorii JCM 16497 16S ribosomal RNA, partial...      684    684   100%  0.0   93.48  NR_113064.1      
Bacteroides paurosaccharolyticus strain WK042 16S ribosomal RN... 678    678   100%  0.0   93.28  NR_112668.1      


Alignments:
>Bacteroides dorei strain 175 16S ribosomal RNA, partial sequence
Sequence ID: NR_041351.1 Length: 1493 
Range 1: 341 to 800

Score:839 bits(454), Expect:0.0, 
Identities:458/460(99%),  Gaps:0/460(0%), Strand: Plus/Plus

Query  1    CCTACGGGTGGCAGCAGTGAGGAATATTGGTCAATGGGCGATGGCCTGAACCAGCCAAGT  60
            |||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||
Sbjct  341  CCTACGGGAGGCAGCAGTGAGGAATATTGGTCAATGGGCGATGGCCTGAACCAGCCAAGT  400

...等等。

现在,对于文件中的每个“查询号”,我需要提取“查询号”和“路线”之间包含的段落信息,并在另一个输出文件中打印。

我尝试使用以下基本代码,但是在Perl编程中遇到了一些困难。有人可以帮助我解决问题吗?非常感谢

#!/usr/bin/perl -w

use warnings;

open(GENBANK, "Bact_ncbi_output.txt") or die;

my $outfile = 'output.txt';
open OUT,'>',$outfile 
  or die "Could not open $outfile : $!";

$content = join("", <GENBANK>);   
close GENBANK;

$content =~ /Query\s+([A-Z0-9_.]+)Alignments$/;         

print OUT "$content\n";
perl design-patterns output extract ncbi
1个回答
0
投票

请尝试这个:

© www.soinside.com 2019 - 2024. All rights reserved.