chahatupreti

many conditions, print something for all

May 15th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.15 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Jun 22 16:42:45 2016
  4. @author: Krishna
  5. """
  6. import re
  7. def cl(s1, gmk1, gs1, data1): # output will be the confidence level
  8.  
  9.     for i in range(0,len(beg_gmk_up)):
  10.         if re.search(r'(^!Series_.*?\s"%s\s)' %beg_gmk_up[i], s1, re.I|re.S):   # manipulation - UP
  11.             k=k*0.63
  12.             vv=1
  13.             d= 1
  14. #            print ('gmks start7')
  15.     for i in range(0,len(beg_gmk_down)):
  16.         if re.search(r'(^!Series_.*?\s"%s\s)' %beg_gmk_down[i], s1, re.I|re.S):   # manipulation - DOWN
  17.             k=k*1.99
  18.             vv=1
  19.             d= -1
  20. #            print ('gmks start7')
  21.     for i in range(0,len(beg_other)):
  22.         if re.search(r'(^!Series_.*?\s"%s\s)' %beg_other[i], s1, re.I|re.S):  # line starts with a golden PHRASE - no manipulation info
  23.             k=k*3.71
  24.             vv=1
  25. #            print ('line start7')
  26.     if re.search(r'(^!Series_\w.*?\s"Keywords:)', s1, re.I):  # line starts with KEYWORDS - manipulation dependent on the gmk linked
  27.         ll=s1.split(',')
  28.         v=0
  29. #        print (321321)
  30.         for i in range(0,len(ll)):
  31.            if gmk1 and gs1 in ll[i]:
  32.                v=4
  33.                k=k*4.43
  34. #               print (123123123)
  35. #               print (k)
  36.                vv=1
  37.                if gmk1 in ['loss of', 'deficient', 'knockout', 'haploinsufficiency', 'haploin-sufficiency', 'inactivation', 'knock-out', 'deletion', 'inhibition', 'silencing', '-/-', 'null', 'KO', 'knockdown', 'ko', 'lacking', 'mutant']:
  38.                    d=-1
  39. #                   print ('keyword start7_1')
  40.                if gmk1 in ['treated', 'exposure', 'activation', 'induced', 'expressing', 'overexpression', 'overexpressing', 'stimulated', 'stimulation', 'over-activation', '+', 'treatment']:
  41.                    d=1
  42. #                   print ('keyword start7_2')
  43.         if v!=4:        # THINK OF REMOVING THIS RULE
  44.            k=k*1.83
  45. #           print ('no keywords')
  46.            vv=1
  47.  
  48.            print ('opposite of keyword start7')
  49.     if re.search(r'(%s\(control\))' %gs1, s1, re.I|re.S): #gs1(control) - no manipulation info
  50. #        print ('control rule')        ###############################
  51.         None
  52.     if re.search(r'(The object of this study was to identify genes transcriptionally upregulated.*?downregulated)', s1):
  53.         None
  54. #        print ('golden line rule')
  55.     if re.search(r'(The object of this study was to identify genes transcriptionally upregulated)', s1):
  56. #        print ('golden line rule')
  57.         d=1
  58.     if re.search(r'(The object of this study was to identify genes transcriptionally downregulated)', s1):
  59. #        print ('golden line rule')
  60.         d=-1
  61.     for ii in range(0,len(data1)):
  62.  
  63.         if (re.search(r'(%s.*?\..*?%s)' % (re.escape(gs1), re.escape(gmk1)), br0, re.I|re.S)) or (re.search(r'(%s.*?\..*?%s)' % (re.escape(gmk1), re.escape(gs1)), br0, re.I|re.S)): #gs1 fullstop gmk1 and viceversa - no manipulation info
  64.             k=k*0.87
  65. #            print ('--fullstop')
  66.         if gmk1 == 'activation':
  67.             if  re.search(r'(activation by %s)' %gs1, br0, re.I|re.S): # this was meant to be a negative rule
  68.                 k=k*0.21
  69.                 vv=1
  70.                 d=1
  71. #                print ('activation one') ##########################
  72.             if  re.search(r'(probably.*?%s activation)' %gs1, br, re.I|re.S|re.DOTALL):
  73.                 k=k*1
  74.                 vv=1
  75.                 d=1
  76. #                print ('activation two') ##############################
  77.             if  re.search(r'(critical for.*?%s activation)' %gs1, br, re.I|re.S):
  78.                 k=k*0.1
  79.                 vv=1
  80.                 d=1
  81. #                print ('activation three') ################################
  82.             if  re.search(r'(%s.*?activation of)' %gs1, br3, re.I|re.S):
  83.                 k=k*0.73
  84.                 vv=1
  85.                 d=1
  86. #                print ('activation four') ################################
  87.         if gmk1 == 'deficient':
  88.             if  re.search(r'(%s deficient)' %gs1, br0, re.I|re.S): # modification is DOWN
  89.                 k=k*3.45
  90.                 vv=1
  91.                 d=-1
  92. #                print ('deficient one')
  93.             if  re.search(r'(deficient.+?exhibited.+?%s)' %gs1, br0, re.I|re.S|re.DOTALL):
  94.                 k=k*0.1
  95.                 vv=1
  96.                 d=-1
  97. #                print ('deficient two') ###########################
  98.  
  99.         if gmk1 == '-/-':
  100.             if  re.search(r'(-/-%s)' %gs1, br0, re.I|re.S): #
  101. #                print ('minus one rule')  ###########################
  102.                 d=-1
  103.             if  re.search(r'(%s-/-)' %gs1, br0, re.I|re.S):
  104.                 k=k*2.78
  105.                 vv=1
  106.                 d=-1
  107. #                print ('minus two')
  108.         if gmk1 == '+':
  109.             if  re.search(r'(%s+)' %gs1, br0, re.I|re.S):
  110. #                print ('plus one rule')
  111.                 d=1
  112.             if  re.search(r'(%s\(\+\))' %gs1, br3, re.I|re.S):
  113.                 k=k*0.1
  114.                 vv=1
  115.                 d=1
  116. #                print ('plus two')
  117.             else:
  118. #                print ('plus last option')
  119. #                None
  120.         if gmk1 == 'induced':
  121.             if  re.search(r'(%s.*?was shown.+?induced)' %gs1, br0, re.I|re.S|re.DOTALL):
  122.                 k=k*0.1
  123.                 vv=1
  124.                 d=1
  125. #                print ('induced one') ###########################
  126.             if  re.search(r'(%s.*?-induced)' %gs1, br0, re.I|re.S):
  127. #                print ('induced two rule') ###########################
  128.                 d=1
  129.             if  re.search(r'(induced.*?to %s)' %gs1, br0, re.I|re.S):
  130.                 k=k*0.41
  131.                 vv=1
  132.                 d=1
  133. #                print ('induced three') ###########################
  134.             if  re.search(r'(induced.*?while %s)' %gs1, br0, re.I|re.S):
  135.                 k=k*0.1
  136.                 vv=1
  137. #                print ('induced four') ###########################
  138.         if gmk1 == 'inhibition':
  139.             if  re.search(r'(hypothesized\s.*?\sinhibition\s.*?\s%s )' %gs1, br, re.I|re.S):
  140. #                print ('inhibition one rule') ###########################
  141.                 d=-1
Add Comment
Please, Sign In to add comment