ARGV::OrDATA

E. Choroba

Prague.pm

GoodData

PerlMonks, CPAN, StackOverflow

choroba@matfyz.cz

Examples

My usual routine

#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;

My usual routine

#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

My usual routine

#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;

while (my $protein = <DATA>) {
    chomp $protein;
}

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

My usual routine

#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;
use LWP::Simple;

while (my $protein = <DATA>) {
    chomp $protein;
    my $fasta = get("http://www.uniprot.org/uniprot/$protein.fasta");
    $fasta =~ s/.*$//m;
    $fasta =~ s/[ \n]//g;
    my @matches;
    while ($fasta =~ /(N[^P][ST][^P])/g) {
        push @matches, pos($fasta) - 3;
        pos($fasta) = pos($fasta) - 3;
    }
    say "$protein\n@matches" if @matches;
}

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

My usual routine

$ mprt.pl mprt.in

Oops!

My usual routine

#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;
use LWP::Simple;

while (my $protein = <DATA>) {
    chomp $protein;
    my $fasta = get("http://www.uniprot.org/uniprot/$protein.fasta");
    $fasta =~ s/.*$//m;
    $fasta =~ s/[ \n]//g;
    my @matches;
    while ($fasta =~ /(N[^P][ST][^P])/g) {
        push @matches, pos($fasta) - 3;
        pos($fasta) = pos($fasta) - 3;
    }
    say "$protein\n@matches" if @matches;
}

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

My usual routine

#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;
use LWP::Simple;

while (my $protein = <>) {
    chomp $protein;
    my $fasta = get("http://www.uniprot.org/uniprot/$protein.fasta");
    $fasta =~ s/.*$//m;
    $fasta =~ s/[ \n]//g;
    my @matches;
    while ($fasta =~ /(N[^P][ST][^P])/g) {
        push @matches, pos($fasta) - 3;
        pos($fasta) = pos($fasta) - 3;
    }
    say "$protein\n@matches" if @matches;
}

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

My usual routine

#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;
use LWP::Simple;

*ARGV = *DATA unless @ARGV || ! -t;

while (my $protein = <>) {
    chomp $protein;
    my $fasta = get("http://www.uniprot.org/uniprot/$protein.fasta");
    $fasta =~ s/.*$//m;
    $fasta =~ s/[ \n]//g;
    my @matches;
    while ($fasta =~ /(N[^P][ST][^P])/g) {
        push @matches, pos($fasta) - 3;
        pos($fasta) = pos($fasta) - 3;
    }
    say "$protein\n@matches" if @matches;
}

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

My usual routine

#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use Data::Dumper;
use LWP::Simple;

use ARGV::OrDATA;

while (my $protein = <>) {
    chomp $protein;
    my $fasta = get("http://www.uniprot.org/uniprot/$protein.fasta");
    $fasta =~ s/.*$//m;
    $fasta =~ s/[ \n]//g;
    my @matches;
    while ($fasta =~ /(N[^P][ST][^P])/g) {
        push @matches, pos($fasta) - 3;
        pos($fasta) = pos($fasta) - 3;
    }
    say "$protein\n@matches" if @matches;
}

__DATA__
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST

ARGV::OrDATA

Thank you.

Questions?

http://e-choroba.eu/19-light/