Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
master_project_JLU2018/bin/get_best_motif.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (23 sloc)
784 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# parses arguments using argparse | |
# @return args list of all parameters | |
def parse_arguments(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("meme", help="Path to meme file") | |
parser.add_argument("output", help="Output file") | |
parser.add_argument("num", help="Number of motifs parsed from file") | |
args = parser.parse_args() | |
return args | |
# write lines of file till certain line (MOTIF + [num]) | |
def main(): | |
args = parse_arguments() | |
out = open(args.output, "w+") | |
number = int(args.num) + 1 | |
motif = "MOTIF " + str(number) | |
with open(args.meme) as f: | |
for line in f: | |
if motif in line: | |
break | |
out.write(line) | |
if __name__ == "__main__": | |
import argparse | |
main() |