Skip to content

Instantly share code, notes, and snippets.

View edraizen's full-sized avatar

Eli Draizen edraizen

View GitHub Profile
from collections import defaultdict
import requests
from bs4 import beautifulsoup
num_sequences = defaultdict(int)
with open("/Users/edraizen/Dropbox/Membrane-Proteins/data/pfam-uniprot/pfam-polytopic_201601.txt") as pfam_f:
pfam_f.next()
for line in pfam_f:
pfam = line.split()[1]
r = requests.get("http://pfam.xfam.org/family/{}#tabview=tab3".format(pfam))
soup = BeautifulSoup(r.text)
#Standard libraries
import os, sys
import logging
#Requried Libraries
from joblib import Parallel, delayed
try:
#Import libraries to use use cluster
from cluster_helper.cluster import cluster_view
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
from itertools import groupby
from torch.nn.modules.loss import _Loss
class DiceLoss(_Loss):
def __init__(self, size_average=True, smooth=1.):
super(DiceLoss, self).__init__(size_average)
self.smooth = smooth
def forward(self, input, target, locations, weights=None):
if self.size_average:
import torch
import torch.nn as nn
import sparseconvnet as scn
class UNet3D(nn.Module):
"""Sparse 3D Unet for voxel level prediction.
Modified from shiba24/3d-unet and ellisdg/3DUnetCNN
Parameters
import torch.nn as nn
import sparseconvnet as scn
import torch.nn.functional as F
class Dropout(nn.Module):
def __init__(self, p=0.5, inplace=False):
super(Dropout, self).__init__()
if p < 0 or p > 1:
raise ValueError("dropout probability has to be between 0 and 1, "
"but got {}".format(p))
SELECT
i.mol_sdi_id,
i.nbr_sdi_id,
i.nbr_score,
i.nbr_taxid,
i.nbr_superfam_id,
i.int_superfam_id,
i.nbr_obs_int_id,
i.face_seq as resn,
f.seqloc as resi
import os
import pandas as pd
import dask.dataframe as dd
from dask.multiprocessing import get
num_workers = 20 #or use int(os.environ["SLURM_JOB_CPUS_PER_NODE"])
def apply_row(row):
return pd.Series({
"newColA": row["A"]+row["B"]),
DEBUG:toil.batchSystems.mesos.batchSystem:Preparing to launch Mesos task 0 with 1.00 cores, 2048.00 MiB memory, and 2048.00 MiB disk using offer 5b6aaf7d-99c1-410a-85f3-dc9602313361-O20 ...
DEBUG:toil.batchSystems.mesos.batchSystem:Launched Mesos task 0.
WARNING:toil.batchSystems.mesos.batchSystem:Executor 'toil-28072' reported lost with status '32512'.
WARNING:toil.batchSystems.mesos.batchSystem:Handling failure of executor 'toil-28072' on agent '5b6aaf7d-99c1-410a-85f3-dc9602313361-S2'.
DEBUG:toil.batchSystems.mesos.batchSystem:Available files: dict_keys(['/slave/log', '/var/lib/mesos/slaves/5b6aaf7d-99c1-410a-85f3-dc9602313361-S2/frameworks/5b6aaf7d-99c1-410a-85f3-dc9602313361-0032/executors/toil-27424/runs/f56c948d-a6b4-4ea5-9639-7518518f6ace', '/var/lib/mesos/slaves/5b6aaf7d-99c1-410a-85f3-dc9602313361-S2/frameworks/5b6aaf7d-99c1-410a-85f3-dc9602313361-0033/executors/toil-28072/runs/807e0102-ecc0-406c-b9b8-f60a845ec65f'])
WARNING:toil.batchSystems.mesos.batchSystem:Attempting to retrieve executor error l
import torch
import numpy as np
import sparseconvnet as scn
from more_itertools import pairwise
from torch.nn.parallel._functions import Scatter
class Batch(object):
def __init__(self, indices, data, truth, chunk_sizes=None, dim=3):
assert isinstance(indices, torch.Tensor), "indices must be tensor"
assert isinstance(data, torch.Tensor), "data must be tensor"