public class TaxaUtil extends Object
OtuUtil
.BuildTaxaTables
.Modifier and Type | Field and Description |
---|---|
static String |
FILE_EXT |
static String |
NORMALIZED
File suffix appended to normalized taxa count tables: "norm"
|
protected static String |
TAXA_TABLE
Included in the file name of each file output.
|
Modifier and Type | Method and Description |
---|---|
static List<String> |
allTaxonomyLevels()
Returns a list of all taxonomy levels, not only the levels configured via
Config ."report.taxonomyLevels". |
static String |
bottomTaxaLevel()
Return the bottom configured taxonomy level from
Config ."report.taxonomyLevels" |
static TreeSet<String> |
findUniqueTaxa(TreeSet<String> otus,
String level)
Extract taxonomy names at the given level from all given OTUs.
|
static String |
getLeafLevel(String otu)
Return OTU taxonomy level for the leaf edge of the OTU
|
static Integer |
getLevelNum(String level)
Return the absolute taxonomy level for the given level.
|
static TreeMap<String,TreeMap<String,Long>> |
getLevelTaxaCounts(TreeMap<String,TreeMap<String,Long>> sampleOtuCounts,
String level)
Return TreeMap keyed on Sample ID, each sample maps to an inner map(taxa, count).
Input param sampleOtuCounts contains OTUs for which many can share the same level taxonomy assignment. For example if sample42 contained the following 3 OTU values: phylum__Actinobacteria|class__Actinobacteria|order__Actinomycetales|family__Actinomycetaceae|genus__Actinomyces 1000 phylum__Bacteroidetes|class__Bacteroidia|order__Bacteroidales|family__Porphyromonadaceae|genus__Barnesiella 500 phylum__Bacteroidetes|class__Bacteroidia|order__Bacteroidales|family__Porphyromonadaceae|genus__Parabacteroides 77 The phylum level output would contain entries: TreeMap(sample42, TreeMap( Actinobacteria=1000, Bacteroidetes=577 ) ) |
static TreeMap<String,String> |
getTaxaByLevel(String otu)
Return a map of the given otu parameter split by level.
|
static List<String> |
getTaxaLevels()
Method ensures taxonomy levels are returned in descending order from top to bottom.
|
static List<String> |
getTaxaLevelSpan()
Return taxa levels from top to bottom level, including in-between levels not configured as part of
|
static String |
getTaxaName(String otu,
String level)
Extract a taxonomy name at the given level from the given OTU.
|
static File |
getTaxonomyTableFile(File dir,
String level,
String suffix)
Create File object of a taxonomy table at the given level, with the given suffix, in the given directory dir.
|
static String |
getTaxonomyTableLevel(File file)
Extract the table taxonomy level from an existing taxonomy table file.
|
static String |
getUnclassifiedTaxa(String taxa,
String level)
Build the name of an unclassified taxa using the given "taxa" parameter.
Returns a name like Unclassified (taxa name) Taxa |
static List<String> |
initTaxaLevels()
Set taxonomy levels ordered by level, from highest to lowest.
|
static boolean |
isLogNormalizedTaxaFile(File file)
Check the file name to determine if it is a Log normalized taxonomy table file.
|
static boolean |
isNormalizedTaxaFile(File file)
Check the file name to determine if it is a normalized taxonomy table file.
|
static boolean |
isTaxaFile(File file)
Check the file name to determine if it is a taxonomy table file.
|
static String |
parentTaxaLevel(String level)
Get parent level name of the given level parameter.
|
static TaxaLevelTable |
readTaxaTable(File taxaTable)
Read a table of counts, formatted with samples as rows (ids in first column) and taxa as columns (ids in header).
|
static String |
topTaxaLevel()
Return the top configured taxonomy level from
Config ."report.taxonomyLevels" |
static void |
writeDataToFile(File outFile,
List<String> sampleNames,
List<String> taxaNames,
TaxaLevelTable taxaCounts)
Write transformed data to file
|
static void |
writeDataToFile(File outFile,
TaxaLevelTable taxaCounts) |
public static final String NORMALIZED
protected static final String TAXA_TABLE
public static final String FILE_EXT
public static List<String> allTaxonomyLevels()
Config
."report.taxonomyLevels".public static String bottomTaxaLevel()
Config
."report.taxonomyLevels"public static TreeSet<String> findUniqueTaxa(TreeSet<String> otus, String level)
otus
- TreeSet of OTUs in ParserModule
formatlevel
- Config
."report.taxonomyLevels"public static String getLeafLevel(String otu)
otu
- OTUpublic static Integer getLevelNum(String level)
level
- Taxonomy levelpublic static TreeMap<String,TreeMap<String,Long>> getLevelTaxaCounts(TreeMap<String,TreeMap<String,Long>> sampleOtuCounts, String level)
sampleOtuCounts
- TreeMap(sampleId, TreeMap(OTU, count)) OTU counts for every samplelevel
- Config
."report.taxonomyLevels"public static TreeMap<String,String> getTaxaByLevel(String otu)
otu
- OTU path valuepublic static List<String> getTaxaLevels()
public static List<String> getTaxaLevelSpan()
public static String getTaxaName(String otu, String level)
otu
- OTU name in ParserModule
formatlevel
- Config
."report.taxonomyLevels"public static File getTaxonomyTableFile(File dir, String level, String suffix) throws BioLockJException
dir
- Target directorylevel
- Taxonomy levelsuffix
- File suffixBioLockJException
- if level is nullpublic static String getTaxonomyTableLevel(File file)
file
- File Taxonomy Tablepublic static String getUnclassifiedTaxa(String taxa, String level)
taxa
- Taxa parent namelevel
- Taxa parent levelpublic static List<String> initTaxaLevels() throws ConfigNotFoundException, ConfigFormatException, DockerVolCreationException
ConfigNotFoundException
- if is undefinedConfigFormatException
- if is defined, but does not contain any
valid taxonomy levelsDockerVolCreationException
public static boolean isLogNormalizedTaxaFile(File file)
file
- File to testpublic static boolean isNormalizedTaxaFile(File file)
file
- File to testpublic static boolean isTaxaFile(File file)
file
- File to testpublic static String parentTaxaLevel(String level)
level
- Taxonomy levelpublic static String topTaxaLevel()
Config
."report.taxonomyLevels"public static TaxaLevelTable readTaxaTable(File taxaTable) throws FileNotFoundException, IOException, BioLockJException
taxaTable
- FileNotFoundException
IOException
BioLockJException
public static void writeDataToFile(File outFile, List<String> sampleNames, List<String> taxaNames, TaxaLevelTable taxaCounts) throws Exception
outFile
- File to write tosampleNames
- Sample names to includetaxaNames
- Taxa names to includetaxaCounts
- transformed Taxa countsException
- if errors occurpublic static void writeDataToFile(File outFile, TaxaLevelTable taxaCounts) throws Exception
Exception