Demo entry 6152028

Pytho

   

Submitted by anonymous on Oct 04, 2016 at 00:34
Language: Python 3. Code size: 1.3 kB.

import sys
class CAS9:
    @staticmethod
    def clean(file):
        with open(file, 'r') as file:
            file.readline()
            Data = file.read().replace("\n", "").replace("N", "").upper()
        return Data

class polymorase(str):
    @staticmethod
    def transcripe(DNA):
        return DNA.replace("A","?").replace("T","A").replace("?","T").replace("C","?").replace("G","C").replace("?","G")
    @staticmethod
    def len(DNA):
        return len(DNA)

class sequencer:
    @staticmethod
    def sequence(argv):
        commands={"-len":polymorase.len,"-tra":polymorase.transcripe} # Dictonary 
        DNA = CAS9.clean(argv[1])
        rang = [0, -1, 1]
        x=0
        while(x<len(argv)):
            a = 0
            try:
                rang[0] = int(argv[x+a])
                a += 1
                rang[1] = int(argv[x+a])
                a += 1
                rang[2] = int(argv[x+a])
                a += 1
            except:
                pass
            if(a):
                x+=a-1
                DNA = DNA[rang[0]:rang[1]:rang[2]]
            try:
                DNA=commands[argv[x]](DNA)
            except:
                pass
            x+=1
        return DNA
if __name__ == '__main__':
    print(sequencer.sequence(sys.argv))

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).