API
helix.utility.unit_prefix.UnitPrefix
Convert a quantity into a more readable form using unit prefixes.
This class is expecially useful for very big or very small number, that are difficult to read or visualize.
Examples:
>>> UnitPrefix.convert_bytes(1024)
'1kB'
>>> UnitPrefix.convert(1000)
'1k'
>>> UnitPrefix.convert(0.01)
'10m'
Source code in helix\utility\unit_prefix.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 |
|
convert(input, decimal=2)
Convert a quantity using metric prefixes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
int
|
The number to convert. |
required |
decimal |
int
|
Number of decimals to use. Defaults to 2. |
2
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Converted number. |
Source code in helix\utility\unit_prefix.py
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 |
|
convert_bytes(input, decimal=2)
Convert bytes using binary prefixes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
int
|
The number to convert. |
required |
decimal |
int
|
Number of decimals to use. Defaults to 2. |
2
|
Raises:
Type | Description |
---|---|
ValueError
|
The input number is a float |
ValueError
|
The input number is negative. |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Converted number. |
Source code in helix\utility\unit_prefix.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
helix.alignment_map.variant_caller.VariantCaller
Bases: SimpleWorker
This class is responsible for calling variants for a given alignment-map file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
AlignmentMapFile
|
File that contains aligned reads. |
required |
calling_type |
VariantCallingType
|
Type of variant calling to perform. Defaults to VariantCallingType.Both. |
Both
|
repo_config |
RepositoryConfig
|
Configuration for reference genome repository. Defaults to MANAGER_CFG.REPOSITORY. |
REPOSITORY
|
ext_config |
ExternalConfig
|
Configuration for external tools. Defaults to MANAGER_CFG.EXTERNAL. |
EXTERNAL
|
external |
External
|
Object that contains functions to call external tools. Defaults to External(). |
External()
|
progress |
Callable[[str, int]
|
Function that accept a status message and a percentage, for progress tracking. Defaults to None. |
None
|
logger |
Logger
|
Logger object. Defaults to logging.getLogger(name). |
getLogger(__name__)
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the index stats inside |
RuntimeError
|
If the reference genome for |
Source code in helix\alignment_map\variant_caller.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
call()
Does exactly what you think it does.
Source code in helix\alignment_map\variant_caller.py
78 79 80 |
|
kill()
Kill a variant calling operation.
Source code in helix\alignment_map\variant_caller.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
helix.files.file_type_checker.FileTypeChecker
Gets the type of a file trying to not relying on its extension (if possible)
This class uses the utility htsfile
to get the type of a file. If it fails to
get the type of a file using htsfile
, it will try to guess its type based on its
extension.
Examples:
>>> input = Path("file.fasta")
>>> checker = FileTypeChecker()
>>> assert checker.get_type() == FileType.DECOMPRESSED
>>> input = input.rename("file")
>>> assert checker.get_ext() == ".fa"
Source code in helix\files\file_type_checker.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 |
|
get_extension(file)
Get an extension based on the content of the file.
NOTE: if the input file is gzipped/bgzipped, this function will assume the extension is .fa.gz
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
Path
|
Input file |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Extension |
Source code in helix\files\file_type_checker.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
get_type(file)
Get a Type starting from a file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
Path
|
Path of the file to analyze. |
required |
Returns:
Type | Description |
---|---|
FileType
|
Type | None: Type or None if the type is unknown. |
Source code in helix\files\file_type_checker.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
helix.naming.converter.Converter
Source code in helix\naming\converter.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 |
|
canonicalize(sequence_name)
Convert a sequence name into a "canonical" form, which is essentially the Number format:
- Digits only for autosome
- X/Y for sexual
- M for mitochondrial
- Other sequences are not touched
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence_name |
str
|
Sequence to convert |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Converted name sequence. |
Source code in helix\naming\converter.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
helix.reference.reference.Reference
This class represent a reference genome.
Source code in helix\reference\reference.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 |
|
helix.reference.repository.Repository
Manages the reference genomes and their metadata.
Examples:
>>> repository = Repository()
>>> reference = repository.find(file.file_info.sequences)
Source code in helix\reference\repository.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
acquire(genome, progress=None, force=False)
Download and convert to BGZip format (if necessary) a reference genome. Create additionals files that are needed by DoubleHelix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
genome |
Genome
|
Genome to acquire |
required |
progress |
Callable[[str, int], None]
|
Callback function that takes two arguments: a string indicating the progress message and an integer indicating the progress percentage. |
None
|
force |
bool
|
Determines whether to overwrite existing files. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Genome |
Genome
|
The reference genome. |
Source code in helix\reference\repository.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
ingest(url, source, build, force=False)
Add a genome to the repository.
Build a new Genome object with the input parameters and call acquire() on it
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
Url for the FASTA file. |
required |
source |
str
|
Source of the Genome (i.e., "Ensembl") |
required |
build |
str
|
Build of the Genome (i.e., "38"). |
required |
force |
bool
|
True to force the ingestion even if the files exist. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Genome |
Genome after ingestion |
Examples:
>>> manager = RepositoryManager()
>>> manager.genomes.append(
>>> manager.ingest(
>>> "https://source/reference.fa",
>>> "NIH", # Should match an entry in sources.json
>>> "38", # Only 38 or 37
>>> )
>>> )
>>> GenomeMetadataLoader().save(manager.genomes)
Source code in helix\reference\repository.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|