comparison cmpb2016/exclus_clono_VCDR3.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 16:57:12 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 exclusiveVclonoFunc(inputs,thres):
17
18 vClono=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 vClono = 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 vClono = vClono.merge(cl[['V-GENE','AA JUNCTION','ReadsB']], how='left', on=['V-GENE','AA JUNCTION'])
34
35 vClono['ReadsB'].fillna(0, inplace=True)
36
37 vClono = vClono[vClono['ReadsB'] == 0]
38 del vClono['ReadsB']
39
40 vClono.index = range(1,len(vClono)+1)
41
42 return vClono
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 = exclusiveVclonoFunc(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))