-
Notifications
You must be signed in to change notification settings - Fork 5
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
3aaeafa
commit c4ef334
Showing
8 changed files
with
218 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"keys": ["ctrl+shift+r"], | ||
"command": "reverse_complement" | ||
} | ||
] |
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 @@ | ||
[ | ||
{ | ||
"keys": ["super+shift+r"], | ||
"command": "reverse_complement" | ||
} | ||
] |
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 @@ | ||
[ | ||
{ | ||
"keys": ["ctrl+shift+r"], | ||
"command": "reverse_complement" | ||
} | ||
] |
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,16 @@ | ||
[ | ||
{ | ||
"id": "edit", | ||
"children": [ | ||
{ | ||
"caption": "Nucleotides", | ||
"id": "nucleotides", | ||
"children": [ | ||
{ | ||
"command": "reverse_complement" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
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,23 @@ | ||
ACTG for SublimeText | ||
==================== | ||
|
||
Nucleotide syntax highlighting and reverse complement support. This is handy for "stare at the screen and squint" DNA analysis. | ||
|
||
Features | ||
-------- | ||
|
||
* Choose 'Nucleotides' syntax highlighting to colorize ACTG and N. | ||
* Automatically associates .fa, .fasta, .fq, .fastq, .sam, and .vcf files. | ||
* Make a selection and hit Control-Shift-R (or Command-Shift-R on Mac) to replace it with the reverse complement. | ||
|
||
Bugs | ||
---- | ||
|
||
* ACTG and N are simply highlighted in place, which can make for some interestingly colored VCF comments and quality strings. A more clever regex would help, if only I could fathom the tmLanguage backreference match syntax. | ||
|
||
Patches welcome. | ||
|
||
Releases | ||
-------- | ||
|
||
* 0.0.1: Initial release, 2014-09-29 |
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,40 @@ | ||
{ | ||
"name": "Nucleotides", | ||
"scopeName": "source.nucleotides", | ||
"fileTypes": [ | ||
"fq", | ||
"fastq", | ||
"fa", | ||
"fasta", | ||
"sam", | ||
"vcf" | ||
], | ||
"patterns": [ | ||
{ | ||
"match": "A", | ||
"name": "keyword.control.nucleotides", | ||
"comment": "adenine" | ||
}, | ||
{ | ||
"match": "C", | ||
"name": "entity.name.function.nucleotides", | ||
"comment": "cytosine" | ||
}, | ||
{ | ||
"match": "T", | ||
"name": "constant.numeric.source.nucleotides", | ||
"comment": "thymine" | ||
}, | ||
{ | ||
"match": "G", | ||
"name": "string.quoted.source.nucleotides", | ||
"comment": "guanine" | ||
}, | ||
{ | ||
"match": "N", | ||
"name": "comment.block.source.nucleotides", | ||
"comment": "unknown" | ||
} | ||
], | ||
"uuid": "34f308ec-03a9-428e-93dd-d8eae6648d7f" | ||
} |
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,57 @@ | ||
''' | ||
actg.py | ||
Reverse complement plugin for Sublime Text 2 | ||
''' | ||
import sublime, sublime_plugin | ||
|
||
class ReverseComplementCommand(sublime_plugin.TextCommand): | ||
def complement(self, sequence, reverse=False): | ||
""" | ||
Compute the complement of a DNA sequence. | ||
If reverse is True, reverse it too. | ||
""" | ||
flip = { | ||
'A': 'T', | ||
'C': 'G', | ||
'G': 'C', | ||
'T': 'A', | ||
'N': 'N', | ||
'a': 't', | ||
'c': 'g', | ||
'g': 'c', | ||
't': 'a', | ||
'n': 'n' | ||
} | ||
|
||
complines = [] | ||
|
||
# Gracefully handle line endings | ||
if '\n' in sequence: | ||
postfix = '\n' | ||
else: | ||
postfix = '' | ||
|
||
for line in sequence.split('\n'): | ||
line_complement = [] | ||
for i in list(line): | ||
if not i in flip: | ||
sublime.error_message('Selection contains non-nucleotides.') | ||
return False | ||
line_complement.append(flip[i]) | ||
|
||
if reverse: | ||
complines.append(''.join(line_complement[::-1])) | ||
else: | ||
complines.append(''.join(line_complement)) | ||
|
||
return postfix.join(complines) | ||
|
||
def run(self, edit): | ||
sels = self.view.sel() | ||
for sel in sels: | ||
if not sel.empty(): | ||
ret = self.complement(self.view.substr(sel), reverse=True) | ||
if(ret): | ||
self.view.replace(edit, sel, ret) |
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,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>fileTypes</key> | ||
<array> | ||
<string>fq</string> | ||
<string>fastq</string> | ||
<string>fa</string> | ||
<string>fasta</string> | ||
<string>sam</string> | ||
<string>vcf</string> | ||
</array> | ||
<key>name</key> | ||
<string>Nucleotides</string> | ||
<key>patterns</key> | ||
<array> | ||
<dict> | ||
<key>comment</key> | ||
<string>adenine</string> | ||
<key>match</key> | ||
<string>A</string> | ||
<key>name</key> | ||
<string>keyword.control.nucleotides</string> | ||
</dict> | ||
<dict> | ||
<key>comment</key> | ||
<string>cytosine</string> | ||
<key>match</key> | ||
<string>C</string> | ||
<key>name</key> | ||
<string>entity.name.function.nucleotides</string> | ||
</dict> | ||
<dict> | ||
<key>comment</key> | ||
<string>thymine</string> | ||
<key>match</key> | ||
<string>T</string> | ||
<key>name</key> | ||
<string>constant.numeric.source.nucleotides</string> | ||
</dict> | ||
<dict> | ||
<key>comment</key> | ||
<string>guanine</string> | ||
<key>match</key> | ||
<string>G</string> | ||
<key>name</key> | ||
<string>string.quoted.source.nucleotides</string> | ||
</dict> | ||
<dict> | ||
<key>comment</key> | ||
<string>unknown</string> | ||
<key>match</key> | ||
<string>N</string> | ||
<key>name</key> | ||
<string>comment.block.source.nucleotides</string> | ||
</dict> | ||
</array> | ||
<key>scopeName</key> | ||
<string>source.nucleotides</string> | ||
<key>uuid</key> | ||
<string>34f308ec-03a9-428e-93dd-d8eae6648d7f</string> | ||
</dict> | ||
</plist> |