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
d = {} | |
with open('myfile.ext','rU') as f: | |
for line in f: | |
linesplit = line.split('\t') | |
try: | |
d[linesplit[fasta_pos]].append( [x for x in linesplit[other_positions] ) #list comprehension | |
except KeyError: | |
d[linesplit[fasta_pos]] = [] | |
d[linesplit[fasta_pos]].append( [x for x in linesplit[other_positions] ) |
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
from collections import Counter | |
# construct counter to count the number of occurances of each fasta | |
cnt = Counter() | |
with inputfile as f: | |
for line in f: | |
linesplit = line.split('\t') | |
cnt[linesplit[fasta_pos]] += 1 #establish counter, count occurrances of each fasta file | |
with inputfile as f: |
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
for key in d.keys(): | |
acc = '' | |
gi = 0 | |
taxonfaa=None | |
homolo = None | |
for sublst in d[key]: | |
if 'NP' in sublst[3]: | |
if sublst[2] > gi: | |
acc = sublst[3] | |
gi = sublst[2] |
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 func_ex(p_arg, *args, preset_guy = 'billy', **kwargs): | |
''' | |
Example function on how to pass required positional, optional positional, | |
keyword arguments, and optional keyword arguments | |
''' | |
print('positional argument value is : {}'.format(p_arg)) | |
for arg in args: | |
print('Another arg is here boys : \n{}'.format(arg)) | |
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
#check if files in directory aren't in log of previously encountered log | |
from time import sleep | |
def filechecker(): | |
print '{} : Checking for new files...'.format(time.ctime()) | |
try : log = open('filelog.log','r+U') #open log file in append mode | |
except : log = open('filelog.log','ab+') # if it doesn't exist, create it | |
files = [line.strip('\n') for line in log.readlines()] # list of all files in log | |
for f in os.listdir(inputdir): # iterate through all files in directory |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
%http://tex.stackexchange.com/questions/77920/comment-package-excludecomment-gives-error | |
\documentclass[12pt]{article} | |
\usepackage{todonotes} % \missingfigure | |
\usepackage{comment} % to exclude whole sections when I want to | |
\newif\ifshow % toggle true or false based on if want to hide section | |
%\showtrue % show the sections | |
\showfalse % hide the sections | |
\ifshow |
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
from functools import wraps | |
def make_iterable(argn=0, exceptions=[]): | |
"""Check to make sure an argument is an iterator. | |
Default argument is args[0] | |
Add exceptions that you wish to enclose in an iterator by providing an | |
iterator of their type. | |
Ironically, exceptions must be encapsulated in an iterator""" | |
def decorate(func): | |
@wraps(func) |
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
""" | |
Simple script to separate MaxQuant experiments | |
""" | |
import os | |
import sys | |
import numpy as np | |
import pandas as pd | |
def main(f): | |
df = pd.read_table(f) |