| 1 | package MS::Search::DB::Source::uniprot; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use HTTP::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use URI::Escape; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use FileHandle; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 0 | my ($class, %args) = @_; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 0 | my $self = bless {%args} => $class; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | return $self; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | ▶ | sub _fetch_fh { | ||||||||||||||||||
|
Subroutine
_fetch_fh: not called CC=13 SCAR=52.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | my ($self) = @_; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | my ($rdr, $wtr) = FileHandle::pipe; | |||||||||||||||||||
| 26 | 0 | my $pid = fork; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | if ($pid) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | close $wtr; | |||||||||||||||||||
| 31 | 0 | return($rdr, $pid); | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | close $rdr; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | my @proteomes; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | if (defined $self->{proteome}) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 41 | 0 | @proteomes = ($self->{proteome}); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | ▶ | elsif (defined $self->{taxid} && ! defined $self->{proteome}) { | |||||||||||||||||||
|
Condition0%0/3
defined $self->{"taxid"} and not defined $self->{"proteome"}
MC/DC0%0/2
defined $self->{"taxid"} and not defined $self->{"proteome"}
defined $self->{"taxid"}
not defined $self->{"proteome"}
Truth table0%0/3
A and not(B)
A= defined $self->{"taxid"}B= not defined $self->{"proteome"}
| |||||||||||||||||||||
| 44 | 0 | ▶ | my $ref_only = $self->{ref_only} ? 'true' : 'false'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | ▶ | my $top_node = $self->{taxid} // die "No taxon specified\n"; | ||||||||||||||||||
|
Condition0%0/2
$self->{"taxid"} // die("No taxon specified\n")
MC/DC0%0/1
$self->{"taxid"} // die("No taxon specified\n")
$self->{"taxid"}
Truth table0%0/2
A
A= $self->{"taxid"}
| |||||||||||||||||||||
| 46 | 0 | ▶ | die "Taxon must be NCBI integer ID\n" if ($top_node =~ /\D/); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | #my $list_url = "http://www.uniprot.org/proteomes/?query=reference:$ref_only+taxonomy:$top_node&format=list"; | ||||||||||||||||||||
| 49 | 0 | my $list_url = "https://rest.uniprot.org/proteomes/stream?query=reference:$ref_only+taxonomy_id:$top_node&format=list"; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | my $resp = HTTP::Tiny->new->get($list_url); | |||||||||||||||||||
| 52 | die "Failed to fetch proteome list: $resp->{status} $resp->{reason}\n" | ||||||||||||||||||||
| 53 | 0 | ▶ | if (! $resp->{success}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 0 | @proteomes = split /\r?\n/, $resp->{content}; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||
| 57 | 0 | die "No taxonomy ID or proteome ID given!\n"; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | my $fasta; | |||||||||||||||||||
| 61 | my $want; | ||||||||||||||||||||
| 62 | my $reviewed = $self->{reviewed_only} | ||||||||||||||||||||
| 63 | 0 | ▶ | ? '+AND+reviewed:true' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | : ''; | ||||||||||||||||||||
| 65 | my $include = $self->{include_isoforms} | ||||||||||||||||||||
| 66 | 0 | ▶ | ? 'yes' | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | : 'no'; | ||||||||||||||||||||
| 68 | 0 | for (@proteomes) { | |||||||||||||||||||
| 69 | 0 | my $id = uri_escape($_); | |||||||||||||||||||
| 70 | 0 | warn "Fetching $id\n"; | |||||||||||||||||||
| 71 | #my $fetch_url = "http://www.uniprot.org/uniprot/?query=proteome:$id$reviewed&include=$include&format=fasta"; | ||||||||||||||||||||
| 72 | 0 | my $fetch_url = "https://rest.uniprot.org/uniprotkb/stream?query=proteome:$id$reviewed&include=$include&format=fasta"; | |||||||||||||||||||
| 73 | my $resp = HTTP::Tiny->new->get( $fetch_url, { data_callback | ||||||||||||||||||||
| 74 | 0 | ▶ | => sub { print {$wtr} $_[0] if ($_[1]->{status} < 300 ) } } ); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||
| 75 | die "Failed to fetch sequences for $_: $resp->{status} $resp->{reason}\n" | ||||||||||||||||||||
| 76 | 0 | ▶ | if (! $resp->{success}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | 0 | close $wtr; | |||||||||||||||||||
| 79 | 0 | exit; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 1 | 1; | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||