Skip to content

Commit c9a000d

Browse files
committed
Now works with python3 + django 2.1.3
1 parent 037bdfa commit c9a000d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1327
-196
lines changed

NetExplorer/models.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -777,14 +777,14 @@ def write(self, what=None):
777777
'''
778778
Writes to temp file
779779
'''
780-
with open(self.filename.name, "wb") as fh:
780+
with open(self.filename.name, "w") as fh:
781781
if self.header is not None:
782782
fh.write(self.header)
783783
for elem in self.elements:
784784
if self.fformat == 'csv':
785785
fh.write( "%s\n" % ",".join(elem) )
786786
elif self.fformat == 'fasta':
787-
formatseq = "".join(elem[1][i:i+64] + "\n" for i in xrange(0,len(elem[1]), 64))
787+
formatseq = "".join(elem[1][i:i+64] + "\n" for i in range(0,len(elem[1]), 64))
788788
fh.write(">%s|%s\n%s" % (elem[0], elem[2], formatseq))
789789
else:
790790
raise InvalidFormat(self.fformat)
@@ -796,7 +796,7 @@ def to_response(self, what=None):
796796
'''
797797
if self.written is False:
798798
self.write(what)
799-
wrapper = FileWrapper(file(self.filename.name))
799+
wrapper = FileWrapper(open(self.filename.name))
800800
response = HttpResponse(wrapper, content_type='text/plain')
801801
response['Content-Disposition'] = 'attachment; filename=%s' % self.oname
802802
response['Content-Length'] = os.path.getsize(self.filename.name)
@@ -1604,7 +1604,7 @@ def add_ylab(self, ylab):
16041604
def is_empty(self):
16051605
empty = True
16061606
for trace in self.traces:
1607-
for condition, expression in trace.iteritems():
1607+
for condition, expression in trace.items():
16081608
if sum(expression):
16091609
empty = False
16101610
break
@@ -1908,7 +1908,7 @@ def get_allowed_datasets(cls, user):
19081908
Returns QuerySet of allowed datasets for a given user
19091909
'''
19101910
public_datasets = cls.objects.filter(public=True).order_by('-year')
1911-
if not user.is_authenticated():
1911+
if not user.is_authenticated:
19121912
# Return only public datasets
19131913
return public_datasets
19141914
else:
@@ -1954,7 +1954,7 @@ def get_allowed_experiments(cls, user):
19541954
Returns QuerySet of allowed experiments for a given user
19551955
'''
19561956
public_experiments = cls.objects.filter(public=True).order_by('name')
1957-
if not user.is_authenticated():
1957+
if not user.is_authenticated:
19581958
# Return only public datasets
19591959
return public_experiments
19601960
else:
@@ -2091,7 +2091,7 @@ class CellPlotPosition(models.Model):
20912091
class ExpressionRelative(models.Model):
20922092
experiment = models.ForeignKey(Experiment, on_delete=models.CASCADE)
20932093
condition1 = models.ForeignKey(Condition, on_delete=models.CASCADE, related_name='condition1_expressionrelative_set')
2094-
condition2 = models.ForeignKey(Condition, on_delete=models.CASCADE, related_name='condition1_expressionrelative_setsubcondition_')
2094+
condition2 = models.ForeignKey(Condition, on_delete=models.CASCADE, related_name='condition1_expressionrelative_setsubcondition')
20952095
cond_type = models.ForeignKey(ConditionType, on_delete=models.CASCADE)
20962096
dataset = models.ForeignKey(Dataset, on_delete=models.CASCADE)
20972097
gene_symbol = models.CharField(max_length=50)

NetExplorer/static/js/get-card.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function getCard(card_data) {
77
elementID = "card-overlay";
88
$.ajax({
99
type: "GET",
10-
url: "/info_card",
10+
url: window.ROOT + "/info_card",
1111
data: {
1212
'target' : card_data.target,
1313
'targetDB' : card_data.targetDB,

NetExplorer/static/js/netexplorer-addnode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function addNode(symbol, database, type, cyobj) {
3636
// neighbours as a JSON object.
3737
$.ajax({
3838
type: "GET",
39-
url: "/net_explorer",
39+
url: window.ROOT + "/net_explorer",
4040
cache: true,
4141
data: {
4242
'genesymbol': symbol,

NetExplorer/static/js/netexplorer-showconnections.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $("#show_connections").on("click", function(){
2222

2323
$.ajax({
2424
type: "POST",
25-
url: "/show_connections",
25+
url: window.ROOT + "/show_connections",
2626
cache: true,
2727
data: {
2828
'nodes': elements.node_ids,

NetExplorer/static/js/planexp.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var PlanExp = (function() {
2323

2424
$.ajax({
2525
type: "GET",
26-
url: "/experiment_summary",
26+
url: window.ROOT + "/experiment_summary",
2727
data: {
2828
'experiment' : expName,
2929
'csrfmiddlewaretoken': '{{ csrf_token }}'
@@ -70,7 +70,7 @@ var PlanExp = (function() {
7070

7171
$.ajax({
7272
type: "GET",
73-
url: "/experiment_conditions",
73+
url: window.ROOT + "/experiment_conditions",
7474
data: {
7575
'experiment' : expName,
7676
'csrfmiddlewaretoken': '{{ csrf_token }}'
@@ -117,7 +117,7 @@ var PlanExp = (function() {
117117

118118
$.ajax({
119119
type: "GET",
120-
url: "/experiment_condition_types",
120+
url: window.ROOT + "/experiment_condition_types",
121121
data: {
122122
'experiment' : expName,
123123
'csrfmiddlewaretoken': '{{ csrf_token }}'
@@ -166,7 +166,7 @@ var PlanExp = (function() {
166166

167167
$.ajax({
168168
type: "GET",
169-
url: "/experiment_dataset",
169+
url: window.ROOT + "/experiment_dataset",
170170
data: {
171171
'experiment': expName,
172172
'csrfmiddlewaretoken': '{{ csrf_token }}'
@@ -200,7 +200,7 @@ var PlanExp = (function() {
200200

201201
$.ajax({
202202
type: "GET",
203-
url: "/experiment_dge_table",
203+
url: window.ROOT + "/experiment_dge_table",
204204
data: {
205205
'experiment': expName,
206206
'dataset' : dataset,
@@ -241,7 +241,7 @@ var PlanExp = (function() {
241241
$("#" + plotDivId).html("");
242242
$.ajax({
243243
type: "GET",
244-
url: "/plot_gene_expression",
244+
url: window.ROOT + "/plot_gene_expression",
245245
data: {
246246
'experiment': expName,
247247
'dataset' : dataset,
@@ -266,7 +266,7 @@ var PlanExp = (function() {
266266
$("#" + plotDivId).html("");
267267
$.ajax({
268268
type: "GET",
269-
url: "/plot_tsne",
269+
url: window.ROOT + "/plot_tsne",
270270
data: {
271271
'experiment': expName,
272272
'dataset' : dataset,

NetExplorer/static/js/root.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.ROOT = "";

NetExplorer/static/js/select-expression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ $("#map-expression-btn-submit").on("click", function(){
137137
} else {
138138
$.ajax({
139139
type: "GET",
140-
url: "/map_expression",
140+
url: window.ROOT + "/map_expression",
141141
cache: true,
142142
data: {
143143
'experiment' : $("#select-expression").val(),

NetExplorer/templates/NetExplorer/404.html

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ <h2>Go back to <a href="/PlanNET">PlanNET</a></h2>
1414
</div>
1515
</div>
1616
</body>
17+
18+
<script src="{% static 'js/root.js' %}"></script>

NetExplorer/templates/NetExplorer/500.html

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ <h2>Go back to <a href="/PlanNET">PlanNET</a></h2>
1414
</div>
1515
</div>
1616
</body>
17+
18+
19+
<script src="{% static 'js/root.js' %}"></script>

NetExplorer/templates/NetExplorer/about.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ <h3>v1.1: August 7th 2018</h3>
6363
<li>PlanNET now holds 729,043 Schmidtea mediterranea interactions (up from 510,996).</li>
6464
<li>The Smed454 dataset and Newmark dataset were temporarily removed because of disk size limitations. These will be uploaded in due time.</li>
6565
<li>A manually curated list of identifiers for planarian transcripts was uploaded to PlanNET. Now users can search for these identifiers, which follow the form: "Smed_XXX". If a particular transcripts has a manually curated identifier, the identifier will appear in pink both in Gene Search and in the corresponding Gene Card.</li>
66-
<li>New Data Downloader allows users to download sequences and sequence annotations in bulk. Available at <a href="{% url downloads %}" title="Downloads">downloads page</a>.</li>
66+
<li>New Data Downloader allows users to download sequences and sequence annotations in bulk. Available at <a href="{% url 'downloads' %}" title="Downloads">downloads page</a>.</li>
6767
<li>Many quality of life improvements to the overall design of the website, including a search bar in NetExplorer.</li>
6868
</ul>
6969

NetExplorer/templates/NetExplorer/base.html

+14-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div id="logo-container">
2727
<div class="row row-eq-height">
2828
<div class="col-sm-8">
29-
<a href="{% url index_view %}"> <img id="logoheader" src="{% static 'Images/logo-new-version2.png' %}"/> </a>
29+
<a href="{% url 'index_view' %}"> <img id="logoheader" src="{% static 'Images/logo-new-version2.png' %}"/> </a>
3030
</div>
3131
<div class="col-sm-4 company-logo-container-parent">
3232
<div class="company-logo-container">
@@ -40,29 +40,29 @@
4040
<nav class="navbar navbar-plannet">
4141
<div class="container-fluid">
4242
<ul class="nav navbar-nav">
43-
<li id="navbar-home"><a href="{% url index_view %}">Home</a></li>
44-
<li id="navbar-tutorial"><a href="{% url tutorial %}">Tutorial</a></li>
43+
<li id="navbar-home"><a href="{% url 'index_view' %}">Home</a></li>
44+
<li id="navbar-tutorial"><a href="{% url 'tutorial' %}">Tutorial</a></li>
4545
<li class="dropdown">
4646
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Tools
4747
<span class="caret"></span>
4848
</a>
4949
<ul class="dropdown-menu">
50-
<li><a href="{% url gene_search %}">Gene Search</a></li>
51-
<li><a href="{% url blast %}">Blast</a></li>
52-
<li><a href="{% url net_explorer %}">Net Explorer</a></li>
53-
<li><a href="{% url path_finder %}">Pathway Finder</a></li>
50+
<li><a href="{% url 'gene_search' %}">Gene Search</a></li>
51+
<li><a href="{% url 'blast' %}">Blast</a></li>
52+
<li><a href="{% url 'net_explorer' %}">Net Explorer</a></li>
53+
<li><a href="{% url 'path_finder' %}">Pathway Finder</a></li>
5454
</ul>
5555
</li>
56-
<li id="navbar-datasets"><a href="{% url datasets %}">Datasets</a></li>
57-
<li id="navbar-downloads"><a href="{% url downloads %}">Downloads</a></li>
58-
<li id="navbar-about"><a href="{% url about %}">About</a></li>
56+
<li id="navbar-datasets"><a href="{% url 'datasets' %}">Datasets</a></li>
57+
<li id="navbar-downloads"><a href="{% url 'downloads' %}">Downloads</a></li>
58+
<li id="navbar-about"><a href="{% url 'about' %}">About</a></li>
5959
</ul>
6060
<ul class="nav navbar-nav navbar-right">
6161
{% if user.is_authenticated %}
62-
<li id="navbar-login"><a href="{% url account %}"><span class="glyphicon glyphicon-user"></span> {{ user.username }}</a></li>
63-
<li id="navbar-logout"><a href="{% url logout %}"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li>
62+
<li id="navbar-login"><a href="{% url 'account' %}"><span class="glyphicon glyphicon-user"></span> {{ user.username }}</a></li>
63+
<li id="navbar-logout"><a href="{% url 'logout' %}"><span class="glyphicon glyphicon-log-out"></span> Log out</a></li>
6464
{% else %}
65-
<li id="navbar-login"><a href="{% url login %}"><span class="glyphicon glyphicon-user"></span> Login</a></li>
65+
<li id="navbar-login"><a href="{% url 'login' %}"><span class="glyphicon glyphicon-user"></span> Login</a></li>
6666
{% endif %}
6767
</div>
6868
</nav>
@@ -109,6 +109,7 @@
109109

110110
</div>
111111

112+
<script src="{% static 'js/root.js' %}"></script>
112113
<script src="{% static 'js/jquery-min.js' %}"></script>
113114
<script src="{% static 'js/jquery-data-tables-min.js' %}"></script>
114115
<script src="{% static 'js/bootstrap-min.js' %}"></script>

NetExplorer/templates/NetExplorer/blast.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1>BLAST</h1>
3737

3838
<div class="panel-body">
3939

40-
<form id="blast_form" method="post" enctype="multipart/form-data" action="{% url blast %}">
40+
<form id="blast_form" method="post" enctype="multipart/form-data" action="{% url 'blast' %}">
4141
{% csrf_token %}
4242

4343
<h2>Query</h2>
@@ -55,7 +55,7 @@ <h2>Database</h2>
5555
<select id="database-selection" name="database" class="selectpicker" title="Select Database">
5656
<option value="Human">Human</option>
5757
{% for db in databases %}
58-
<option value="{{ db }}">{{ db }}</option>
58+
<option value="{{ db.name }}">{{ db.name }}</option>
5959
{% endfor %}
6060
</select>
6161
<br><br>

NetExplorer/templates/NetExplorer/datasets.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h3><span class="overlay plot-title">Sequence Length</span></h3>
3232
<div class="panel panel-default panel-transcriptome">
3333
<div class="panel-heading">
3434
<a class="about-title" name="{{ db.name }}">
35-
<h4><img class='legend-db' src="{% static 'Images/legend-' %}{{ db.name }}.png"/>{{ db }}</h4>
35+
<h4><img class='legend-db' src="{% static 'Images/legend-' %}{{ db.name }}.png"/>{{ db.name }}</h4>
3636
</a>
3737
</div>
3838
<div class="panel-body transcriptome-panel">

NetExplorer/templates/NetExplorer/downloads.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<h2>Data downloader</h2>
1111
<p>Download PlanNET sequences and annotations in bulk</p>
1212

13-
<form id="download-seqs" method="POST" action="{% url downloader %}">
13+
<form id="download-seqs" method="POST" action="{% url 'downloader' %}">
1414
{% csrf_token %}
1515
<label for="comment">Identifiers (separated by commas):</label>
1616
<textarea class="form-control idtextarea" name="identifiers" cols="5" rows="5" id="identifiers"></textarea>
1717
<br>
1818
<select id="download-data" name="database" class="selectpicker" title="Database">
1919
{% for db in databases %}
20-
<option value="{{ db }}">{{ db }}</option>
20+
<option value="{{ db.name }}">{{ db.name }}</option>
2121
{% endfor %}
2222
</select>
2323
<br>

NetExplorer/templates/NetExplorer/experiment_dge_table.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<a class="card-trigger"
2020
title="Click to view info card"
2121
target="{{ exp.gene_symbol }}"
22-
targetDB="{{ database }}">
22+
targetDB="{{ database.name }}">
2323
{{ exp.gene_symbol }}
2424
</a>
2525
</td>
@@ -34,6 +34,7 @@
3434

3535
</table>
3636

37+
<script src="{% static 'js/root.js' %}"></script>
3738
<script>
3839
$(document).ready(function(){
3940
$("#dge-table").DataTable({"order": [[ 3, "desc" ]]});

NetExplorer/templates/NetExplorer/experiment_summary.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2 id="planexp-title">Summary - {{ experiment.name }}</h2>
1010
{% else %}
1111
<img id="Single-Cell" src="{% static 'Images/sc_type.png' %}">
1212
{% endif %}
13-
{{ experiment.exp_type }}
13+
{{ experiment.exp_type.exp_type }}
1414
</span>
1515
</div>
1616
<div class="col-sm-12"><br></div>
@@ -38,4 +38,6 @@ <h4>Conditions:</h4>
3838
<!-- Conditions here -->
3939
</div>
4040
</div>
41-
</div>
41+
</div>
42+
43+
<script src="{% static 'js/root.js' %}"></script>

NetExplorer/templates/NetExplorer/gene_card.html

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<div class="card-subtitle">
1818
<h3>
19-
<a target="_blank" title="Information about the dataset" href="{% url datasets %}#{{ node.database }}">
19+
<a target="_blank" title="Information about the dataset" href="{% url 'datasets' %}#{{ node.database }}">
2020
<img class='legend-db' src="{% static 'Images/' %}legend-{{ node.database }}.png"/>
2121
{{ node.database }}
2222
</a>
@@ -116,7 +116,7 @@ <h2><span class="glyphicon glyphicon-tag"></span> Sequence information</h2>
116116
<hr class="h2-sep">
117117

118118
<h3>Read sequence:</h3>
119-
<a href="{% url get_fasta %}?genesymbol={{ node.symbol|urlencode }}&database={{ node.database }}&type=sequence">
119+
<a href="{% url 'get_fasta' %}?genesymbol={{ node.symbol|urlencode }}&database={{ node.database }}&type=sequence">
120120
<div class="download-fasta-wrapper" title="Download FASTA file">
121121
<img class="download-fasta" src="{% static 'Images/download-icon.png' %}">
122122
Download FASTA
@@ -128,7 +128,7 @@ <h3>Read sequence:</h3>
128128
</div>
129129

130130
<h3>Longest Orf sequence:</h3>
131-
<a href="{% url get_fasta %}?genesymbol={{ node.symbol|urlencode }}&database={{ node.database }}&type=orf">
131+
<a href="{% url 'get_fasta' %}?genesymbol={{ node.symbol|urlencode }}&database={{ node.database }}&type=orf">
132132
<div class="download-fasta-wrapper" title="Download FASTA file">
133133
<img class="download-fasta" src="{% static 'Images/download-icon.png' %}">
134134
Download FASTA
@@ -262,7 +262,7 @@ <h2><span class="glyphicon glyphicon-tag"></span> Interactions</h2>
262262
</div>
263263
<div class="col-sm-2">
264264
<a href="#" class="view-on-netexplorer" data-toggle="tooltip" data-placement="top" title="View on NetExplorer">
265-
<form class="view-on-netexplorer" method="POST" action="{% url net_explorer %}" target="_blank"> {% csrf_token %}
265+
<form class="view-on-netexplorer" method="POST" action="{% url 'net_explorer' %}" target="_blank"> {% csrf_token %}
266266
<input type="hidden" name="json_text" value='{{ json_graph|safe }}' />
267267
<button id="netexplorer-mini" class="btn btn-default netexplorer-view view-on-netexplorer-btn" type="submit">
268268
<img src="{% static 'Images/netexplorer-mini.png' %}" class="netexplorer-mini"/>
@@ -324,6 +324,7 @@ <h3>No interactions</h3>
324324
{% endif %} <!-- If Human or PredictedNode -->
325325
</body>
326326

327+
<script src="{% static 'js/root.js' %}"></script>
327328
<script src="{% static 'js/jquery-data-tables-min.js' %}"></script>
328329
<script>
329330
$('.card-link').click(function() {
@@ -335,14 +336,14 @@ <h3>No interactions</h3>
335336
targetDB : $(this).attr("targetDB"),
336337
csrfmiddlewaretoken: '{{ csrf_token }}'
337338
}
338-
var new_url = '{% url index_view %}gene_card/' + card_data.targetDB + "/" + card_data.target;
339+
var new_url = '{% url 'index_view' %}gene_card/' + card_data.targetDB + "/" + card_data.target;
339340
history.pushState(card_data, null, new_url);
340341

341342
// Load Get request html on current card-overlay
342343
$.ajax({
343344
type: "GET",
344345
context: this, //this makes the this variable visible inside the success
345-
url: "{% url get_card %}",
346+
url: "{% url 'get_card' %}",
346347
cache: true,
347348
data: {
348349
'target' : card_data['target'],
@@ -372,7 +373,7 @@ <h3>No interactions</h3>
372373
$.ajax({
373374
type: "GET",
374375
context: this, //this makes the this variable visible inside the success
375-
url: "{% url get_card %}",
376+
url: "{% url 'get_card' %}",
376377
cache: true,
377378
data: {
378379
'target' : event.state['target'],

0 commit comments

Comments
 (0)