-
- All Implemented Interfaces:
public class CreateGraphUtils
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
NO_CONSENSUS_METHOD
-
Method Summary
Modifier and Type Method Description static Connection
connection(String propertiesFile)
Creates a database connection given a properties file static Connection
connection(String host, String user, String password, String dbName)
Creates a sqlite database connection. static Map<Integer, ReferenceRange>
referenceRangeMap(Connection database)
Retrieves all ReferenceRange instances static SortedSet<ReferenceRange>
referenceRanges(Connection database)
Retrieves all ReferenceRange instances with specified genome interval version name. static Map<Integer, TaxaList>
taxaListMap(Connection database)
Retrieves all groups of taxa. static TreeMap<ReferenceRange, List<HaplotypeNode>>
createHaplotypeNodes(Connection database, Map<Integer, ReferenceRange> referenceRangeMap, Map<Integer, TaxaList> taxaListMap, List<Tuple<String, String>> methods, boolean includeSequences, boolean includeVariantContext, SortedSet<Integer> includeHapids, List<String> chromosomes, TaxaList taxaToKeep)
static TreeMap<ReferenceRange, List<HaplotypeNode>>
createHaplotypeNodesWithVariants(Connection database, Set<HaplotypeNode> includeHapNodes)
Creates lists of HaplotypeNodes with variant contexts corresponding to the specified nodes organized by reference Range. static HaplotypeGraph
createHaplotypeNodesWithVariants(Connection database, HaplotypeGraph graph)
Creates HaplotypeGraph with variant contexts corresponding to the given HaplotypeGraph. static HaplotypeGraph
addMissingSequenceNodes(HaplotypeGraph graph)
static int
addMissingSequenceNodes(TreeMap<ReferenceRange, List<HaplotypeNode>> result)
static TaxaList
taxaInNodes(TreeMap<ReferenceRange, List<HaplotypeNode>> nodes)
static TreeMap<ReferenceRange, List<HaplotypeNode>>
tree(HaplotypeGraph graph)
static HaplotypeGraph
nodesSplitByIndividualTaxa(HaplotypeGraph graph, double sameTaxonPercent)
static TreeMap<ReferenceRange, List<HaplotypeNode>>
createHaplotypeNodes(Connection database, List<Tuple<String, String>> methods, boolean includeSequences, boolean includeVariantContext, SortedSet<Integer> includeHapids, List<String> chromosomes, TaxaList taxaToKeep)
static List<HaplotypeEdge>
createEdges(Collection<HaplotypeNode> haplotypeNodes)
Generates Edges based on HaplotypeNodes. static List<HaplotypeEdge>
createEdges(NavigableMap<ReferenceRange, List<HaplotypeNode>> rangeToNode)
static List<HaplotypeEdge>
createEdges(List<HaplotypeNode> leftNodes, List<HaplotypeNode> rightNodes)
static void
compareEdges(List<HaplotypeEdge> edges1, List<HaplotypeEdge> edges2)
static String
getRefLineName(Connection database)
Returns the line name of the reference genotype static int
methodId(Connection database, String method_name)
Returns method id (methods.method_id) for given method name. static HaplotypeGraph
subsetGraph(HaplotypeGraph graph, TaxaList taxa)
Create graph that's a subset of the given graph which contains only nodes from the taxa list. static HaplotypeGraph
removeRefRanges(HaplotypeGraph graph, double minPercentTaxa)
Removes reference ranges from given graph that represent less than given minimum percent of total taxa. static HaplotypeGraph
removeRefRanges(HaplotypeGraph graph, int minCountTaxa)
Removes reference ranges from given graph that represent less than given minimum number of taxa. static HaplotypeGraph
removeRefRanges(HaplotypeGraph graph, List<ReferenceRange> ranges)
Removes specified reference ranges from graph. static HaplotypeGraph
keepRefRanges(HaplotypeGraph graph, List<ReferenceRange> ranges)
Creates graph that includes specified reference ranges. static HaplotypeGraph
keepRefRangeIDs(HaplotypeGraph graph, List<Integer> rangeIDs)
static HaplotypeGraph
keepHapIDs(HaplotypeGraph graph, SortedSet<Integer> hapids)
Filters the given graph to keep only the specified haplotype ids. -
-
Method Detail
-
connection
static Connection connection(String propertiesFile)
Creates a database connection given a properties file
- Parameters:
propertiesFile
- properties file
-
connection
static Connection connection(String host, String user, String password, String dbName)
Creates a sqlite database connection.
- Parameters:
host
- hostnameuser
- user idpassword
- passworddbName
- database name
-
referenceRangeMap
static Map<Integer, ReferenceRange> referenceRangeMap(Connection database)
Retrieves all ReferenceRange instances
- Parameters:
database
- database connection
-
referenceRanges
static SortedSet<ReferenceRange> referenceRanges(Connection database)
Retrieves all ReferenceRange instances with specified genome interval version name.
- Parameters:
database
- database connection
-
taxaListMap
static Map<Integer, TaxaList> taxaListMap(Connection database)
Retrieves all groups of taxa.
- Parameters:
database
- database connection
-
createHaplotypeNodes
static TreeMap<ReferenceRange, List<HaplotypeNode>> createHaplotypeNodes(Connection database, Map<Integer, ReferenceRange> referenceRangeMap, Map<Integer, TaxaList> taxaListMap, List<Tuple<String, String>> methods, boolean includeSequences, boolean includeVariantContext, SortedSet<Integer> includeHapids, List<String> chromosomes, TaxaList taxaToKeep)
-
createHaplotypeNodesWithVariants
static TreeMap<ReferenceRange, List<HaplotypeNode>> createHaplotypeNodesWithVariants(Connection database, Set<HaplotypeNode> includeHapNodes)
Creates lists of HaplotypeNodes with variant contexts corresponding to the specified nodes organized by reference Range. LCJ June 16, 2022- this function is only called from MergeGVCFPlugin:extractNodesWithVariants() MergeGVCFPlugin has been deprecated, so I am not making changes here to pull gvcf files for the variants. If this function is called at some point from a non-deprecated method, we can re-look at what changes are needed.
- Parameters:
database
- database connectionincludeHapNodes
- includes specified hapids
-
createHaplotypeNodesWithVariants
static HaplotypeGraph createHaplotypeNodesWithVariants(Connection database, HaplotypeGraph graph)
Creates HaplotypeGraph with variant contexts corresponding to the given HaplotypeGraph.
- Parameters:
database
- database connectiongraph
- graph without variant contexts
-
addMissingSequenceNodes
static HaplotypeGraph addMissingSequenceNodes(HaplotypeGraph graph)
-
addMissingSequenceNodes
static int addMissingSequenceNodes(TreeMap<ReferenceRange, List<HaplotypeNode>> result)
-
taxaInNodes
static TaxaList taxaInNodes(TreeMap<ReferenceRange, List<HaplotypeNode>> nodes)
-
tree
static TreeMap<ReferenceRange, List<HaplotypeNode>> tree(HaplotypeGraph graph)
-
nodesSplitByIndividualTaxa
static HaplotypeGraph nodesSplitByIndividualTaxa(HaplotypeGraph graph, double sameTaxonPercent)
-
createHaplotypeNodes
static TreeMap<ReferenceRange, List<HaplotypeNode>> createHaplotypeNodes(Connection database, List<Tuple<String, String>> methods, boolean includeSequences, boolean includeVariantContext, SortedSet<Integer> includeHapids, List<String> chromosomes, TaxaList taxaToKeep)
-
createEdges
static List<HaplotypeEdge> createEdges(Collection<HaplotypeNode> haplotypeNodes)
Generates Edges based on HaplotypeNodes. Database information not used.
- Parameters:
haplotypeNodes
- HaplotypeNodes
-
createEdges
static List<HaplotypeEdge> createEdges(NavigableMap<ReferenceRange, List<HaplotypeNode>> rangeToNode)
-
createEdges
static List<HaplotypeEdge> createEdges(List<HaplotypeNode> leftNodes, List<HaplotypeNode> rightNodes)
-
compareEdges
static void compareEdges(List<HaplotypeEdge> edges1, List<HaplotypeEdge> edges2)
-
getRefLineName
static String getRefLineName(Connection database)
Returns the line name of the reference genotype
-
methodId
static int methodId(Connection database, String method_name)
Returns method id (methods.method_id) for given method name.
- Parameters:
database
- database connectionmethod_name
- method name
-
subsetGraph
static HaplotypeGraph subsetGraph(HaplotypeGraph graph, TaxaList taxa)
Create graph that's a subset of the given graph which contains only nodes from the taxa list.
- Parameters:
graph
- original graphtaxa
- taxa list
-
removeRefRanges
static HaplotypeGraph removeRefRanges(HaplotypeGraph graph, double minPercentTaxa)
Removes reference ranges from given graph that represent less than given minimum percent of total taxa.
- Parameters:
graph
- graphminPercentTaxa
- minimum percent taxa
-
removeRefRanges
static HaplotypeGraph removeRefRanges(HaplotypeGraph graph, int minCountTaxa)
Removes reference ranges from given graph that represent less than given minimum number of taxa.
- Parameters:
graph
- graphminCountTaxa
- minimum number of taxa
-
removeRefRanges
static HaplotypeGraph removeRefRanges(HaplotypeGraph graph, List<ReferenceRange> ranges)
Removes specified reference ranges from graph.
- Parameters:
graph
- graphranges
- reference ranges to remove
-
keepRefRanges
static HaplotypeGraph keepRefRanges(HaplotypeGraph graph, List<ReferenceRange> ranges)
Creates graph that includes specified reference ranges.
- Parameters:
graph
- graphranges
- ranges to keep
-
keepRefRangeIDs
static HaplotypeGraph keepRefRangeIDs(HaplotypeGraph graph, List<Integer> rangeIDs)
-
keepHapIDs
static HaplotypeGraph keepHapIDs(HaplotypeGraph graph, SortedSet<Integer> hapids)
Filters the given graph to keep only the specified haplotype ids.
- Parameters:
graph
- input graphhapids
- list of haplotype ids to keep
-
-
-
-