|
0
|
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))
|