Class PathClassTools
PathClass
objects.- Author:
- Pete Bankhead
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsName
(PathClass pathClass, String name) Query whether aPathClass
or any of its ancestor classes contains a specified name.static PathClass
getNonIntensityAncestorClass
(PathClass pathClass) Get the first ancestor class that is not an intensity class (i.e.static boolean
isGradedIntensityClass
(PathClass pathClass) Return true if the PathClass represents a built-in intensity class.static boolean
isIgnoredClass
(PathClass pathClass) Return true if the PathClass should be ignored from some operations, or is null.static boolean
isNegativeClass
(PathClass pathClass) Return true if the PathClass has the name "Negative".static boolean
isNullClass
(PathClass pathClass) Return true if the PathClass is null, its name is null or if it is equal to the special case of 'Unclassified' path object.static boolean
Returns true if the name of the class is "1+", indicating a weakly-positive staining.static boolean
isPositiveClass
(PathClass pathClass) Returntrue
if the PathClass has the name "Positive".static boolean
isPositiveOrGradedIntensityClass
(PathClass pathClass) Return true if the name of the class is "Positive", "1+", "2+" or "3+", indicating positive staining.static boolean
isThreePlus
(PathClass pathClass) Return true if the name of the class is "3+", indicating a weakly-positive staining.static boolean
Return true if the name of the class is "2+", indicating a moderately-positive staining.static boolean
isValidClass
(PathClass pathClass) Returns true if the PathClass represents a valid (non-null) classification.static PathClass
mergeClasses
(PathClass baseClass, PathClass additionalClass) Merge two classifications together.static PathClass
removeNames
(PathClass pathClass, String... namesToRemove) Create aPathClass
with specific name elements removed (if present) from an existing classification.static PathClass
removeNames
(PathClass pathClass, Collection<String> namesToRemove) Create aPathClass
with specific name elements removed (if present) from an existing classification.static PathClass
Create aPathClass
with name elements sorted alphabetically.static PathClass
sortNames
(PathClass pathClass, Comparator<String> comparator) Create aPathClass
with name elements sorted using an arbitraryComparator
.splitNames
(PathClass pathClass) Get a list containing the names of all constituent parts of aPathClass
.static PathClass
uniqueNames
(PathClass pathClass) Remove duplicate names from a derivedPathClass
.
-
Method Details
-
isGradedIntensityClass
Return true if the PathClass represents a built-in intensity class. Here, this means its name is equal to "1+", "2+" or "3+".- Parameters:
pathClass
-- Returns:
-
isIgnoredClass
Return true if the PathClass should be ignored from some operations, or is null. In practice, this checks if the PathClass is null or if the name is either null or ends with an asterisk. It is useful to avoid generating objects for certain classes (e.g. Ignore*, Artefact*, Background*) where these would not be meaningful.Warning: the 'ignored' status is ambiguous if the PathClass is null. In a future version this method may throw an exception rather than accepting null classifications. Code that calls this method therefore should explicitly handle cases where the PathClass is null (or its name is null) to avoid ambiguity and potential exceptions in the future.
- Parameters:
pathClass
-- Returns:
- See Also:
-
isNullClass
Return true if the PathClass is null, its name is null or if it is equal to the special case of 'Unclassified' path object.- Parameters:
pathClass
-- Returns:
-
isValidClass
Returns true if the PathClass represents a valid (non-null) classification.- Parameters:
pathClass
- input classification to check- Returns:
- true if the input represents a valid classification, or false if the input is null or is equivalent to
PathClass.NULL_CLASS
.
-
isOnePlus
Returns true if the name of the class is "1+", indicating a weakly-positive staining.- Parameters:
pathClass
-- Returns:
-
isTwoPlus
Return true if the name of the class is "2+", indicating a moderately-positive staining.- Parameters:
pathClass
-- Returns:
-
isThreePlus
Return true if the name of the class is "3+", indicating a weakly-positive staining.- Parameters:
pathClass
-- Returns:
-
isPositiveClass
Returntrue
if the PathClass has the name "Positive".- Parameters:
pathClass
-- Returns:
-
isPositiveOrGradedIntensityClass
Return true if the name of the class is "Positive", "1+", "2+" or "3+", indicating positive staining.- Parameters:
pathClass
-- Returns:
-
isNegativeClass
Return true if the PathClass has the name "Negative".- Parameters:
pathClass
-- Returns:
-
getNonIntensityAncestorClass
Get the first ancestor class that is not an intensity class (i.e. not negative, positive, 1+, 2+ or 3+).This will return null if pathClass is null or if no non-intensity class was found (e.g. 'Positive' instead of 'Tumor: Positive').
- Parameters:
pathClass
-- Returns:
-
splitNames
Get a list containing the names of all constituent parts of aPathClass
.- Parameters:
pathClass
- thePathClass
to split- Returns:
- an empty list if the class has no name or is null, otherwise an ordered list containing
the result of calling
PathClass.getName()
for all derived classes, starting from the root.
-
uniqueNames
Remove duplicate names from a derivedPathClass
. -
sortNames
Create aPathClass
with name elements sorted alphabetically. This can be useful when comparing classifications that may have been derived independently, and where the name order is unimportant. -
sortNames
Create aPathClass
with name elements sorted using an arbitraryComparator
. This can be useful when comparing classifications that may have been derived independently, and where the name order is unimportant. -
removeNames
Create aPathClass
with specific name elements removed (if present) from an existing classification. -
removeNames
Create aPathClass
with specific name elements removed (if present) from an existing classification. -
mergeClasses
Merge two classifications together. Specifically, the name components of the additional class that are not already contained within the base class will be appended, deriving a new class as required.Note that if the additional class contains duplicate names these will not automatically be stripped unless they are also present within the base class; use
uniqueNames(PathClass)
if this is required.- Parameters:
baseClass
- base class, all name components will be retainedadditionalClass
-- Returns:
- the merged classification, or null if both input classes are null
-
containsName
Query whether aPathClass
or any of its ancestor classes contains a specified name.For example a class
"CD3: CD8"
would return true for the name "CD3" or "CD8", but not anything else.- Parameters:
pathClass
- the classification to testname
- the name to search for- Returns:
- true if the name is found, false otherwise
-