Mercurial > repos > chmaramis > testirprofiler
comparison cmpb2016/exclus_clono_JCDR3.py @ 0:8be019b173e6 draft
Uploaded included tools
| author | chmaramis |
|---|---|
| date | Sun, 18 Mar 2018 05:54:20 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:8be019b173e6 |
|---|---|
| 1 # -*- coding: utf-8 -*- | |
| 2 """ | |
| 3 Created on Mon Feb 29 17:06:09 2016 | |
| 4 | |
| 5 @author: chmaramis | |
| 6 """ | |
| 7 | |
| 8 from __future__ import division | |
| 9 import numpy as np | |
| 10 from pandas import * | |
| 11 from numpy import nan as NA | |
| 12 import sys | |
| 13 import time | |
| 14 | |
| 15 | |
| 16 def exclusiveJclonoFunc(inputs,thres): | |
| 17 | |
| 18 jClono=DataFrame() | |
| 19 | |
| 20 # File A | |
| 21 cl = DataFrame() | |
| 22 cl = read_csv(inputs[0] , sep = '\t' , index_col = 0) | |
| 23 if (thres != 'null'): | |
| 24 cl = cl[cl['Reads'] > int(thres)] | |
| 25 jClono = cl | |
| 26 | |
| 27 # File B | |
| 28 cl = DataFrame() | |
| 29 cl = read_csv(inputs[2] , sep = '\t' , index_col = 0) | |
| 30 if (thres != 'null'): | |
| 31 cl = cl[cl['Reads'] > int(thres)] | |
| 32 cl.rename(columns={'Reads':'ReadsB'}, inplace=True) | |
| 33 jClono = jClono.merge(cl[['J-GENE','AA JUNCTION','ReadsB']], how='left', on=['J-GENE','AA JUNCTION']) | |
| 34 | |
| 35 jClono['ReadsB'].fillna(0, inplace=True) | |
| 36 | |
| 37 jClono = jClono[jClono['ReadsB'] == 0] | |
| 38 del jClono['ReadsB'] | |
| 39 | |
| 40 jClono.index = range(1,len(jClono)+1) | |
| 41 | |
| 42 return jClono | |
| 43 | |
| 44 | |
| 45 if __name__ == '__main__': | |
| 46 | |
| 47 start=time.time() | |
| 48 | |
| 49 # Parse input arguments | |
| 50 threshold = sys.argv[2] | |
| 51 arg = sys.argv[3:] | |
| 52 output = sys.argv[1] | |
| 53 | |
| 54 # Execute basic function | |
| 55 excl = exclusiveJclonoFunc(arg,threshold) | |
| 56 | |
| 57 # Save output to CSV files | |
| 58 if not excl.empty: | |
| 59 excl.to_csv(output , sep = '\t') | |
| 60 | |
| 61 # Print execution time | |
| 62 stop=time.time() | |
| 63 print('Runtime:' + str(stop-start)) |
