Skip to content

Commit

Permalink
Added functionality to Fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
basti committed Jan 3, 2019
1 parent c0c36bc commit e1db4c2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bin/3.1_create_gtf/Modules/CrossMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class CrossMapper:
def __init__(self, org, wd, out, is_dir):
self.org = org
if is_dir:
self.infile = os.path.join( wd + "/temp/" + org + ".gtf")
self.infile = os.path.join(wd + "/temp/" + org + ".gtf")
else:
self.infile = os.path.join(wd+"/data/temp/"+org+".gtf")
self.outfile = os.path.join(out+"/" + org + "_mapped.gtf")
self.outfile = os.path.join(out)
self.chainfile = self.get_chain_file(org, wd, is_dir)

# Execute Crossmapper for gff/gtf files
Expand Down
16 changes: 8 additions & 8 deletions bin/3.1_create_gtf/Modules/SaveResults.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ResultSaver:
"""

def __init__(self, results, organism, wd, mapped, is_data_dir, tissue, out):
def __init__(self, results, organism, wd, mapped, is_data_dir, out):

# Constructor and main method for result-saving
# input_parameter: results = finished list of gtf-entries
Expand All @@ -24,20 +24,20 @@ def __init__(self, results, organism, wd, mapped, is_data_dir, tissue, out):
# is_data_dir = boolean if wd is a data_dir (true) or not (false)
# is_data_dir = boolean if wd is a data_dir (true) or not (false)


# TODO: DATADIR !!

print("Save results to File !")
self.path = ""

# If results has to be crossmapped -> Path is tempdirectory.

if mapped:
if is_data_dir:
self.path = os.path.join(wd + "/temp/" + organism + ".gtf")
else:
self.path = os.path.join(wd + "/data/temp/" + organism + ".gtf" )
elif tissue:
self.path = os.path.join(out+"/"+organism+"_filtered.gtf")
self.path = os.path.join(wd + "/data/temp/" + organism + ".gtf")

# if no crossmapping is needed:
else:
self.path = os.path.join(out+"/"+organism+".gtf")
self.path = os.path.join(out)

with open(self.path, "w") as output_file:
for line in results:
Expand Down
10 changes: 7 additions & 3 deletions bin/3.1_create_gtf/RegGTFExtractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def main_script(organism, wd, data_dir, out, tissuetype=None):
# main function
# input_parameter: all parameters from argparse

# if no output parameter is given output file is "./organism.gtf"
if out == ".":
out = "./"+organism+".gtf"

(org, x_mappable) = check_organism(organism)
if not data_dir:
check_for_local_folder(wd)
Expand All @@ -122,11 +126,11 @@ def main_script(organism, wd, data_dir, out, tissuetype=None):
print("Getting Unique Results")
unique_filter = UniqueFilter(ense.get_gtf(), ucsc.get_gtf(), tissues)
if data_dir:
ResultSaver(unique_filter.get_results(), organism, data_dir, x_mappable, True, tissues, out)
ResultSaver(unique_filter.get_results(), organism, data_dir, x_mappable, True, out)
if x_mappable:
CrossMapper(organism, data_dir, out, True)
else:
ResultSaver(unique_filter.get_results(), organism, wd, x_mappable, False, tissues, out)
ResultSaver(unique_filter.get_results(), organism, wd, x_mappable, False, out)
if x_mappable:
CrossMapper(organism, wd, out, False)

Expand All @@ -140,7 +144,7 @@ def main_script(organism, wd, data_dir, out, tissuetype=None):
parser.add_argument('--tissue', help='Tissue- or Celltype(s)', action='store', nargs='*', type=str)
parser.add_argument('--wd', help='Working directory. default: "."', action='store', default=os.getcwd(), type=str)
parser.add_argument('--dir', help='Data directory. default: "working_directory"', action='store', default="", type=str)
parser.add_argument('--out', help='Output directory: default: "."', action='store', default=".", type=str)
parser.add_argument('--out', help='Path to output file: default: "./organism.gtf"', action='store', default=".", type=str)
args = vars(parser.parse_args())

# Check if organism exists
Expand Down

0 comments on commit e1db4c2

Please sign in to comment.