python - Matching codons -
so i'm learning nested pools , don't it. task return matching pairs in following format:
[('aag', 'ttc'), ('gat', 'cta'), ('ttg', 'aac'), ('cat', 'gta'), ('ggc', 'ccg'), ('att', 'taa'), ('tct', 'aga')]
so code:
def matching_codons(complements, poola, poolb): complements = {'a':'t', 'c':'g', 't':'a', 'g':'c'} poola = ['aag', 'tac', 'cgg', 'gat', 'ttg', 'gtg', 'cat', 'ggc', 'att', 'tct'] poolb = ['taa', 'cta', 'aac', 'ttc', 'aga', 'ccc', 'ccg', 'gta'] final = [] in poola: z in poolb: if , z in complements: final.append() return(final)
it's not working , don't know why, don't quite it. how can make statement poola , poolb match according dictionary provided?
try search complements in other pool, instead of walking through every elements in poola , poolb.
def _complements(complements, str): return ''.join([complements[i] in str]) def matching_codons(complements, poola, poolb): final = [] in poola: if _complements(complements, i) in poolb: final.append((i, _complements(complements, i))) return final complements = {'a':'t', 'c':'g', 't':'a', 'g':'c'} poola = ['aag', 'tac', 'cgg', 'gat', 'ttg', 'gtg', 'cat', 'ggc', 'att', 'tct'] poolb = ['taa', 'cta', 'aac', 'ttc', 'aga', 'ccc', 'ccg', 'gta'] print matching_codons(complements, poola, poolb)
output
[('aag', 'ttc'), ('gat', 'cta'), ('ttg', 'aac'), ('cat', 'gta'), ('ggc', 'ccg'), ('att', 'taa'), ('tct', 'aga')]
Comments
Post a Comment