Is this what you need?
#!/usr/bin/perl use strict;
# List of required columns separated by ', ', must match names in 'Fields:'
my $req_fields = shift || 'Subject id, % identity, alignment length, mismatches, q. start, q. end';
# Split into array
my @req_fields = split /, /, $req_fields;
# Print header
print join("\t",@req_fields),"\n";
my (@fields,%data); # Read lines following __DATA__ while (defined($_ = <DATA>)) { # trim newline chomp; # get list of columns in data if 'Fields:' was found @fields = split /, /,$1 if /Fields: (.+)/; # skip lines beginning with '#' next if /^#/; # split data line into hash slice @[EMAIL PROTECTED] = split /\t/; # print hash slice of required fields print join("\t",@[EMAIL PROTECTED]),"\n"; } close DATA;
__DATA__
# BLASTN 2.2.9 [May-01-2004]
# Query: gi|37182815|gb|AY358849.1| Homo sapiens clone DNA180287 ALTE (UNQ6508) mRNA, complete cds
# Database: nr
# Fields: Query id, Subject id, % identity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
gi|37182815|gb|AY358849.1| gi|28592069|gb|U63637.2|BTU63637 100.00 17 0 0 552 568 3218 3234 1.1 34.19
gi|37182815|gb|AY358849.1| gi|14318385|gb|AC089993.2| 95.24 21 1 0 435 455 56604 56624 1.1 34.19
gi|37182815|gb|AY358849.1| gi|14318385|gb|AC089993.2| 100.00 16 0 0 260 275 89982 89967 4.2 32.21
gi|37182815|gb|AY358849.1| gi|7385112|gb|AF222766.1|AF222766 100.00 17 0 0 345 361 242 226 1.1 34.19
gi|37182815|gb|AY358849.1| gi|2290397|gb|U90937.1|BTU90937 100.00 17 0 0 866 882 1450 1466 1.1 34.19
gi|37182815|gb|AY358849.1| gi|1663641|gb|U73621.1|BTU73621 100.00 17 0 0 256 272 1070 1086 1.1 34.19
__END__
You may read 'perldoc perldata' on the section about slices.
HTH aditi gupta wrote:
hi to all,
well, a listing of sequence similarity is as follows:
# BLASTN 2.2.9 [May-01-2004] # Query: gi|37182815|gb|AY358849.1| Homo sapiens clone DNA180287 ALTE (UNQ6508) mRNA, complete cds # Database: nr # Fields: Query id, Subject id, % identity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score gi|37182815|gb|AY358849.1| gi|28592069|gb|U63637.2|BTU63637 100.00 17 0 0 552 568 3218 3234 1.1 34.19 gi|37182815|gb|AY358849.1| gi|14318385|gb|AC089993.2| 95.24 21 1 0 435 455 56604 56624 1.1 34.19 gi|37182815|gb|AY358849.1| gi|14318385|gb|AC089993.2| 100.00 16 0 0 260 275 89982 89967 4.2 32.21 gi|37182815|gb|AY358849.1| gi|7385112|gb|AF222766.1|AF222766 100.00 17 0 0 345 361 242 226 1.1 34.19 gi|37182815|gb|AY358849.1| gi|2290397|gb|U90937.1|BTU90937 100.00 17 0 0 866 882 1450 1466 1.1 34.19 gi|37182815|gb|AY358849.1| gi|1663641|gb|U73621.1|BTU73621 100.00 17 0 0 256 272 1070 1086 1.1 34.19
where the fields are: Fields: Query id, Subject id, % identity, alignment length, mismatches, gap openings, q. start, q. end, s. start, s. end, e-value, bit score
only subject id, %identity, alignment length, mismatches, q.start and q. end fields are required in out put...... if i use (.+), then all fields from subject id will come.....what should i do?
regards
aditi
Yahoo! India Matrimony: Find your partner online.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>