diff --git a/Build.PL b/Build.PL index b3a1ae2e..c4127179 100644 --- a/Build.PL +++ b/Build.PL @@ -43,6 +43,7 @@ my $requires = { 'List::MoreUtils' => 0, 'List::Util' => 0, 'Log::Log4perl' => 0, + 'LWP::Simple' => 0, 'LWP::UserAgent' => 0, 'Math::Round' => 0, 'MIME::Base64' => 0, @@ -69,6 +70,7 @@ my $requires = { 'REST::Client' => 0, 'Statistics::Lite' => 0, 'strict' => 0, + 'Term::ANSIColor' => 0, 'Text::CSV' => 0, 'Try::Tiny' => 0, 'warnings' => 0, diff --git a/bin/npg_qc_tag_sniff.pl b/bin/npg_qc_tag_sniff.pl index c0057695..8341995c 100755 --- a/bin/npg_qc_tag_sniff.pl +++ b/bin/npg_qc_tag_sniff.pl @@ -1,13 +1,4 @@ #!/usr/bin/env perl -######### -# Author: nf2 -# Created: 18 Nov 2011 -# - -######################### -# This script checks a bam file's tag sequences -# It should find the observed tags, and map them to tagsets and the expected tags -######################### use strict; use warnings; @@ -17,7 +8,9 @@ use LWP::Simple qw(get); use JSON; -# this URL returns a complete set of known tags in json format +use WTSI::DNAP::Warehouse::Schema; + +# This URL returns a complete set of known tags in json format our $LIMS_TAGS_URL = q[https://sequencescape.psd.sanger.ac.uk/api/v2/tag_groups]; ##no critic @@ -104,12 +97,6 @@ sub showTags{ my %tagsFound = @_; my $unassigned = $sampleSize; - my $class = 'WTSI::DNAP::Warehouse::Schema'; - my $loaded = eval "require $class"; ## no critic (BuiltinFunctions::ProhibitStringyEval) - if (!$loaded) { - croak q[Can't load module WTSI::DNAP::Warehouse::Schema]; - } - my %db_tags = (); if ($groups =~ /\.taglist/) { @@ -126,7 +113,7 @@ sub showTags{ next if m/^barcode/; croak "Invalid tag $_" unless m/^([ACGT]+)\t(\d+)\t/; my ($sequence,$tag_index) = ($1,$2); - my $original = $sequence; + my $original = $sequence; push(@{$db_tags{$sequence}},[$name,$id,$tag_index,0,$original]); if (@{$revcomps}) { $sequence =~ tr/ACGTN/TGCAN/; @@ -137,7 +124,6 @@ sub showTags{ close(FILE); } } elsif ($groups =~ /\d+_\d/) { - # read the npg_plex_infomation table my $s = WTSI::DNAP::Warehouse::Schema->connect(); my $rs; my @rls = split(/[,]/, $groups); @@ -154,7 +140,7 @@ sub showTags{ if (!defined $tag_index || !defined $sequence) { next; } - my $original = $sequence; + my $original = $sequence; push(@{$db_tags{$sequence}},[$name,$id,$tag_index,0,$original]); if (@{$revcomps}) { $sequence =~ tr/ACGTN/TGCAN/; @@ -171,19 +157,19 @@ sub showTags{ map {$groups{$_}++} (split(/[,]/, $groups)); } foreach my $group (@{$t->{"data"}}) { - my $id = $group->{"id"}; - next if (%groups && !exists($groups{$id})); - my $name = $group->{"attributes"}->{"name"}; - foreach my $tag (@{$group->{"attributes"}->{"tags"}}) { - my $sequence = $tag->{"oligo"}; - my $map_id = $tag->{"index"}; - my $original = $sequence; + my $id = $group->{"id"}; + next if (%groups && !exists($groups{$id})); + my $name = $group->{"attributes"}->{"name"}; + foreach my $tag (@{$group->{"attributes"}->{"tags"}}) { + my $sequence = $tag->{"oligo"}; + my $map_id = $tag->{"index"}; + my $original = $sequence; push(@{$db_tags{$sequence}},[$name,$id,$map_id,0,$original]); if (@{$revcomps}) { $sequence =~ tr/ACGTN/TGCAN/; $sequence = reverse($sequence); push(@{$db_tags{$sequence}},[$name,$id,$map_id,1,$original]); - } + } } } } @@ -389,7 +375,7 @@ sub initialise { =head1 NAME -tag_sniff.pl +npg_qc_tag_sniff.pl =head1 USAGE @@ -401,6 +387,9 @@ =head1 SYNOPSIS =head1 DESCRIPTION +This script finds the actual tag sequences in a SAM file and maps them +to tagsets and the expected tags. + =head1 SUBROUTINES/METHODS =head1 DIAGNOSTICS @@ -425,7 +414,13 @@ =head1 DEPENDENCIES =item Getopt::Long -=item npg_warehouse::Schema +=item Term::ANSIColor + +=item LWP::Simple + +=item JSON + +=item WTSI::DNAP::Warehouse::Schema =back @@ -437,9 +432,11 @@ =head1 AUTHOR Nadeem Faruquenf2@sanger.ac.ukE +Steven Leonardsrl@sanger.ac.ukE + =head1 LICENSE AND COPYRIGHT -Copyright (C) 2011 GRL, by Nadeem Faruque +Copyright (C) 2011,2014,2015,2016,2017,2018,2022,2023 Genome Research Ltd. This file is part of NPG.