Skip to content

Commit

Permalink
Dropped derived library type and barcode sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed Oct 27, 2023
1 parent 385d7a5 commit fd3a5fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 66 deletions.
84 changes: 19 additions & 65 deletions lib/st/api/lims.pm
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ sub BUILD {
Readonly::Hash my %ATTRIBUTE_LIST_METHODS => {
'library' => [qw/ id
name
type
/],
'sample' => [qw/ accession_number
cohort
Expand Down Expand Up @@ -357,9 +358,6 @@ sub _build_tag_sequence {
Read-only array accessor, not possible to set from the constructor.
Empty array on a lane level and for zero tag_index.
Might return not the index given by LIMs, but the one contained in the
sample description.
If dual index is used, the array contains two sequences. The secons index
might come from LIMS or, if LIMs has one long index, it will be split in two.
Expand All @@ -372,34 +370,24 @@ has 'tag_sequences' => (isa => 'ArrayRef',
sub _build_tag_sequences {
my $self = shift;

my ($seq, $seq2);
my @sqs = ();

if ($self->tag_index) {
if (!$self->spiked_phix_tag_index || $self->tag_index != $self->spiked_phix_tag_index) {
if ($self->sample_description) {
$seq = _tag_sequence_from_sample_description($self->sample_description);
my $seq = $self->default_tag_sequence;
if ($seq) {
push @sqs, $seq;
$seq = $self->default_tagtwo_sequence;
if ($seq) {
push @sqs, $seq;
}
}
if (!$seq) {
$seq = $self->default_tag_sequence;
if ($seq && $self->default_tagtwo_sequence) {
$seq2 = $self->default_tagtwo_sequence;
}
}
}

my @sqs = ();
if ($seq) {
push @sqs, $seq;
}
if ($seq2) {
push @sqs, $seq2;
}

if (scalar @sqs == 1) {
if (length($sqs[0]) == $DUAL_INDEX_TAG_LENGTH) {
my $tag_length = $DUAL_INDEX_TAG_LENGTH/2;
push @sqs, substr $sqs[0], $tag_length;
$sqs[0] = substr $sqs[0], 0, $tag_length;
if (scalar @sqs == 1) {
if (length($sqs[0]) == $DUAL_INDEX_TAG_LENGTH) {
my $tag_length = $DUAL_INDEX_TAG_LENGTH/2;
push @sqs, substr $sqs[0], $tag_length;
$sqs[0] = substr $sqs[0], 0, $tag_length;
}
}
}

Expand Down Expand Up @@ -1101,55 +1089,21 @@ has 'library_type' => (isa => 'Maybe[Str]',
);
sub _build_library_type {
my $self = shift;
if($self->is_pool) { return; }
return _derived_library_type($self);
}

sub _derived_library_type {
my $o = shift;
my $type = $o->default_library_type;
if ($o->tag_index && $o->sample_description &&
_tag_sequence_from_sample_description($o->sample_description)) {
$type = '3 prime poly-A pulldown';
my $type;
if (!$self->is_pool) {
$type = $self->default_library_type;
}
$type ||= undef;
return $type;
}

sub _tag_sequence_from_sample_description {
my $desc = shift;
my @x = _parse_sample_description($desc);
return $x[0];
}

sub _parse_sample_description {
my $desc = shift;
my $tag=undef;
my $start=undef;
my $end=undef;
my $read=undef;
if ($desc && (($desc =~ m/base\ indexing\ sequence/ismx) && ($desc =~ m/enriched\ mRNA/ismx))) {
($tag) = $desc =~ /\(([ACGT]+)\)/smx;
if ($desc =~ /bases\ (\d+)\ to\ (\d+)\ of\ read\ 1/smx) {
($start, $end, $read) = ($1, $2, 1);
} elsif ($desc =~ /bases\ (\d+)\ to\ (\d+)\ of\ non\-index\ read\ (\d)/smx) {
($start, $end, $read) = ($1, $2, $3);
} else {
croak q[Error parsing sample description ] . $desc;
}
}
return ($tag, $start, $end, $read);
return $type;
}

=head2 library_types
A list of library types, excluding spiked phix library
=cut
sub library_types {
my ($self) = @_;
return $self->_list_of_attributes('_derived_library_type',0);
}

=head2 driver_method_list
Expand Down
4 changes: 3 additions & 1 deletion t/40-st-lims.t
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ subtest 'Consent and separation of human data' => sub {
};

subtest 'Library types' => sub {
plan tests => 6;
plan tests => 7;

local $ENV{NPG_CACHED_SAMPLESHEET_FILE} =
't/data/samplesheet/4pool4libs_extended.csv';
Expand All @@ -872,6 +872,8 @@ subtest 'Library types' => sub {
is($lims->library_type, 'No PCR', 'library type');
$lims = st::api::lims->new(id_run => 9999, position => 8);
is($lims->library_type, undef, 'library type undefined for a pool');
is(join(q[,], $lims->library_types), q[Pre-quality controlled],
'library types');
$lims = st::api::lims->new(id_run => 9999, position => 8, tag_index => 0);
is($lims->library_type, undef, 'library type undefined for tag 0');
$lims = st::api::lims->new(id_run => 9999, position => 8, tag_index => 88);
Expand Down

0 comments on commit fd3a5fe

Please sign in to comment.