Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tag sniff pod and dependencies #849

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
57 changes: 27 additions & 30 deletions bin/npg_qc_tag_sniff.pl
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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/) {
Expand All @@ -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/;
Expand All @@ -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);
Expand All @@ -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/;
Expand All @@ -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]);
}
}
}
}
}
Expand Down Expand Up @@ -389,7 +375,7 @@ sub initialise {

=head1 NAME

tag_sniff.pl
npg_qc_tag_sniff.pl

=head1 USAGE

Expand All @@ -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
Expand All @@ -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

Expand All @@ -437,9 +432,11 @@ =head1 AUTHOR

Nadeem Faruque<lt>[email protected]<gt>

Steven Leonard<lt>[email protected]<gt>

=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.

Expand Down