Mercurial > repos > charles-bernard > alfa
comparison ALFA/ALFA_wrapper.py @ 31:7df7bee710ad draft
Uploaded
author | charles-bernard |
---|---|
date | Sun, 18 Dec 2016 09:50:39 -0500 |
parents | 1c9cea51dc24 |
children | b26aec436ab5 |
comparison
equal
deleted
inserted
replaced
30:1c9cea51dc24 | 31:7df7bee710ad |
---|---|
58 k = 0 | 58 k = 0 |
59 reads_filenames = [''] * (n/2) | 59 reads_filenames = [''] * (n/2) |
60 reads_labels = [''] * (n/2) | 60 reads_labels = [''] * (n/2) |
61 for i in range(0, n, 2): | 61 for i in range(0, n, 2): |
62 reads_filenames[k] = reads_list[i].split('__fname__')[1] | 62 reads_filenames[k] = reads_list[i].split('__fname__')[1] |
63 reads_labels[k] = reads_list[i+1].split('__label__')[1] | 63 cur_label = reads_list[i+1].split('__label__')[1] |
64 reads_labels[k] = re.sub(r' ', '_', cur_label) | |
64 if not reads_labels[k]: | 65 if not reads_labels[k]: |
65 reads_labels[k] = 'sample_%s' % str(k) | 66 reads_labels[k] = 'sample_%s' % str(k) |
66 input2_args='%s %s %s' % (input2_args, reads_filenames[k], reads_labels[k]) | 67 input2_args='%s "%s" "%s"' % (input2_args, reads_filenames[k], reads_labels[k]) |
67 k += 1 | 68 k += 1 |
68 if format == 'bedgraph': | 69 if format == 'bedgraph': |
69 input2_args = input2_args + ' --bedgraph' | 70 input2_args = input2_args + ' --bedgraph' |
70 return input2_args, reads_filenames, reads_labels | 71 return input2_args, reads_filenames, reads_labels |
71 | 72 |
83 exit_and_explain("The script ALFA.py encountered the following error:\n\n%s" % alfa_err) | 84 exit_and_explain("The script ALFA.py encountered the following error:\n\n%s" % alfa_err) |
84 | 85 |
85 def merge_count_files(reads_labels): | 86 def merge_count_files(reads_labels): |
86 merged_count_file = open('count_file.txt', 'wb') | 87 merged_count_file = open('count_file.txt', 'wb') |
87 for i in range(0, len(reads_labels)): | 88 for i in range(0, len(reads_labels)): |
88 current_count_file = open(reads_labels[i] + '.categories_counts', 'r') | 89 current_count_file = open('%s.categories_counts' % reads_labels[i], 'r') |
89 merged_count_file.write('##LABEL: %s\n\n' % reads_labels[i]) | 90 merged_count_file.write('##LABEL: %s\n\n' % reads_labels[i]) |
90 merged_count_file.write(current_count_file.read()) | 91 merged_count_file.write(current_count_file.read()) |
91 merged_count_file.write('__________________________________________________________________\n') | 92 merged_count_file.write('__________________________________________________________________\n') |
92 current_count_file.close() | 93 current_count_file.close() |
93 merged_count_file.close() | 94 merged_count_file.close() |
104 | 105 |
105 #INPUT1: Annotation File | 106 #INPUT1: Annotation File |
106 if args.indexes: | 107 if args.indexes: |
107 # The indexes submitted by the user must exhibit the suffix '.(un)stranded.index' and will be called by alfa by their prefix | 108 # The indexes submitted by the user must exhibit the suffix '.(un)stranded.index' and will be called by alfa by their prefix |
108 index = symlink_user_indexes(args.indexes[0], args.indexes[1]) | 109 index = symlink_user_indexes(args.indexes[0], args.indexes[1]) |
109 input1_args = '-g %s' % index | 110 input1_args = '-g "%s"' % index |
110 elif args.bi_indexes: | 111 elif args.bi_indexes: |
111 input1_args = '-g %s' % args.bi_indexes[0] | 112 input1_args = '-g "%s"' % args.bi_indexes[0] |
112 elif args.annotation_file: | 113 elif args.annotation_file: |
113 input1_args = '-a %s' % args.annotation_file[0] | 114 input1_args = '-a "%s"' % args.annotation_file[0] |
114 else: | 115 else: |
115 exit_and_explain('No annotation file submitted !') | 116 exit_and_explain('No annotation file submitted !') |
116 | 117 |
117 #INPUT 2: Mapped Reads | 118 #INPUT 2: Mapped Reads |
118 if args.reads: | 119 if args.reads: |