1
1
import { get , isBoolean , isFinite , isNil , isNumber , isString , range , sumBy } from 'lodash'
2
2
import type {
3
3
Aa ,
4
- AnyType ,
5
4
Cds ,
6
5
CdsSegment ,
7
6
Dataset ,
8
7
DatasetsIndexJson ,
8
+ PathogenJson ,
9
9
FastaRecord ,
10
10
InsertionFor_Nuc , // eslint-disable-line camelcase
11
11
LetterRangeFor_AaAnd_Position , // eslint-disable-line camelcase
12
12
LetterRangeFor_NucAnd_Position , // eslint-disable-line camelcase
13
- NextcladeErrorOutputs ,
14
- NextcladeOutputs ,
15
13
NextcladeResult ,
14
+ ResultJson ,
15
+ ResultJsonError ,
16
16
Nuc ,
17
17
NucDel ,
18
18
NucSub ,
@@ -28,16 +28,18 @@ export function rangeLen(range: Range) {
28
28
return range . end - range . begin
29
29
}
30
30
31
+ export type AnyType = unknown
31
32
export type Nucleotide = Nuc
32
33
export type Aminoacid = Aa
33
34
export type NucleotideRange = LetterRangeFor_NucAnd_Position // eslint-disable-line camelcase
34
35
export type AminoacidRange = LetterRangeFor_AaAnd_Position // eslint-disable-line camelcase
35
36
export type NucleotideInsertion = InsertionFor_Nuc // eslint-disable-line camelcase
36
37
export type NucleotideMissing = LetterRangeFor_NucAnd_Position // eslint-disable-line camelcase
37
- export type AnalysisResult = NextcladeOutputs
38
- export type AnalysisError = NextcladeErrorOutputs
38
+ export type AnalysisResult = ResultJson
39
+ export type AnalysisError = ResultJsonError
39
40
export type FastaRecordId = StrictOmit < FastaRecord , 'seq' >
40
41
export type DatasetsIndexV2Json = DatasetsIndexJson
42
+ export type VirusProperties = PathogenJson
41
43
42
44
export function cdsNucLength ( cds : Cds ) {
43
45
return sumBy ( cds . segments , cdsSegmentNucLength )
@@ -120,27 +122,27 @@ export function areDatasetsEqual(left?: Dataset, right?: Dataset): boolean {
120
122
return ! isNil ( left ?. path ) && ! isNil ( right ?. path ) && left ?. path === right ?. path
121
123
}
122
124
123
- export function anyAsStrMaybe ( x : AnyType | undefined ) : string | undefined {
125
+ export function anyAsStrMaybe ( x : unknown | undefined ) : string | undefined {
124
126
return isString ( x ) ? x : undefined
125
127
}
126
128
127
- export function anyAsNumberMaybe ( x : AnyType | undefined ) : number | undefined {
129
+ export function anyAsNumberMaybe ( x : unknown | undefined ) : number | undefined {
128
130
return isNumber ( x ) && isFinite ( x ) ? x : undefined
129
131
}
130
132
131
- export function anyAsBoolMaybe ( x : AnyType | undefined ) : boolean | undefined {
133
+ export function anyAsBoolMaybe ( x : unknown | undefined ) : boolean | undefined {
132
134
return isBoolean ( x ) ? x : undefined
133
135
}
134
136
135
- export function attrStrMaybe ( attributes : Record < string , AnyType > | undefined , name : string ) : string | undefined {
137
+ export function attrStrMaybe ( attributes : Record < string , unknown > | undefined , name : string ) : string | undefined {
136
138
return anyAsStrMaybe ( get ( attributes , name ) )
137
139
}
138
140
139
- export function attrNumberMaybe ( attributes : Record < string , AnyType > | undefined , name : string ) : number | undefined {
141
+ export function attrNumberMaybe ( attributes : Record < string , unknown > | undefined , name : string ) : number | undefined {
140
142
return anyAsNumberMaybe ( get ( attributes , name ) )
141
143
}
142
144
143
- export function attrBoolMaybe ( attributes : Record < string , AnyType > | undefined , name : string ) : boolean | undefined {
145
+ export function attrBoolMaybe ( attributes : Record < string , unknown > | undefined , name : string ) : boolean | undefined {
144
146
return anyAsBoolMaybe ( get ( attributes , name ) )
145
147
}
146
148
0 commit comments