Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Cosy-Bio
Drugst.One
plugin
Commits
bf08763b
Commit
bf08763b
authored
4 years ago
by
Julian Späth
Committed by
Julian Matschinske
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Connect backend
parent
ffa5905c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/api.service.ts
+18
-0
18 additions, 0 deletions
src/app/api.service.ts
src/app/app.module.ts
+4
-1
4 additions, 1 deletion
src/app/app.module.ts
src/app/pages/explorer-page/explorer-page.component.ts
+21
-57
21 additions, 57 deletions
src/app/pages/explorer-page/explorer-page.component.ts
with
43 additions
and
58 deletions
src/app/api.service.ts
0 → 100644
+
18
−
0
View file @
bf08763b
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
environment
}
from
'
../environments/environment
'
;
const
networkUrl
=
`
${
environment
.
backend
}
`
+
'
network
'
;
@
Injectable
({
providedIn
:
'
root
'
})
export
class
ApiService
{
constructor
(
private
http
:
HttpClient
)
{
}
async
getNetwork
()
{
return
this
.
http
.
get
(
networkUrl
).
toPromise
();
}
}
This diff is collapsed.
Click to expand it.
src/app/app.module.ts
+
4
−
1
View file @
bf08763b
...
...
@@ -9,6 +9,8 @@ import { AppComponent } from './app.component';
import
{
ExplorerPageComponent
}
from
'
./pages/explorer-page/explorer-page.component
'
;
import
{
AboutPageComponent
}
from
'
./pages/about-page/about-page.component
'
;
import
{
HomePageComponent
}
from
'
./pages/home-page/home-page.component
'
;
import
{
HttpClientModule
}
from
'
@angular/common/http
'
;
@
NgModule
({
declarations
:
[
...
...
@@ -21,7 +23,8 @@ import {HomePageComponent} from './pages/home-page/home-page.component';
BrowserModule
,
AppRoutingModule
,
FormsModule
,
CommonModule
CommonModule
,
HttpClientModule
],
providers
:
[],
bootstrap
:
[
AppComponent
]
...
...
This diff is collapsed.
Click to expand it.
src/app/pages/explorer-page/explorer-page.component.ts
+
21
−
57
View file @
bf08763b
import
{
AfterViewInit
,
Component
,
ElementRef
,
OnInit
,
ViewChild
}
from
'
@angular/core
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
environment
}
from
'
../../../environments/environment
'
;
import
{
Effect
,
ProteinNetwork
}
from
'
../protein-network
'
;
import
{
ApiService
}
from
'
../../api.service
'
;
declare
var
vis
:
any
;
...
...
@@ -23,14 +26,20 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
public
proteinData
:
ProteinNetwork
;
public
proteinGroups
:
any
;
public
effects
:
any
;
public
edges
:
any
;
private
network
:
any
;
private
nodeData
:
{
nodes
:
any
,
edges
:
any
}
=
{
nodes
:
null
,
edges
:
null
};
private
networkData
:
any
=
[];
private
seed
=
1
;
// TODO: Remove this
@
ViewChild
(
'
network
'
,
{
static
:
false
})
networkEl
:
ElementRef
;
constructor
(
private
route
:
ActivatedRoute
,
private
router
:
Router
)
{
constructor
(
private
route
:
ActivatedRoute
,
private
router
:
Router
,
private
api
:
ApiService
)
{
this
.
groupId
=
'
IFI16
'
;
this
.
geneNames
.
push
(
'
IFI16
'
);
this
.
proteinNames
.
push
(
'
Gamma-interface-inducible protein 16
'
);
...
...
@@ -70,12 +79,21 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
ngOnInit
()
{
}
async
ngAfterViewInit
()
{
if
(
!
this
.
network
)
{
await
this
.
createNetwork
();
}
}
private
async
getNetwork
()
{
const
data
:
any
=
await
this
.
api
.
getNetwork
();
this
.
proteinGroups
=
data
.
proteinGroups
;
this
.
effects
=
data
.
effects
;
this
.
edges
=
data
.
edges
;
}
public
zoomToNode
(
id
:
string
)
{
const
coords
=
this
.
network
.
getPositions
(
id
)[
id
];
this
.
network
.
moveTo
({
...
...
@@ -99,8 +117,8 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
}
private
async
createNetwork
()
{
const
{
proteinGroups
,
effects
,
edges
:
proteinEdges
}
=
await
this
.
load
Network
();
this
.
proteinData
=
new
ProteinNetwork
(
proteinGroups
,
effects
,
proteinE
dges
);
await
this
.
get
Network
();
this
.
proteinData
=
new
ProteinNetwork
(
this
.
proteinGroups
,
this
.
effects
,
this
.
e
dges
);
this
.
proteinData
.
loadPositions
();
this
.
proteinData
.
linkNodes
();
...
...
@@ -114,8 +132,6 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
const
{
nodes
,
edges
}
=
this
.
mapDataToNodes
(
this
.
proteinData
);
console
.
log
(
nodes
,
edges
);
this
.
nodeData
.
nodes
=
new
vis
.
DataSet
(
nodes
);
this
.
nodeData
.
edges
=
new
vis
.
DataSet
(
edges
);
...
...
@@ -203,58 +219,6 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this
.
nodeData
.
nodes
.
add
(
Array
.
from
(
addNodes
.
values
()));
}
private
async
loadNetwork
():
Promise
<
any
>
{
// TODO: Load from backend instead of generating random stuff here...
const
proteinGroupCount
=
10000
;
const
effectCount
=
50
;
const
edgeCount
=
2000
;
const
proteinGroups
=
[];
const
effects
=
[];
const
edges
=
[];
for
(
let
i
=
0
;
i
<
effectCount
;
i
++
)
{
effects
.
push
({
id
:
i
,
name
:
`eff
${
i
}
`
,
});
}
const
proteinGroupIds
=
[];
for
(
let
i
=
0
;
i
<
edgeCount
;
i
++
)
{
const
proteinGroupId
=
Math
.
floor
(
this
.
random
()
*
proteinGroupCount
);
const
effectId
=
Math
.
floor
(
this
.
random
()
*
effects
.
length
);
let
found
=
false
;
for
(
const
edge
of
edges
)
{
if
(
edge
.
proteinGroupId
===
proteinGroupId
&&
edge
.
effectId
===
effectId
)
{
found
=
true
;
break
;
}
}
if
(
!
found
)
{
edges
.
push
({
proteinGroupId
,
effectId
});
if
(
proteinGroupIds
.
indexOf
(
proteinGroupId
)
===
-
1
)
{
proteinGroupIds
.
push
(
proteinGroupId
);
}
}
}
for
(
const
proteinGroupId
of
proteinGroupIds
)
{
proteinGroups
.
push
({
id
:
proteinGroupId
,
name
:
`pg
${
proteinGroupId
}
`
,
});
}
return
{
proteinGroups
,
effects
,
edges
};
}
private
mapProteinGroupToNode
(
proteinGroup
:
any
):
any
{
return
{
...
...
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