Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
062e3e05
Commit
062e3e05
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
show full compId for modified residues in sequence widget
parent
1465174a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-model/sequence/sequence.ts
+32
-18
32 additions, 18 deletions
src/mol-model/sequence/sequence.ts
with
32 additions
and
18 deletions
src/mol-model/sequence/sequence.ts
+
32
−
18
View file @
062e3e05
...
@@ -54,30 +54,37 @@ namespace Sequence {
...
@@ -54,30 +54,37 @@ namespace Sequence {
function
determineKind
(
names
:
Column
<
string
>
)
{
function
determineKind
(
names
:
Column
<
string
>
)
{
for
(
let
i
=
0
,
_i
=
Math
.
min
(
names
.
rowCount
,
10
);
i
<
_i
;
i
++
)
{
for
(
let
i
=
0
,
_i
=
Math
.
min
(
names
.
rowCount
,
10
);
i
<
_i
;
i
++
)
{
const
name
=
names
.
value
(
i
)
||
''
;
const
name
=
names
.
value
(
i
)
||
''
;
if
(
getProteinOneLetterCode
(
name
)
!==
'
X
'
)
return
{
kind
:
Kind
.
Protein
,
code
:
getProteinOneLetterCode
}
;
if
(
getProteinOneLetterCode
(
name
)
!==
'
X
'
)
return
Kind
.
Protein
;
if
(
getRnaOneLetterCode
(
name
)
!==
'
X
'
)
return
{
kind
:
Kind
.
RNA
,
code
:
getRnaOneLetterCode
}
;
if
(
getRnaOneLetterCode
(
name
)
!==
'
X
'
)
return
Kind
.
RNA
;
if
(
getDnaOneLetterCode
(
name
)
!==
'
X
'
)
return
{
kind
:
Kind
.
DNA
,
code
:
getDnaOneLetterCode
}
;
if
(
getDnaOneLetterCode
(
name
)
!==
'
X
'
)
return
Kind
.
DNA
;
}
}
return
{
kind
:
Kind
.
Generic
,
code
:
(
v
:
string
)
=>
'
X
'
}
;
return
Kind
.
Generic
;
}
}
function
modCode
(
code
:
(
name
:
string
)
=>
string
,
map
:
ReadonlyMap
<
string
,
string
>
):
(
name
:
string
)
=>
string
{
function
codeProvider
(
kind
:
Kind
,
map
?:
ReadonlyMap
<
string
,
string
>
)
{
return
n
=>
{
let
code
:
(
name
:
string
)
=>
string
const
ret
=
code
(
n
);
switch
(
kind
)
{
if
(
ret
!==
'
X
'
||
!
map
.
has
(
n
))
return
ret
;
case
Kind
.
Protein
:
code
=
getProteinOneLetterCode
;
break
;
return
code
(
map
.
get
(
n
)
!
);
case
Kind
.
DNA
:
code
=
getDnaOneLetterCode
;
break
;
case
Kind
.
RNA
:
code
=
getRnaOneLetterCode
;
break
;
case
Kind
.
Generic
:
code
=
()
=>
'
X
'
;
break
;
default
:
throw
new
Error
(
`unknown kind '
${
kind
}
'`
)
}
}
if
(
map
&&
map
.
size
>
0
)
{
return
(
name
:
string
)
=>
{
const
ret
=
code
(
name
);
if
(
ret
!==
'
X
'
||
!
map
.
has
(
name
))
return
ret
;
return
code
(
map
.
get
(
name
)
!
);
}
}
return
code
}
}
export
function
ofResidueNames
(
compId
:
Column
<
string
>
,
seqId
:
Column
<
number
>
,
modifiedMap
?:
ReadonlyMap
<
string
,
string
>
):
Sequence
{
export
function
ofResidueNames
(
compId
:
Column
<
string
>
,
seqId
:
Column
<
number
>
,
modifiedMap
?:
ReadonlyMap
<
string
,
string
>
):
Sequence
{
if
(
seqId
.
rowCount
===
0
)
throw
new
Error
(
'
cannot be empty
'
);
if
(
seqId
.
rowCount
===
0
)
throw
new
Error
(
'
cannot be empty
'
);
const
{
kind
,
code
}
=
determineKind
(
compId
);
const
kind
=
determineKind
(
compId
);
return
new
ResidueNamesImpl
(
kind
,
compId
,
seqId
,
modifiedMap
)
as
Sequence
;
if
(
!
modifiedMap
||
modifiedMap
.
size
===
0
)
{
return
new
ResidueNamesImpl
(
kind
,
compId
,
seqId
,
code
)
as
Sequence
;
}
return
new
ResidueNamesImpl
(
kind
,
compId
,
seqId
,
modCode
(
code
,
modifiedMap
))
as
Sequence
;
}
}
class
ResidueNamesImpl
<
K
extends
Kind
,
Alphabet
extends
string
>
implements
Base
<
K
,
Alphabet
>
{
class
ResidueNamesImpl
<
K
extends
Kind
,
Alphabet
extends
string
>
implements
Base
<
K
,
Alphabet
>
{
...
@@ -87,6 +94,8 @@ namespace Sequence {
...
@@ -87,6 +94,8 @@ namespace Sequence {
private
_code
:
Column
<
Alphabet
>
|
undefined
=
undefined
private
_code
:
Column
<
Alphabet
>
|
undefined
=
undefined
private
_label
:
Column
<
string
>
|
undefined
=
undefined
private
_label
:
Column
<
string
>
|
undefined
=
undefined
private
codeFromName
:
(
name
:
string
)
=>
string
get
code
():
Column
<
Alphabet
>
{
get
code
():
Column
<
Alphabet
>
{
if
(
this
.
_code
!==
void
0
)
return
this
.
_code
;
if
(
this
.
_code
!==
void
0
)
return
this
.
_code
;
this
.
create
();
this
.
create
();
...
@@ -142,11 +151,15 @@ namespace Sequence {
...
@@ -142,11 +151,15 @@ namespace Sequence {
const
seqId
=
this
.
seqId
.
value
(
i
)
const
seqId
=
this
.
seqId
.
value
(
i
)
const
idx
=
seqId
-
minSeqId
;
const
idx
=
seqId
-
minSeqId
;
const
name
=
this
.
compId
.
value
(
i
);
const
name
=
this
.
compId
.
value
(
i
);
const
code
=
this
.
getCod
e
(
name
);
const
code
=
this
.
codeFromNam
e
(
name
);
// in case of MICROHETEROGENEITY `sequenceArray[idx]` may already be set
// in case of MICROHETEROGENEITY `sequenceArray[idx]` may already be set
if
(
!
sequenceArray
[
idx
]
||
sequenceArray
[
idx
]
===
'
-
'
)
{
if
(
!
sequenceArray
[
idx
]
||
sequenceArray
[
idx
]
===
'
-
'
)
{
if
(
code
===
'
X
'
&&
this
.
modifiedMap
&&
this
.
modifiedMap
.
has
(
name
))
{
sequenceArray
[
idx
]
=
this
.
modifiedMap
.
get
(
name
)
!
}
else
{
sequenceArray
[
idx
]
=
code
;
sequenceArray
[
idx
]
=
code
;
}
}
}
labels
[
idx
].
push
(
code
===
'
X
'
?
name
:
code
);
labels
[
idx
].
push
(
code
===
'
X
'
?
name
:
code
);
compIds
[
seqId
].
push
(
name
);
compIds
[
seqId
].
push
(
name
);
}
}
...
@@ -170,8 +183,9 @@ namespace Sequence {
...
@@ -170,8 +183,9 @@ namespace Sequence {
this
.
_length
=
count
this
.
_length
=
count
}
}
constructor
(
public
kind
:
K
,
public
compId
:
Column
<
string
>
,
public
seqId
:
Column
<
number
>
,
private
getCode
:
(
name
:
string
)
=>
string
)
{
constructor
(
public
kind
:
K
,
public
compId
:
Column
<
string
>
,
public
seqId
:
Column
<
number
>
,
private
modifiedMap
?:
ReadonlyMap
<
string
,
string
>
)
{
this
.
codeFromName
=
codeProvider
(
kind
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment