示例#1
0
class prosol:
    """interface of proso predictor"""

    #	initialize evironment

    def __init__(self):
        print("Initializing PROSOII script...")
        self.n = 0

        #	set up the SequenceMaker
        OrigSeq = '''MATKILALLALLALLVSATNAFIIPQCSLAPSASIPQFLPPVTSMGFEHPAVQAYRLQLALAASALQQPIAQLQQQSLAHLTLQTIATQQQQQQFLPSLSHLAVVNPVTYLQQQLLASNPLALANVAAYQQQQQLQQFMPVLSQLAMVNPAVYLQLLSSSPLAVGNAPTYLQQQLLQQIVPALTQLAVANPAAYLQQLLPFNQLAVSNSAAYLQQRQQLLNPLAVANPLVATFLQQQQQLLPYNQFSLMNPALQQPIVGGAIF'''
        self.SequenceMaker = SequenceMaker(OrigSeq)

        #	initialize database interface
        self.DbInterface = DbInterface('zeinsolub', 'prosol')
        print("Initialized")
        return

    #	Begin scrapping 5 sequences input for n times
    #	Unconstrained version
    def start_unconstrained_upto(self, n, length):
        print("Begin Mining...")
        row = []
        for i in range(n):
            leng = random.randint(1, length)
            randomSequence = self.SequenceMaker.generator_unconstrained(leng)
            with open("./software/prosol/sequence.fasta", "w") as se:
                se.write(">sample" + "\n")
                se.write(randomSequence)
                call([
                    "./software/prosol/multiple_prediction_wrapper_export.sh",
                    "sequence.fasta"
                ])
                while not os.path.exists("seq_prediction.txt"):
                    time.sleep(.1)
                with open("./software/prosol/seq_prediction.txt", "r") as rs:
                    for line in rs:
                        if line.startswith("SEQUENCE PREDICTIONS"):
                            nline = line.split(",")
                            solub = nline[3]
                            deter = True if solub > 0.45 else False
                        else:
                            raise ValueError

                call(["rm", "seq_prediction.txt"])
                aa_count_list, charge = self.SequenceMaker.count_aa_difference(
                    randomSequence)
                row = [deter, solub, sum(aa_count_list), charge
                       ] + aa_count_list + [randomSequence]

                self.DbInterface.insert(row)
                self.n += 1
                print('---Written ' + str(self.n) + ' rows---')
        return 0
示例#2
0
    def __init__(self):
        print("Initializing PROSOII script...")
        self.n = 0

        #	set up the SequenceMaker
        OrigSeq = '''MATKILALLALLALLVSATNAFIIPQCSLAPSASIPQFLPPVTSMGFEHPAVQAYRLQLALAASALQQPIAQLQQQSLAHLTLQTIATQQQQQQFLPSLSHLAVVNPVTYLQQQLLASNPLALANVAAYQQQQQLQQFMPVLSQLAMVNPAVYLQLLSSSPLAVGNAPTYLQQQLLQQIVPALTQLAVANPAAYLQQLLPFNQLAVSNSAAYLQQRQQLLNPLAVANPLVATFLQQQQQLLPYNQFSLMNPALQQPIVGGAIF'''
        self.SequenceMaker = SequenceMaker(OrigSeq)

        #	initialize database interface
        self.DbInterface = DbInterface('zeinsolub', 'prosol')
        print("Initialized")
        return
示例#3
0
    def __init__(self):
        print("Initializing PROSOII script...")
        self.n = 0

        #	set up the SequenceMaker
        OrigSeq = '''MATKILALLALLALLVSATNAFIIPQCSLAPSASIPQFLPPVTSMGFEHPAVQAYRLQLALAASALQQPIAQLQQQSLAHLTLQTIATQQQQQQFLPSLSHLAVVNPVTYLQQQLLASNPLALANVAAYQQQQQLQQFMPVLSQLAMVNPAVYLQLLSSSPLAVGNAPTYLQQQLLQQIVPALTQLAVANPAAYLQQLLPFNQLAVSNSAAYLQQRQQLLNPLAVANPLVATFLQQQQQLLPYNQFSLMNPALQQPIVGGAIF'''
        self.SequenceMaker = SequenceMaker(OrigSeq)

        #	initialize driver and preload the website
        chromedriver = '/Users/mac/webscript/chromedriver'
        os.environ["webdriver.chrome.driver"] = chromedriver
        self.driver = webdriver.Chrome(chromedriver)
        self.url = 'http://mbiljj45.bio.med.uni-muenchen.de:8888/prosoII/prosoII.seam'
        self.driver.get(self.url)
        print("Opening Browser...")

        #	initialize database interface
        self.DbInterface = DbInterface('zeinsolub',\
                  'proso')
        print("Initialized")
示例#4
0
    def __init__(self):
        print("Initializing PROSOII script...")
        self.n = 0

        #	set up the SequenceMaker
        OrigSeq = '''MATKILALLALLALLVSATNAFIIPQCSLAPSASIPQFLPPVTSMGFEHPAVQAYRLQLALAASALQQPIAQLQQQSLAHLTLQTIATQQQQQQFLPSLSHLAVVNPVTYLQQQLLASNPLALANVAAYQQQQQLQQFMPVLSQLAMVNPAVYLQLLSSSPLAVGNAPTYLQQQLLQQIVPALTQLAVANPAAYLQQLLPFNQLAVSNSAAYLQQRQQLLNPLAVANPLVATFLQQQQQLLPYNQFSLMNPALQQPIVGGAIF'''
        self.SequenceMaker = SequenceMaker(OrigSeq)

        #	initialize database interface
        self.DbInterface = DbInterface('zeinsolub', 'prosol')

        conn = psycopg2.connect("dbname=zeinsolub")
        cur = conn.cursor()
        cur.execute("SELECT seq FROM proso2")
        self.material = cur.fetchall()

        cur.close()
        conn.close()

        self.index = 0
        self.leng = len(self.material)

        print("Initialized")
        return
示例#5
0
class prosoWeb:
    """interface of proso predictor"""

    #	initialize evironment
    def __init__(self):
        print("Initializing PROSOII script...")
        self.n = 0

        #	set up the SequenceMaker
        OrigSeq = '''MATKILALLALLALLVSATNAFIIPQCSLAPSASIPQFLPPVTSMGFEHPAVQAYRLQLALAASALQQPIAQLQQQSLAHLTLQTIATQQQQQQFLPSLSHLAVVNPVTYLQQQLLASNPLALANVAAYQQQQQLQQFMPVLSQLAMVNPAVYLQLLSSSPLAVGNAPTYLQQQLLQQIVPALTQLAVANPAAYLQQLLPFNQLAVSNSAAYLQQRQQLLNPLAVANPLVATFLQQQQQLLPYNQFSLMNPALQQPIVGGAIF'''
        self.SequenceMaker = SequenceMaker(OrigSeq)

        #	initialize driver and preload the website
        chromedriver = '/Users/mac/webscript/chromedriver'
        os.environ["webdriver.chrome.driver"] = chromedriver
        self.driver = webdriver.Chrome(chromedriver)
        self.url = 'http://mbiljj45.bio.med.uni-muenchen.de:8888/prosoII/prosoII.seam'
        self.driver.get(self.url)
        print("Opening Browser...")

        #	initialize database interface
        self.DbInterface = DbInterface('zeinsolub',\
                  'proso')
        print("Initialized")

    #	Begin scrapping 50 sequences input for n times
    #	Unconstrained version
    def start_unconstrained(self, \
           n, length):
        print("Begin Mining...")
        for i in range(n):

            #	Initialize data buffer
            data = []

            #	Enter 50 random sequence into textarea
            for i in range(50):
                leng = random.randint(1,\
                      length)
                randomSequence = self.SequenceMaker.generator_unconstrained(
                    leng)
                self.driver.find_element_by_id("form1:inText")\
                   .send_keys(">sample\n"+ randomSequence + "\n")
                aa_count_list, charge = self.SequenceMaker.count_aa_difference(
                    randomSequence)
                data.append([False, 0, sum(aa_count_list), charge] +
                            aa_count_list + [randomSequence])

            #	Submmit text via Ajax
            self.driver.find_element_by_id("form1:j_id24").click()

            #	Wait for data table to be loaded
            wait = WebDriverWait(self.driver, 100000)
            element = wait.until(
                EC.invisibility_of_element_located(
                    (By.ID, "_viewRoot:status.start")))

            #	Parsing raw HTML response and locate the result table
            page_soup = soup(self.driver.page_source, "html.parser")
            tb = page_soup.findAll(id="infoBlock_body")
            slubs = tb[0].findAll("td")

            #	Prepare data buffer to be written to database
            index = 0
            for i in range(2, 3 * 50, 3):
                temp = slubs[i].text.split(';')
                data[index][0] = True if temp[0] == 'soluble' else False
                data[index][1] = float(temp[1])
                index += 1

            #	Upload data to database
            for item in data:
                self.DbInterface.insert(item)
                self.n += 1
                print('---Written ' + str(self.n) + ' rows---')

            #	Clear text area
            self.driver.find_element_by_id("form1:inText").clear()

        #	close database session and return
        self.DbInterface.close_connection()
        return 0

    #	Begin scrapping 50 sequences input for n times with constrained charge
    #	Unconstrained version
    def start_constrained(self, n, length, positive, negative):
        print("Begin Mining...")
        for i in range(n):

            #	Initialize data buffer
            data = []

            #	Enter 50 random sequence into textarea
            for i in range(50):
                leng = length
                charge = total_sub = -1
                #		make sure the sequence fits the reqirement
                while not (charge >= (5 - negative) and charge <=
                           (5 + positive) and total_sub == length):
                    randomSequence = self.SequenceMaker.generator_constrained(
                        leng, -negative, positive)
                    aa_count_list, charge = self.SequenceMaker.count_aa_difference(
                        randomSequence)
                    total_sub = sum(aa_count_list)
                #	Input to text area
                self.driver.find_element_by_id("form1:inText")\
                   .send_keys(">sample\n"+ randomSequence + "\n")

                #	write to buffer
                data.append([False, 0, sum(aa_count_list), charge] +
                            aa_count_list + [randomSequence])

            #	Submmit text via Ajax
            self.driver.find_element_by_id("form1:j_id24").click()

            #	Wait for data table to be loaded
            wait = WebDriverWait(self.driver, 100000)
            element = wait.until(
                EC.invisibility_of_element_located(
                    (By.ID, "_viewRoot:status.start")))

            #	Parsing raw HTML response and locate the result table
            page_soup = soup(self.driver.page_source, "html.parser")
            tb = page_soup.findAll(id="infoBlock_body")
            slubs = tb[0].findAll("td")

            #	Prepare data buffer to be written to database
            index = 0
            for i in range(2, 3 * 50, 3):
                temp = slubs[i].text.split(';')
                data[index][0] = True if temp[0] == 'soluble' else False
                data[index][1] = float(temp[1])
                index += 1

            #	Upload data to database
            for item in data:
                self.DbInterface.insert(item)
                self.n += 1
                print('---Written ' + str(self.n) + ' rows---')

            #	Clear text area
            self.driver.find_element_by_id("form1:inText").clear()

        #	close database session and return
        self.DbInterface.close_connection()
        return 0
示例#6
0
class prosol:
    """interface of proso predictor"""

    #	initialize evironment

    def __init__(self):
        print("Initializing PROSOII script...")
        self.n = 0

        #	set up the SequenceMaker
        OrigSeq = '''MATKILALLALLALLVSATNAFIIPQCSLAPSASIPQFLPPVTSMGFEHPAVQAYRLQLALAASALQQPIAQLQQQSLAHLTLQTIATQQQQQQFLPSLSHLAVVNPVTYLQQQLLASNPLALANVAAYQQQQQLQQFMPVLSQLAMVNPAVYLQLLSSSPLAVGNAPTYLQQQLLQQIVPALTQLAVANPAAYLQQLLPFNQLAVSNSAAYLQQRQQLLNPLAVANPLVATFLQQQQQLLPYNQFSLMNPALQQPIVGGAIF'''
        self.SequenceMaker = SequenceMaker(OrigSeq)

        #	initialize database interface
        self.DbInterface = DbInterface('zeinsolub', 'prosol')

        conn = psycopg2.connect("dbname=zeinsolub")
        cur = conn.cursor()
        cur.execute("SELECT seq FROM proso2")
        self.material = cur.fetchall()

        cur.close()
        conn.close()

        self.index = 0
        self.leng = len(self.material)

        print("Initialized")
        return

    #	Begin scrapping 5 sequences input for n times
    #	Unconstrained version
    def recover(self):
        print("Begin Recover...")
        while self.index < self.leng:
            row = []
            buffer = []
            sequenceBuffer = []
            # for i in range(n):
            with open("sequence.fasta", "w") as se:
                for i in range(50):
                    randomSequence = self.material[self.index][0]
                    sequenceBuffer.append(randomSequence)
                    se.write(">sample" + str(i) + "\n")
                    se.write(randomSequence + "\n")
                    self.index += 1
                print("------50 rows done------")
            call(["./multiple_prediction_wrapper_export.sh", "sequence.fasta"])

            while not os.path.exists("seq_prediction.txt"):
                time.sleep(.1)

            coun = 0
            with open("seq_prediction.txt", "r") as rs:
                for line in rs:
                    if line.startswith("SEQUENCE PREDICTIONS"):
                        nline = line.split(",")
                        solub = float(nline[3])
                        deter = True if solub > 0.45 else False
                        #print(solub, deter)
                        ranseq = sequenceBuffer[coun]
                        aa_count_list, charge = self.SequenceMaker.count_aa_difference(
                            ranseq)
                        row = [deter, solub,
                               sum(aa_count_list), charge
                               ] + aa_count_list + [ranseq]
                        buffer.append(row)
                        coun += 1
            call(["rm", "seq_prediction.txt"])
            # print(coun)
            for eachrow in buffer:
                self.DbInterface.insert(eachrow)
                self.n += 1
                #print('---Written ' + str(self.n) + ' rows---')
        return 0