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

Proposal to split semicolon delimited values in full ISA-Tab, if needed #3

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions ISA/lib/perl/StudyAssayEntity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,11 @@ sub addFactorValue {
}
sub getFactorValues { $_[0]->{_factor_values} || [] }

#
# allow StudyAssayFileReader->readLineToObjects() to split this entity
# into multiple entities based on a delimiter
#
sub isSplittable { return 0 }
sub getSplitDelimiter { die "getSplitDelimiter() called on a non-splittable object" }

1;
3 changes: 3 additions & 0 deletions ISA/lib/perl/StudyAssayEntity/Characteristic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ sub qualifierContextMethod {
return "addCharacteristic";
}

sub isSplittable { return 1; }
sub getSplitDelimiter { return qr/;\s*/ }

1;
26 changes: 26 additions & 0 deletions ISA/lib/perl/StudyAssayFileReader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,33 @@ sub readLineToObjects {
}
}

@rv = map { $_->isSplittable() ? splitObject($_) : $_ } @rv;

return \@rv;
}

sub splitObject {
my ($obj) = @_;
my $delimiter = $obj->getDelimiter();
my @rv = ();

# Do something like this:
#
# check that $obj->getValue and the scalar return values of $obj->getXXX (wjere XXX in $obj->getAttributeNames)
# all split to the same number of values, N.
#
# there could be object attributes such as from $obj->getUnit
# if so, I guess check that that has the same number of splits as $obj->getValue
#
# that could also have sub-objects? so potentially do this recursively?
#
# if all is good, create N new objects, ideally by a deep copy of $obj, then
# go in to each copy and split and replace all the scalar values with the
# appropriate value (e.g. for the second of three objects, replace 'aaa;bbb;ccc' with 'bbb')
#
# otherwise warn about the split count mismatch and return the original object?

return @rv;
}

1;