def fastaToCNSThreeLetter(seqRecord,width=10): seqStr = seqRecord.seq.tostring() L = len(seqStr) outSeq = [PP.one_to_three(i) for i in seqStr] numbered = zip(outSeq,count(0)) groups = [[j[0] for j in i[1]] for i in groupby(numbered,lambda x:x[1]/width)] joined = '\n'.join([' '.join(one_group) for one_group in groups]) + '\n' return joined
def GetList(protein, mincount, measure_cutoffs, thresh=9.0, loss=True): """Get list with SSP positions, AA in three letter code. If loss==False, use complement for gain predictions. """ pos = GetNetworkExtremes(protein, mincount, measure_cutoffs, thresh=thresh) if not loss: total_pos = functional_data[protein].columns complement = [i for i in total_pos if i not in pos] pos = complement positions = map(lambda x: pp.one_to_three(x[0]) + x[1:], pos) return list(positions)
def write_pdb_tleap(output_filepath, sequence, phi, psi): leapfile = tempfile.NamedTemporaryFile(mode='w', delete=False) leapfile.write('source leaprc.ff14SB\n') sequence = ' '.join([Polypeptide.one_to_three(aa) for aa in sequence]) leapfile.write('system = sequence {' + sequence + '}\n') for i in range(len(phi)): leapfile.write(( 'impose system {%s} ' '{{"N" "CA" "C" "N" %s} ' '{"C" "N" "CA" "C" %s}}\n') % ( i + 1, phi[i], psi[i], ) ) leapfile.write('savepdb system ' + output_filepath) leapfile.write('\nquit\n') leapfile.close() subprocess.check_call(['tleap', '-f', leapfile.name]) os.remove(leapfile.name)