Hey everyone,
Following is what I have. I ran the command and it is just processing... It hasn't given me any errors or results yet. Can you please let me know what's the issue.
#!/usr/bin/perl
use warnings;
use strict;
print 'Enter protein sequence filename: ';
chomp( my $prot_filename = <STDIN> );
open my $PROTFILE, '<', $prot_filename
or die "Cannot open '$prot_filename' because: $!";
my $out_filename = 'duplicate_gene_entries_in_'.$prot_filename;
open my $OUTFILE, '>', $out_filename
or die "Cannot open '$out_filename' because: $!";
$/ = ''; # Set paragraph mode
my %seen;
my $header;
my $count_in;
my $count_out;
my $gn;
while (<>) {
if (/^>.* GN=([^ ]+)/) {
$gn = $1;
$header = exists $seen{$gn} ? undef : $_;
} elsif ($header) {
undef $seen{$gn};
print $header, $_;
}
}
close $OUTFILE;
close $PROTFILE;
printf "%d total records read from '%s'\n",$count_in,$prot_filename;
printf "%d records written to '%s' after removing duplicate entries\n"
+,$count_out,$out_filename;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.