#!/usr/bin/env python3 import sys import ws2016 as ws from argparse import ArgumentParser from random import randint as rand game=ArgumentParser() game.add_argument("Aufgabe5B.py", rand(1:10)) args=parser.parse_args() print(args) if len(sys.argv) > 1: with open(sys.argv[1], "rb") as f: data = ws.parse_fasta(f) print("Id\tGC%") for index, seq in enumerate(data): print("{0}\t{1:.2f}".format(seq['id'].decode(), ws.get_gc_content(data, index))) else: print("Run fasta_parser.py <filename>", file=sys.stderr) print(ws.__file__)
import argparse import ws2016 as ws parser = argparse.ArgumentParser(prog='PROG') parser.add_argument('-input', help='name of input file', type=argparse.FileType("r", encoding='UTF-8')) parser.add_argument('-o', '--output', help='name of output file', type=argparse.FileType("w", encoding='UTF-8'), default="-") args = parser.parse_args() data = ws.parse_fasta(args.input) args.output.write(str(data))
#!/usr/bin/env python import sys import ws2016 as ws #sys.argv[0] - prorgam name #sys.argv[1] - first argument if len(sys.argv) > 1: data = [] with open(sys.argv[1], "rb") as f: data.append(ws.parse_fasta(f)) data.append(ws.parse_fasta(f)) print(len(data))