• 3.Complementing a Strand of DNA


    Problem

    In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'.

    The reverse complement of a DNA string ss is the string scsc formed by reversing the symbols of ss, then taking the complement of each symbol (e.g., the reverse complement of "GTCA" is "TGAC").

    Given: A DNA string ss of length at most 1000 bp.

    Return: The reverse complement scsc of ss.

    Sample Dataset

    AAAACCCGGT
    

    Sample Output

    ACCGGGTTTT
    # -*- coding: utf-8 -*-
    """
    Created on Thu Dec 08 20:33:16 2016
    
    @author: hyl
    “”” alt_map = {'ins':'0'} complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'} def reverse_complement(seq): for k,v in alt_map.iteritems(): seq = seq.replace(k,v) bases = list(seq) bases = reversed([complement.get(base,base) for base in bases]) bases = ''.join(bases) for k,v in alt_map.iteritems(): bases = bases.replace(v,k) print bases if __name__ == "__main__": fh= open ("C:\Users\hyl\Desktop\rosalind_revc.txt") seq ='' for line in fh.readlines(): seq += line reverse_complement(seq)
  • 相关阅读:
    java-第二周学习总结
    春季总结
    第十二周作业
    第十一周作业
    第十周作业
    第九周作业
    第八周作业
    网络层思维导图
    数据链路层思维导图
    Mysql数据库的基本操作之建表操作(2)
  • 原文地址:https://www.cnblogs.com/ylHe/p/6170705.html
Copyright © 2020-2023  润新知