خرید بک لینک

Vote count: -1

I have a file with information about sequences. Every sequence has some lines. The sequences are separated by five white lines. I want to change the file into a list, and split it by 5 newlines. So that I have a list, with every sequence as one element. Then I want to remove the sequences that not contain the regular expression. At the end, I want a list, with only the sequences that contain the regex.

Now I have this. Can anyone help me further?

import re
def main():
    ReadFile()
    file = open ("filename.txt", "r")
    CreateList(file, data)
    RegEx(file, data)

def ReadFile()
    try:
        file = open ("filename.txt", "r")
    except IOError:
        print ("Can't open the file")
    except:
        print ("Something went wrong.")

def CreateList(file, data)
    data = file.readlines()
    data = data.split('n')

def RegEx(file, data)
    regex = ("[AG].{4}GK[ST]") 
    for element in data:
        if regex not in element: 
            data.remove(element) 
    print (data) 

main()

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 28 فروردين 1395 ساعت: 19:08

صفحه بندی