Skip to content

Commit

Permalink
Merge pull request #130 from CostaLab/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lzj1769 authored Aug 19, 2019
2 parents ba30e36 + c098662 commit 7cb9d88
Show file tree
Hide file tree
Showing 7 changed files with 388 additions and 684 deletions.
18 changes: 13 additions & 5 deletions data/motifs/createPwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
import re
import argparse

from rgt.Util import npath

parser = argparse.ArgumentParser()

parser.add_argument('-i', '--input-file', type=str, required=True, help='name of the input file')
parser.add_argument('-f', '--input-format', choices=['jaspar-2014', 'jaspar-2016', 'hocomoco-pcm'], type=str, required=True, help='format of the input file')
parser.add_argument('-f', '--input-format', choices=['jaspar-2014', 'jaspar-2016', 'hocomoco-pcm'],
type=str, required=True, help='format of the input file')
parser.add_argument('-o', '--output-folder', type=str, required=True, help='name of output Folder')

args = parser.parse_args()

# read the input file
with open(args.input_file, "r") as f:
with open(npath(args.input_file), "r") as f:
content = f.readlines()

n_lines = len(content)

output_folder = npath(args.output_folder)

# make output directory path, if it doesn't exist
os.makedirs(output_folder)

###################################################################################################
# JASPAR 2014
###################################################################################################
Expand All @@ -32,7 +40,7 @@
count_g = re.sub('\s+', ' ', count_g)
count_t = re.sub('\s+', ' ', count_t)

outputFileName = os.path.join(args.output_folder, "{}.pwm".format(motif_name.replace(">", "")))
outputFileName = os.path.join(output_folder, "{}.pwm".format(motif_name.replace(">", "")))
with open(outputFileName, "w") as f:
f.write(count_a + "\n")
f.write(count_c + "\n")
Expand All @@ -55,7 +63,7 @@
count_g = re.sub('\s+', ' ', count_g)
count_t = re.sub('\s+', ' ', count_t)

outputFileName = os.path.join(args.output_folder, "{}.pwm".format(motif_name))
outputFileName = os.path.join(output_folder, "{}.pwm".format(motif_name))
with open(outputFileName, "w") as f:
f.write(count_a + "\n")
f.write(count_c + "\n")
Expand Down Expand Up @@ -97,7 +105,7 @@
count_g = ' '.join(count_g)
count_t = ' '.join(count_t)

outputFileName = os.path.join(args.output_folder, "{}.pwm".format(motif_name))
outputFileName = os.path.join(output_folder, "{}.pwm".format(motif_name))
with open(outputFileName, "w") as f:
f.write(count_a + "\n")
f.write(count_c + "\n")
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ HTSeq
hmmlearn
configparser
matplotlib
pyx
natsort
moods-python
pandas
logomaker
Loading

0 comments on commit 7cb9d88

Please sign in to comment.