forked from pydna-group/pydna
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9496f64
commit 469bc6b
Showing
16 changed files
with
846 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from IPython.display import Javascript" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/javascript": [ | ||
"$.getScript('http://d3js.org/d3.v3.min.js')" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Javascript object>" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"Javascript(\"\"\"$.getScript('http://d3js.org/d3.v3.min.js')\"\"\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/javascript": [ | ||
"\n", | ||
"\n", | ||
"// This unhides the output area\n", | ||
"container.show();\n", | ||
"\n", | ||
"// element is the jQuery element we will append to\n", | ||
"var e = element.get(0);\n", | ||
" \n", | ||
"var diameter = 600,\n", | ||
" format = d3.format(\",d\");\n", | ||
"\n", | ||
"var pack = d3.layout.pack()\n", | ||
" .size([diameter - 4, diameter - 4])\n", | ||
" .value(function(d) { return d.size; });\n", | ||
"\n", | ||
"var svg = d3.select(e).append(\"svg\")\n", | ||
" .attr(\"width\", diameter)\n", | ||
" .attr(\"height\", diameter)\n", | ||
" .append(\"g\")\n", | ||
" .attr(\"transform\", \"translate(2,2)\");\n", | ||
"\n", | ||
"d3.json(\"files/flare.json\", function(error, root) {\n", | ||
" var node = svg.datum(root).selectAll(\".node\")\n", | ||
" .data(pack.nodes)\n", | ||
" .enter().append(\"g\")\n", | ||
" .attr(\"class\", function(d) { return d.children ? \"node\" : \"leaf node\"; })\n", | ||
" .attr(\"transform\", function(d) { return \"translate(\" + d.x + \",\" + d.y + \")\"; });\n", | ||
"\n", | ||
" node.append(\"title\")\n", | ||
" .text(function(d) { return d.name + (d.children ? \"\" : \": \" + format(d.size)); });\n", | ||
"\n", | ||
" node.append(\"circle\")\n", | ||
" .attr(\"r\", function(d) { return d.r; });\n", | ||
"\n", | ||
" node.filter(function(d) { return !d.children; }).append(\"text\")\n", | ||
" .attr(\"dy\", \".3em\")\n", | ||
" .style(\"text-anchor\", \"middle\")\n", | ||
" .text(function(d) { return d.name.substring(0, d.r / 3); });\n", | ||
"});\n", | ||
"\n", | ||
"d3.select(self.frameElement).style(\"height\", diameter + \"px\");\n" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Javascript object>" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"Javascript(\"\"\"\n", | ||
"\n", | ||
"// This unhides the output area\n", | ||
"container.show();\n", | ||
"\n", | ||
"// element is the jQuery element we will append to\n", | ||
"var e = element.get(0);\n", | ||
" \n", | ||
"var diameter = 600,\n", | ||
" format = d3.format(\",d\");\n", | ||
"\n", | ||
"var pack = d3.layout.pack()\n", | ||
" .size([diameter - 4, diameter - 4])\n", | ||
" .value(function(d) { return d.size; });\n", | ||
"\n", | ||
"var svg = d3.select(e).append(\"svg\")\n", | ||
" .attr(\"width\", diameter)\n", | ||
" .attr(\"height\", diameter)\n", | ||
" .append(\"g\")\n", | ||
" .attr(\"transform\", \"translate(2,2)\");\n", | ||
"\n", | ||
"d3.json(\"files/flare.json\", function(error, root) {\n", | ||
" var node = svg.datum(root).selectAll(\".node\")\n", | ||
" .data(pack.nodes)\n", | ||
" .enter().append(\"g\")\n", | ||
" .attr(\"class\", function(d) { return d.children ? \"node\" : \"leaf node\"; })\n", | ||
" .attr(\"transform\", function(d) { return \"translate(\" + d.x + \",\" + d.y + \")\"; });\n", | ||
"\n", | ||
" node.append(\"title\")\n", | ||
" .text(function(d) { return d.name + (d.children ? \"\" : \": \" + format(d.size)); });\n", | ||
"\n", | ||
" node.append(\"circle\")\n", | ||
" .attr(\"r\", function(d) { return d.r; });\n", | ||
"\n", | ||
" node.filter(function(d) { return !d.children; }).append(\"text\")\n", | ||
" .attr(\"dy\", \".3em\")\n", | ||
" .style(\"text-anchor\", \"middle\")\n", | ||
" .text(function(d) { return d.name.substring(0, d.r / 3); });\n", | ||
"});\n", | ||
"\n", | ||
"d3.select(self.frameElement).style(\"height\", diameter + \"px\");\n", | ||
"\"\"\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"HTML(\"\"\"\n", | ||
"<style>\n", | ||
"\n", | ||
"circle {\n", | ||
" fill: rgb(31, 119, 180);\n", | ||
" fill-opacity: .25;\n", | ||
" stroke: rgb(31, 119, 180);\n", | ||
" stroke-width: 1px;\n", | ||
"}\n", | ||
"\n", | ||
".leaf circle {\n", | ||
" fill: #ff7f0e;\n", | ||
" fill-opacity: 1;\n", | ||
"}\n", | ||
"\n", | ||
"text {\n", | ||
" font: 10px sans-serif;\n", | ||
"}\n", | ||
"\n", | ||
"</style>\n", | ||
"\"\"\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"anaconda-cloud": {}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.5.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
6 changes: 6 additions & 0 deletions
6
...Parsers to wrangle the plethora of biological flatfile formats into standard JSON.desktop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Desktop Entry] | ||
Encoding=UTF-8 | ||
Name=Link to levskaya/BioJSON: Parsers to wrangle the plethora of biological flatfile formats into standard JSON | ||
Type=Link | ||
URL=https://github.com/levskaya/BioJSON | ||
Icon=text-html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
################################################################################################ | ||
# __ ____ _______ _ | ||
# | \/ \ \ / / ____| (_) | ||
# _ __ __ _ _ __ ___ ___ | \ / |\ \ /\ / / | __ _ __ _ __ _ _ __ ___ ___ _ __ ___ | ||
# | '_ \ / _` | '__/ __|/ _ \ | |\/| | \ \/ \/ /| | |_ | | '_ \| '__| | '_ ` _ \ / _ \ '__/ __| | ||
# | |_) | (_| | | \__ \ __/ | | | | \ /\ / | |__| | | |_) | | | | | | | | | __/ | \__ \ | ||
# | .__/ \__,_|_| |___/\___| |_| |_| \/ \/ \_____| | .__/|_| |_|_| |_| |_|\___|_| |___/ | ||
# | | | | | ||
# |_| |_| | ||
################################################################################################ | ||
|
||
WIKIDPAD_PLUGIN = (("MenuFunctions",1), ("ToolbarFunctions",1)) | ||
|
||
import mecplugins_ini | ||
|
||
from Bio import SeqIO | ||
from os import linesep | ||
from cStringIO import StringIO | ||
from Bio.Seq import Seq | ||
from Bio.SeqRecord import SeqRecord | ||
from Bio.Alphabet import SingleLetterAlphabet | ||
|
||
def describeMenuItems(wiki): | ||
return ((mwgtofasta,_(u"mecplugins|DNA Sequence Tools|MWG primers to fasta format") + u"\t", _(u"mwgtofasta")),) | ||
|
||
def empty(wiki, evt): | ||
pass | ||
|
||
def describeToolbarItems(wiki): | ||
return () | ||
|
||
def mwgtofasta(wiki, evt): | ||
|
||
from pyparsing import Word, Literal, printables, LineStart, SkipTo, Combine, nums | ||
|
||
raw_string = wiki.getActiveEditor().GetSelectedText() | ||
start, end = wiki.getActiveEditor().GetSelection() | ||
|
||
fastaheader = Combine(Literal('>').suppress()+Word(nums).setResultsName("number")+\ | ||
Literal('_').suppress()) | ||
try: | ||
data, dataStart, dataEnd = fastaheader.scanString(raw_string).next() | ||
except StopIteration: | ||
number = 1 | ||
dataStart = end - start | ||
else: | ||
number = int(data.number)+1 | ||
|
||
wiki.getActiveEditor().SetSelectionByCharPos(start,start+dataStart) | ||
|
||
name = Word(printables).setResultsName("name") | ||
seq_start = Literal("5'").suppress() | ||
seq_stop = Literal("3'").suppress() | ||
sequence = Combine(seq_start + SkipTo(seq_stop)).setResultsName("seq") | ||
mwg_primer = LineStart() + name + SkipTo(LineStart()) + sequence | ||
|
||
result = mwg_primer.scanString(raw_string) | ||
|
||
seqlist = [data for data,dataStart,dataEnd in result] | ||
|
||
number+=len(seqlist) | ||
|
||
fasta_string = '' | ||
|
||
for data in seqlist: | ||
number-=1 | ||
s=data.seq.strip("-").replace("\n","").replace(" ","") | ||
fasta_string+=">{number}_{name} ({length}-mer)\n{seq}\n\n".format(number=number,name=data.name,length=len(s),seq=s) | ||
|
||
wiki.getActiveEditor().ReplaceSelection(fasta_string) | ||
wiki.getActiveEditor().SetSelectionByCharPos(start, start+len(fasta_string)) | ||
|
||
|
Oops, something went wrong.