Skip to content

Commit

Permalink
also converted index and taxtbl
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Angerer committed May 9, 2017
1 parent 60067d5 commit 64ffcd8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
19 changes: 12 additions & 7 deletions taxMaps-index
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ parser.add_option(
help = "Dry run (default = False)"
)

(opt, args) = parser.parse_args()
if not opt.fasta_file or not opt.corr_file or not opt.tax_file:
parser.print_help()
sys.exit(-1)


######################################################### /ARGUMENTS,OPTIONS ###
################################################################################
Expand All @@ -137,7 +132,15 @@ if not opt.fasta_file or not opt.corr_file or not opt.tax_file:
################################################################################
### MAIN #######################################################################

if __name__ == '__main__':
def main(args=None):
if args is None:
args = sys.argv

opt, args = parser.parse_args(args)
if not opt.fasta_file or not opt.corr_file or not opt.tax_file:
parser.print_help()
sys.exit(-1)

module_dir = os.path.abspath(os.path.dirname(__file__))

fasta_f = opt.fasta_file
Expand All @@ -160,7 +163,7 @@ if __name__ == '__main__':
if sge_queue:
sge_f = prefix + '.sge'

dry_run = opt.dry
dry_run = opt.dry

gitax_str = ' '.join(['txM_gitax', '-i', fasta_f, '-c', gitax_f,'-t', tax_f, '2>', out_f, '>', in_f])
len_str = ' '.join(['txM_fastalen', '-i', in_f, '>', len_f])
Expand All @@ -187,3 +190,5 @@ if __name__ == '__main__':
###################################################################### /MAIN ###
################################################################################

if __name__ == '__main__':
main()
27 changes: 17 additions & 10 deletions taxMaps-taxtbl
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ parser.add_option(
help = "NCBI Taxonomy nodes.dmp file (Mandatory)"
)

(opt, args) = parser.parse_args()

if not opt.names_file or not opt.nodes_file:
parser.print_help()
exit(-1)

######################################################### /ARGUMENTS,OPTIONS ###
################################################################################
Expand All @@ -89,30 +84,42 @@ if not opt.names_file or not opt.nodes_file:
################################################################################
### MAIN #######################################################################

if __name__ == '__main__':
def main(args=None):
if args is None:
args = sys.argv

opt, args = parser.parse_args(args)

if not opt.names_file or not opt.nodes_file:
parser.print_help()
sys.exit(-1)

node_dict = {}

nodes_file = open(opt.nodes_file, 'r')
for line in nodes_file:
la = line.strip().split('\t')
la = line.strip().split('\t')
node = la[0]
parent = la[2]
rank = la[4]
node_dict[node] = [parent, rank]
nodes_file.close()
nodes_file.close()

names_file = open(opt.names_file, 'r')
for line in names_file:
la = line.strip().split('\t')
la = line.strip().split('\t')
if la[6] == 'scientific name':
node = la[0]
sci_name = la[2]
node_dict[node].append(sci_name)
names_file.close()
names_file.close()

for node in node_dict:
node_list = [node] + node_dict[node][1:] + [':'.join(find_path(node, node_dict))]
sys.stdout.write('\t'.join(node_list) + '\n')

###################################################################### /MAIN ###
################################################################################

if __name__ == '__main__':
main()

0 comments on commit 64ffcd8

Please sign in to comment.