示例#1
0
def sequence_maker(length,
                   pdb_folder=os.getcwd() + '/pdb',
                   outputname='allpeps.txt'):
    outputname = str(len) + outputname
    sequences = {}
    total = len(os.listdir(pdb_folder))
    count = 0
    for i in os.listdir(pdb_folder):
        count += 1
        print(str(count) + ' out of ' + str(total) +
              ' completed, Unique Found: ' + str(len(sequences.keys())),
              end='\r')
        file = pd.parsePDB(pdb_folder + '/' + i)
        if file is None:
            os.remove(pdb_folder + '/' + i)
            continue
        seq = pp.find_seq(file)[0]
        info = m.pep_parser(seq, length)
        for mot in info:
            if mot != 'full':
                for pep in info[mot]:
                    if pep not in sequences:
                        sequences[pep] = 1
                    else:
                        sequences[pep] += 1
    print('Saving Sequences')
    with open(outputname, 'w+') as g:
        g.write('Sequence,Amount Found \n')
        for i in sequences:
            g.write(i + ',' + str(sequences[i]) + '\n')
示例#2
0
 def make_structure(pdb_loc, length, maxValues, temp_value):
     #    pdb = pdb_loc.split('/')[-1]
     seperate_pdb(
         pdb_loc,
         temp_value)  # seperates pdb files by block, see above function
     completed = []
     # for every seperated file
     for i in os.listdir(d + "/temp_pdb/" + str(temp_value)):
         try:
             # gets atom data
             pdb_parsed = pd.parsePDB(d + "/temp_pdb/" + str(temp_value) +
                                      "/" + i)
         except:
             continue
         if pdb_parsed == None:
             continue
         seq, elements = find_seq(pdb_parsed)
         for i in elements:
             if i not in ELEMENT_INDEX:
                 return []
         # gets all the motifs from the peptides
         info = m.pep_parser(
             seq['full'], length
         )  # sends a sequence array and the given length to the pep parser
         #        if not os.path.exists(d + '/made_adj/' + pdb.replace('.pdb','')):
         #            os.mkdir(d + '/made_adj/' + pdb.replace('.pdb',''))
         for motif in info:
             if motif == 'full':
                 continue
             for pep in info[motif]:
                 completed.append(main_calc(pep, seq, maxValues,
                                            pdb_parsed))
     return completed
示例#3
0
def make_structure(pdb1, length, maxValues):
    global seq, file, seq_to_pdb, pdb, mV
    mV = maxValues
    pdb = pdb1
    cleaning.cleanATOM(d + '\\pdb\\' + pdb,
                       out_file=d + '\\cleaned\\' + pdb,
                       ext='.pdb')
    file = pd.parsePDB(d + '\\cleaned\\' + pdb)
    seq, seq_to_pdb, pdb_to_seq = find_seq(file)
    info = m.pep_parser(seq, length)
    peps = []
    if not os.path.exists(d + '\\made_adj\\' + pdb.replace('.pdb', '')):
        os.mkdir(d + '\\made_adj\\' + pdb.replace('.pdb', ''))

    completed = []
    for motif in info:
        if motif == 'full':
            continue
        for pep in info[motif]:
            peps.append(pep)
            completed.append(main_calc(pep))
    return completed
示例#4
0
d = os.getcwd()
file = eg.fileopenbox(msg='Where is the file?')
peps = {}
full_string = ''
with open(file, 'r') as g:
    string = g.read()
    while string:
        full_string += string
        string = g.read()
full_string.replace('  ', ' ')
full_string = full_string.split('>')
for i in range(len(full_string)):
    full_string[i] = full_string[i].replace('\n', ' ').replace('>',
                                                               '').split(' ')
    if len(full_string[i]) > 1:
        peps[full_string[i][0]] = full_string[i][-2]

count = 0
for i in peps:
    count += 1
    with open('pep_titles.txt', 'w+') as f:
        f.write(i + ' ')
    print('Current Peptide: ' + i + " (" + str(count) + "/" + str(len(peps)) +
          ")")
    if not os.path.isdir(d + '\\found_peps\\' + i):
        os.mkdir(d + '\\found_peps\\' + i)
    found_peps = m.pep_parser(peps[i], 12)
    with open(d + '\\found_peps\\' + i + '\\peps.pickle', 'wb') as f:
        pickle.dump(found_peps, f, pickle.HIGHEST_PROTOCOL)