sample_index_factory
This module houses SampleIndex factory methods.
create_hierarchy(num_samples, bundle_size, directory_sizes=None, root='.', start_sample_id=0, start_bundle_id=0, address='', n_digits=1)
Factory method to create a SampleIndex
hierarchy based on the number of samples.
This method wraps the
create_hierarchy_from_max_sample
function, which operates on a maximum sample basis rather than a total
sample count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_samples
|
int
|
The total number of samples. |
required |
bundle_size
|
int
|
The maximum number of samples a bundle file can handle. |
required |
directory_sizes
|
List[int]
|
A list specifying the number of samples each directory is responsible for. |
None
|
root
|
str
|
The root path of the index. |
'.'
|
start_sample_id
|
int
|
The starting sample ID. |
0
|
start_bundle_id
|
int
|
The starting bundle ID. |
0
|
address
|
str
|
An optional address prefix for the hierarchy. |
''
|
n_digits
|
int
|
The number of digits to pad the directory names. |
1
|
Returns:
| Type | Description |
|---|---|
SampleIndex
|
The root |
Source code in merlin/common/sample_index_factory.py
create_hierarchy_from_max_sample(max_sample, bundle_size, directory_sizes=None, root='.', start_bundle_id=0, min_sample=0, address='', n_digits=1)
Constructs a SampleIndex hierarchy based on
the maximum sample ID and chunking size at each depth.
This method adds new SampleIndex objects as
children if directory_sizes is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_sample
|
int
|
The maximum Sample ID this hierarchy is responsible for. |
required |
bundle_size
|
int
|
The maximum number of samples a bundle file can handle. |
required |
directory_sizes
|
List[int]
|
A list specifying the number of samples each directory is responsible for. |
None
|
root
|
str
|
The root path of this index. |
'.'
|
start_bundle_id
|
int
|
The starting bundle ID. |
0
|
min_sample
|
int
|
The starting sample ID. |
0
|
address
|
str
|
An optional address prefix for the hierarchy. |
''
|
n_digits
|
int
|
The number of digits to pad the directory names. |
1
|
Returns:
| Type | Description |
|---|---|
SampleIndex
|
The root
|
Source code in merlin/common/sample_index_factory.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
read_hierarchy(path)
Reads a hierarchy from a specified path and constructs a
SampleIndex.
This function reads a file named "sample_index.txt" in the given path,
parsing its contents to create a hierarchical structure of
SampleIndex objects based on the
information found in the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The directory path where the sample index file is located. |
required |
Returns:
| Type | Description |
|---|---|
SampleIndex
|
The root
|