Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pbarth
Genome-viewer
Commits
3b7a92a1
Commit
3b7a92a1
authored
Sep 07, 2018
by
Patrick Blumenkamp
Browse files
integrate genome-viewer in genome-vuer
parent
86da9d7b
Changes
5
Show whitespace changes
Inline
Side-by-side
genome-vuer/src/css/main.css
deleted
100644 → 0
View file @
86da9d7b
/*
* What follows is the result of much research on cross-browser styling.
* Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
* Kroc Camen, and the H5BP dev community and team.
*/
/* ==========================================================================
Base styles: opinionated defaults
========================================================================== */
html
{
color
:
#222
;
font-size
:
1em
;
line-height
:
1.4
;
}
/*
* Remove text-shadow in selection highlight:
* https://twitter.com/miketaylr/status/12228805301
*
* Vendor-prefixed and regular ::selection selectors cannot be combined:
* https://stackoverflow.com/a/16982510/7133471
*
* Customize the background color to match your design.
*/
::selection
{
background
:
#b3d4fc
;
text-shadow
:
none
;
}
/*
* A better looking default horizontal rule
*/
hr
{
display
:
block
;
height
:
1px
;
border
:
0
;
border-top
:
1px
solid
#ccc
;
margin
:
1em
0
;
padding
:
0
;
}
/*
* Remove the gap between audio, canvas, iframes,
* images, videos and the bottom of their containers:
* https://github.com/h5bp/html5-boilerplate/issues/440
*/
audio
,
canvas
,
iframe
,
img
,
svg
,
video
{
vertical-align
:
middle
;
}
/*
* Remove default fieldset styles.
*/
fieldset
{
border
:
0
;
margin
:
0
;
padding
:
0
;
}
/*
* Allow only vertical resizing of textareas.
*/
textarea
{
resize
:
vertical
;
}
/* ==========================================================================
Browser Upgrade Prompt
========================================================================== */
.browserupgrade
{
margin
:
0.2em
0
;
background
:
#ccc
;
color
:
#000
;
padding
:
0.2em
0
;
}
/* ==========================================================================
Author's custom styles
========================================================================== */
/* ==========================================================================
Helper classes
========================================================================== */
/*
* Hide visually and from screen readers
*/
.hidden
{
display
:
none
!important
;
}
/*
* Hide only visually, but have it available for screen readers:
* https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
*
* 1. For long content, line feeds are not interpreted as spaces and small width
* causes content to wrap 1 word per line:
* https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
*/
.visuallyhidden
{
border
:
0
;
clip
:
rect
(
0
0
0
0
);
height
:
1px
;
margin
:
-1px
;
overflow
:
hidden
;
padding
:
0
;
position
:
absolute
;
width
:
1px
;
white-space
:
nowrap
;
/* 1 */
}
/*
* Extends the .visuallyhidden class to allow the element
* to be focusable when navigated to via the keyboard:
* https://www.drupal.org/node/897638
*/
.visuallyhidden.focusable
:active
,
.visuallyhidden.focusable
:focus
{
clip
:
auto
;
height
:
auto
;
margin
:
0
;
overflow
:
visible
;
position
:
static
;
width
:
auto
;
white-space
:
inherit
;
}
/*
* Hide visually and from screen readers, but maintain layout
*/
.invisible
{
visibility
:
hidden
;
}
/*
* Clearfix: contain floats
*
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* `contenteditable` attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that receive the `clearfix` class.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.clearfix
:before
,
.clearfix
:after
{
content
:
" "
;
/* 1 */
display
:
table
;
/* 2 */
}
.clearfix
:after
{
clear
:
both
;
}
/* ==========================================================================
EXAMPLE Media Queries for Responsive Design.
These examples override the primary ('mobile first') styles.
Modify as content requires.
========================================================================== */
@media
only
screen
and
(
min-width
:
35em
)
{
/* Style adjustments for viewports that meet the condition */
}
@media
print
,
(
min-resolution
:
1.25dppx
),
(
min-resolution
:
120dpi
)
{
/* Style adjustments for high resolution devices */
}
/* ==========================================================================
Print styles.
Inlined to avoid the additional HTTP request:
https://www.phpied.com/delay-loading-your-print-css/
========================================================================== */
@media
print
{
*,
*
:before
,
*
:after
{
background
:
transparent
!important
;
color
:
#000
!important
;
/* Black prints faster */
box-shadow
:
none
!important
;
text-shadow
:
none
!important
;
}
a
,
a
:visited
{
text-decoration
:
underline
;
}
a
[
href
]
:after
{
content
:
" ("
attr
(
href
)
")"
;
}
abbr
[
title
]
:after
{
content
:
" ("
attr
(
title
)
")"
;
}
/*
* Don't show links that are fragment identifiers,
* or use the `javascript:` pseudo protocol
*/
a
[
href
^=
"#"
]
:after
,
a
[
href
^=
"javascript:"
]
:after
{
content
:
""
;
}
pre
{
white-space
:
pre-wrap
!important
;
}
pre
,
blockquote
{
border
:
1px
solid
#999
;
page-break-inside
:
avoid
;
}
/*
* Printing Tables:
* http://css-discuss.incutio.com/wiki/Printing_Tables
*/
thead
{
display
:
table-header-group
;
}
tr
,
img
{
page-break-inside
:
avoid
;
}
p
,
h2
,
h3
{
orphans
:
3
;
widows
:
3
;
}
h2
,
h3
{
page-break-after
:
avoid
;
}
}
genome-vuer/src/css/viz-linear-sequence.css
0 → 100644
View file @
3b7a92a1
div
.tooltip
{
text-align
:
left
;
font
:
12px
'Roboto Mono'
,
monospace
;
background
:
black
;
color
:
white
;
border
:
5px
;
border-radius
:
5px
;
padding
:
5px
;
pointer-events
:
none
;
position
:
fixed
;
}
div
.tooltip
:after
{
bottom
:
100%
;
left
:
50%
;
border
:
solid
transparent
;
content
:
" "
;
color
:
black
;
position
:
absolute
;
pointer-events
:
none
;
border-color
:
rgba
(
255
,
255
,
255
,
0
);
border-bottom-color
:
#000000
;
border-width
:
8px
;
margin-left
:
-8px
;
}
\ No newline at end of file
genome-vuer/src/index.html
View file @
3b7a92a1
...
...
@@ -7,13 +7,16 @@
<title></title>
<meta
name=
"description"
content=
""
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
<script
src=
"https://d3js.org/d3.v4.min.js"
></script>
<script
src=
"../lib/vue.js"
></script>
<script
src=
"./js/viz-linear-sequence.js"
defer
></script>
<link
href=
"./css/viz-linear-sequence.css"
rel=
"stylesheet"
>
</head>
<body>
<genome-viewer
>
{{ message }}
</genome-viewer
>
<div
id=
"app"
>
<genome-viewer/>
</div
>
<script
src=
"js/genome_viewer.js"
></script>
</body>
...
...
genome-vuer/src/js/genome_viewer.js
View file @
3b7a92a1
let
genome_viewer
=
{
template
:
`
<div class="container-lin-dna">
<div id="linear-DNA-1" class="lin-dna" data-cluster-start=1706479 data-cluster-end=1718084 style="width: 100%; height: 50px;">
<div class="region-to-display" data-region-name="Gene 1" data-region-description="GMP synthase" data-region-start=1706479 data-region-end=1708024 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 2" data-region-description="glyoxalase" data-region-start=1708314 data-region-end=1708671 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 3" data-region-description="ABC transporter ATP-binding protein LlsG" data-region-start=1709429 data-region-end=1710317 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 4" data-region-description="ABC transporter permease protein LlsH" data-region-start=1710316 data-region-end=1711066 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 5" data-region-description="LlsX" data-region-start=1711106 data-region-end=1711424 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 6" data-region-description="SagB family dehydrogenase LlsB" data-region-start=1711420 data-region-end=1712296 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 7" data-region-description="LlsY" data-region-start=1712303 data-region-end=1713221 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 8" data-region-description="streptolysin-associated protein LlsD" data-region-start=1713213 data-region-end=1714527 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 9" data-region-description="hypothetical protein" data-region-start=1715351 data-region-end=1716125 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 10" data-region-description="glyoxalase family protein, N-terminal part" data-region-start=1716189 data-region-end=1716321 data-region-strand="+" data-region-type="gene">
</div>
<div class="region-to-display" data-region-name="Gene 11" data-region-description="hypothetical protein" data-region-start=1717235 data-region-end=1718084 data-region-strand="-" data-region-type="gene">
</div>
</div>
</div>`
}
var
app
=
new
Vue
({
el
:
'
#app
'
,
components
:
{
'
genome-viewer
'
:
genome_viewer
},
data
:
{
message
:
'
Hello Vue!
'
}
})
genome-vuer/src/js/viz-linear-sequence.js
0 → 100644
View file @
3b7a92a1
(
function
(
d3
)
{
var
div
=
d3
.
select
(
"
body
"
)
.
append
(
"
div
"
)
.
attr
(
"
class
"
,
"
tooltip
"
)
.
style
(
"
opacity
"
,
0
);
Array
.
from
(
document
.
getElementsByClassName
(
"
container-lin-dna
"
)
).
forEach
(
(
e
)
=>
{
e
.
style
.
padding
=
'
4rem 5rem
'
;
}
);
Array
.
from
(
document
.
getElementsByClassName
(
"
lin-dna
"
)
).
forEach
(
(
e
)
=>
{
const
svgHeight
=
e
.
clientHeight
;
const
svgWidth
=
e
.
clientWidth
;
const
padding
=
40
;
//create axis
const
xScale
=
d3
.
scaleLinear
()
.
domain
(
[
e
.
getAttribute
(
"
data-cluster-start
"
),
e
.
getAttribute
(
"
data-cluster-end
"
)
]
)
.
range
(
[
0
,
svgWidth
]
);
const
xAxis
=
d3
.
axisBottom
(
xScale
);
const
svgContainer
=
d3
.
select
(
e
).
append
(
"
svg
"
)
.
attr
(
'
width
'
,
svgWidth
+
padding
*
2
)
.
attr
(
'
height
'
,
svgHeight
+
padding
*
2
)
.
append
(
"
g
"
)
.
attr
(
'
transform
'
,
'
translate(
'
+
0
+
'
,
'
+
padding
+
'
)
'
);
svgContainer
.
append
(
"
g
"
)
.
attr
(
'
transform
'
,
'
translate(
'
+
0
+
'
,
'
+
5
+
'
)
'
)
.
call
(
xAxis
);
//create visualization of DNA-Elements
const
lineGenerator
=
d3
.
line
();
svgContainer
.
selectAll
(
'
.arrow
'
)
.
data
(
collectDNARegionData
(
e
)
)
.
enter
()
.
append
(
'
path
'
)
.
attr
(
'
class
'
,
'
arrow
'
)
.
attr
(
'
data-toggle
'
,
'
tooltip
'
)
.
attr
(
'
data-placement
'
,
'
bottom
'
)
.
attr
(
'
d
'
,
d
=>
{
return
lineGenerator
(
returnRegionAreaPoints
(
d
,
xScale
)
)
}
)
.
style
(
'
fill
'
,
d
=>
{
return
returnSectionColor
(
d
.
type
)
}
)
.
style
(
'
opacity
'
,
0.6
)
.
on
(
"
mouseover
"
,
function
(
d
)
{
this
.
style
.
opacity
=
1
;
div
.
style
(
"
opacity
"
,
.
9
)
.
style
(
"
width
"
,
"
220px
"
)
.
style
(
"
left
"
,
(
this
.
getBoundingClientRect
().
x
+
(
this
.
getBoundingClientRect
().
width
/
2
)
-
110
)
+
"
px
"
)
.
style
(
"
top
"
,
(
this
.
getBoundingClientRect
().
bottom
+
10
)
+
"
px
"
);
div
.
html
(
d
=>
returnStringForPopup
(
this
.
__data__
)
)
})
.
on
(
"
mouseout
"
,
function
(
d
)
{
this
.
style
.
opacity
=
0.6
;
div
.
style
(
"
opacity
"
,
0
);
});
}
);
}
)(
d3
);
function
returnStringForPopup
(
regionElement
){
var
text
=
""
;
//build table
text
=
text
.
concat
(
"
<table><tbody><tr><td style=
\"
vertical-align:top
\"
><b>Name</b>:</td><td>
"
+
regionElement
.
name
+
"
</td></tr>
"
)
text
=
text
.
concat
(
"
<tr><td style=
\"
vertical-align:top
\"
><b>Desc</b>:</td><td>
"
+
regionElement
.
desc
+
"
</td></tr>
"
)
text
=
text
.
concat
(
"
<tr><td style=
\"
vertical-align:top
\"
><b>Start</b>:</td><td>
"
+
regionElement
.
start
+
"
</td></tr>
"
)
text
=
text
.
concat
(
"
<tr><td style=
\"
vertical-align:top
\"
><b>End</b>:</td><td>
"
+
regionElement
.
end
+
"
</td></tr>
"
)
text
=
text
.
concat
(
"
<tr><td style=
\"
vertical-align:top
\"
><b>Type</b>:</td><td>
"
+
regionElement
.
type
+
"
</td></tr>
"
)
Array
.
from
(
Object
.
keys
(
regionElement
)
).
forEach
(
key
=>
{
if
(
key
.
match
(
"
data-optional-
"
)
){
text
=
text
.
concat
(
"
<tr><td style=
\"
vertical-align:top
\"
><b>
"
+
key
.
replace
(
"
data-optional-
"
,
""
)
+
"
</b>:</td><td>
"
+
regionElement
[
key
]
+
"
</td></tr>
"
)
}
}
)
text
=
text
.
concat
(
"
</tbody></table>
"
)
return
text
;
}
function
returnSectionColor
(
type
)
{
switch
(
type
)
{
case
'
region
'
:
return
'
#bdbdbd
'
// greyLighten
case
'
gene
'
:
return
'
#757575
'
// greyDarken
case
'
cds
'
:
return
'
#000000
'
// black
case
'
rRNA
'
:
return
'
#795548
'
// brown
case
'
tRNA
'
:
return
'
#4caf50
'
// green
case
'
ncRNA
'
:
return
'
#ff9800
'
// orange
default
:
return
-
1
}
}
function
collectDNARegionData
(
clusterElement
)
{
var
data
=
[];
Array
.
from
(
clusterElement
.
getElementsByClassName
(
"
region-to-display
"
)
).
forEach
(
(
e
)
=>
{
var
regionData
=
{
"
name
"
:
e
.
getAttribute
(
"
data-region-name
"
),
"
desc
"
:
e
.
getAttribute
(
"
data-region-description
"
),
"
start
"
:
e
.
getAttribute
(
"
data-region-start
"
),
"
end
"
:
e
.
getAttribute
(
"
data-region-end
"
),
"
strand
"
:
e
.
getAttribute
(
"
data-region-strand
"
),
"
type
"
:
e
.
getAttribute
(
"
data-region-type
"
)
};
Array
.
from
(
e
.
attributes
).
forEach
(
(
attr
)
=>
{
if
(
attr
.
name
.
match
(
"
data-optional-
"
)
){
regionData
[
attr
.
name
]
=
attr
.
value
console
.
log
(
regionData
[
attr
.
name
]
)
}
}
);
data
.
push
(
regionData
);
}
);
return
data
;
}
function
returnRegionAreaPoints
(
data
,
xScale
)
{
const
peakWidth
=
10
;
const
height
=
-
40
;
const
mid
=
height
/
2
;
let
points
=
[];
//check for correct data type and strand
if
(
returnSectionColor
(
data
.
type
)
!==
-
1
&&
(
data
.
strand
===
"
+
"
||
data
.
strand
===
"
-
"
)
){
//return drawing points
if
(
data
.
type
===
'
region
'
)
{
points
=
[
[
xScale
(
data
.
start
),
0
],
[
xScale
(
data
.
end
),
0
],
[
xScale
(
data
.
end
),
height
],
[
xScale
(
data
.
start
),
height
]
];
}
else
if
(
xScale
(
data
.
end
)
-
xScale
(
data
.
start
)
<=
peakWidth
)
{
//draw short arrows (without shaft)
if
(
data
.
strand
===
"
+
"
)
{
points
=
[
[
xScale
(
data
.
start
),
0
],
[
xScale
(
data
.
end
),
mid
],
[
xScale
(
data
.
start
),
height
]
]
}
else
if
(
data
.
strand
===
"
-
"
)
{
points
=
[
[
xScale
(
data
.
end
),
0
],
[
xScale
(
data
.
start
),
mid
],
[
xScale
(
data
.
end
),
height
]
]
}
}
else
{
//draw longer arrows (with shaft)
if
(
data
.
strand
===
"
+
"
)
{
points
=
[
[
xScale
(
data
.
start
),
0
],
[
xScale
(
data
.
end
)
-
peakWidth
,
0
],
[
xScale
(
data
.
end
),
mid
],
[
xScale
(
data
.
end
)
-
peakWidth
,
height
],
[
xScale
(
data
.
start
),
height
]
]
}
else
if
(
data
.
strand
===
"
-
"
)
{
points
=
[
[
xScale
(
data
.
start
),
mid
],
[
xScale
(
data
.
start
)
+
peakWidth
,
0
],
[
xScale
(
data
.
end
),
0
],
[
xScale
(
data
.
end
),
height
],
[
xScale
(
data
.
start
)
+
peakWidth
,
height
]
]
}
}
}
else
{
console
.
log
(
`Unknown type: "`
+
data
.
type
+
`" or unknown strand: "`
+
data
.
strand
+
`"`
);
}
return
points
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment