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
<?xml version="1.0" encoding="UTF-8" ?> | |
<!DOCTYPE html> | |
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'> | |
<head> | |
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/> | |
<b:if cond='data:blog.isMobile'> | |
<meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/> | |
<b:else/> | |
<meta content='width=1100' name='viewport'/> | |
</b:if> |
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
elif environ['PATH_INFO'].find('/static') != -1: | |
#ctype = environ['HTTP_ACCEPT'].split(',')[0] | |
protoctype=environ['PATH_INFO'].split('.')[-1] | |
if protoctype =='css': | |
ctype='text/css' | |
response_body = open('wsgi'+environ['PATH_INFO'],encoding='utf-8').read().encode('utf-8') | |
elif protoctype =='js': | |
ctype='text/javascript' | |
response_body = open('wsgi'+environ['PATH_INFO'],encoding='utf-8').read().encode('utf-8') | |
elif protoctype =='ico': |
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 IS PUBLICALLY RELEASED TO DEMONSTRATE A POINT NOT AS A USABLE PIECE OF CODE, HENCE THE LACK OF ANNOTATION. | |
__doc__ = ''' | |
I have peptide sequences, I need the DNA. plan: | |
Option A: | |
* find gi code | |
* look for gi code in the gbk file. | |
Option B: | |
* tblastn online | |
* download genome sequence | |
* extract sequence from nucleotide |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
#Written for python 3, not tested under 2. | |
""" | |
Finds all gene symbols (`get_all_genes()` method) and find the genes in common with the word list. | |
""" | |
__author__ = "Matteo Ferla. [Github](https://github.com/matteoferla)" | |
__email__ = "matteo.ferla@gmail.com" | |
__date__ = "10/05/16" |
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
def zoospotter(zoo,fn='pubmed_scored.csv', assoclist=['infection']): | |
""" | |
Method that downloads the number of Pubmed entries associataed with a given species listed in the zoo variable. | |
The variable assoclist has the fields sought. | |
:param zoo: list of species names | |
:param fn: file name to save. | |
:param assoclist: list of terms that one wishes to see the association. E.g. 'infection' to find pathogenicity. | |
:return: None. | |
""" | |
#debugprint=print |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
__description__ = \ | |
""" | |
A script to check if the IP address is running. | |
Use it add your settings to the fields below. | |
Once you are sure you have all the right keys and it works, install an hour cron job thusly: | |
$sudo nano crontab -e | |
0 * * * * python3 ~/Coding/IP_check/IP_check.py >> ~/Coding/IP_check/log.txt |
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
#python 3 | |
# three methods, two to float-up the path to a key or value and one that given a convoluted nested dictionary and a tuple of keys/indices returns the value. | |
# float_key(dictionary,key) | |
# float_value(dictionary,key) | |
# get_value(dictionary,(keys/indices list)) | |
# great for entrez, Uniprot, PDB XML dictionaries | |
# NB. works for dict and list like objects | |
import collections |
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
def deep_clean(element, damn): # the values have the annoying {http} field this removes them. | |
try: | |
if isinstance(element, dict): | |
return {k.replace(damn, '').replace('@', '').replace('#', ''): deep_clean(element[k], damn) for k in | |
element} | |
elif isinstance(element, list): | |
return [deep_clean(e, damn) for e in element] | |
elif isinstance(element, str): | |
if re.fullmatch('\d*', element): | |
return int(element) |
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
# "pseudo"-bound decorator within a class, with the class attribute boolean `prevent_error`. | |
# it does not inherit self and is not a classmethod or a static method. But will behave like one. | |
# it is a generator function, whose inner function is a normal bound | |
# Do note the print requires customisation, i.e. `self.descriptive_attribute`. | |
def failsafe(func): | |
def wrapper(self, *args, **kargs): | |
# the call happned after chekcing if it should croak on error so to make the traceback cleaner. | |
if self.prevent_error: | |
try: | |
return func(self, *args, **kargs) |
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
__description__ = """ | |
This is a collection of methods that helps handle better the ET.Element instances from Uniprot XML files. | |
They are monkeypatched to the class object itself. | |
The Element can be monkeypached by importing xmlschema, as opposed to using the __builtin__ workaround. | |
Basically, I am piggybacking my monkeypatch on it, meaning that I don't need to copypaste from SO. | |
* `ET.Element.ns_strip()` #returns the tag with the {namespace} | |
* `ET.Element.is_tag(value)` # boolean fx to check if tag == value | |
* `ET.Element.describe()` # prints the content of the elemtn for debugging, similarly to dump but better. | |
* `ET.Element.is_human()` # boolean fx to check if human or dancer |
OlderNewer