SWISS::ListBase(3pm) | User Contributed Perl Documentation | SWISS::ListBase(3pm) |
SWISS::ListBase.pm
Base class for list oriented classes in the SWISS:: hierarchy. It provides a set of quite general list manipulation methods to inheriting classes.
$listBaseObject->set('EMBL', 'TREMBL', 'SWISSPROT'); $listBaseObject->get('.*EMBL');
returns ('EMBL', 'TREMBL')
$listBaseObject->set(['EMBL', 'M1', 'G1', '-'], ['EMBL', 'M2', 'A2', '-'], ['EMBL', 'M2', 'G3', 'ALT_TERM'], ['PROSITE', 'P00001', '1433_2', '1']); $listBaseObject->get('EMBL'); returns (['EMBL', 'M1', 'G1', '-'], ['EMBL', 'M2', 'A2', '-'], ['EMBL', 'M2', 'G3', 'ALT_TERM']) $listBaseObject->get('',M2); returns (['EMBL', 'M2', 'A2', '-'], ['EMBL', 'M2', 'G3', 'ALT_TERM']);
Offering get in the interface is not particularly nice because it exports implementation details into the interface, but it is a powerful method which may save a lot of programming time. As an alternative, the 'filter' concept is available.
Example:
$tmp = $entry->CCs->filter(&ccTopic('FUNCTION'));
returns a SWISS::CCs object containing all CC blocks from $entry which have the topic 'FUNCTION'.
Functions can also be anonymous functions.
Example:
$matchedKWs = $entry->KWs->filter(SWISS::ListBase::attributeEquals('text', $kw));
Example:
$matchedKWs = $entry->KWs->filter(SWISS::ListBase::attributeMatchedBy('text', $kw));
$listBaseObject->set('EMBL','TREMBL', 'SWISSPROT'); $listBaseObject->del('EMBL'); $listBaseObject->list(); returns ('TREMBL','SWISSPROT').
If you want to delete more, use something like
$listBaseObject->del('.*EMBL')
which deletes 'EMBL' and 'TREMBL'.
Warning: Empty elements in @patternList always match!
Using the data from the get example above,
$listBaseObject->del('','', 'A2')
results in
(['EMBL', 'M1', 'G1', '-'], ['EMBL', 'M2', 'G3', 'ALT_TERM'], ['PROSITE', 'P00001', '1433_2', '1'])
$listBaseObject->set(EMBL, TREMBL, SWISSPROT); $listBaseObject->add(EMBL, MGD, EMBL); $listBaseObject->unique();
results in (EMBL, TREMBL, SWISSPROT, MGD)
To be used if the ListBase elements are themselves arrays. A typical construct would be
foreach $dr ($entry->DRs->elements()) { $entry->DRs->setEvidenceTags($dr, 'E2', 'E3'); }
Returns $arrayPointer.
To be used if the ListBase elements are themselves arrays. See documentation of setEvidenceTags.
Returns $arrayPointer.
To be used if the ListBase elements are themselves arrays. A typical construct would be
foreach $dr ($entry->DRs->elements()) { $entry->DRs->deleteEvidenceTags($dr, 'EC2'); }
Returns $arrayPointer.
2021-08-15 | perl v5.32.1 |