annotate TrackHub.py @ 29:7e8a8b732db3 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
author yating-l
date Wed, 16 May 2018 18:04:20 -0400
parents d786bca6a75d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
1 #!/usr/bin/python
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
2 # -*- coding: utf8 -*-
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
3
16
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
4 import logging
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
5 import os
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
6 import tempfile
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
7 import shutil
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
8 import zipfile
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
9 from mako.lookup import TemplateLookup
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
10
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
11 # Internal dependencies
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
12 from datatypes.Datatype import Datatype
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
13 from util import subtools
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
14 from util import santitizer
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
15
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
16
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
17
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
18
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
19 class TrackHub(object):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
20 """docstring for TrackHub"""
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
21
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
22 def __init__(self, inputFastaFile, user_email, outputFile, extra_files_path, tool_directory):
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
23 super(TrackHub, self).__init__()
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
24 self.rootAssemblyHub = None
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
25
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
26 self.mySpecieFolderPath = None
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
27 self.myTracksFolderPath = None
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
28 self.tool_directory = tool_directory
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
29
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
30 self.reference_genome = inputFastaFile
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
31 # TODO: Add the specie name
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
32 self.genome_name = inputFastaFile.assembly_id
11
d05236b15f81 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3760d0c8353b924ecf994131a5c2eb381aa81fb2
rmarenco
parents: 10
diff changeset
33 self.specie_html = self.genome_name + '.html'
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
34 self.default_pos = None
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
35 self.user_email = user_email
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
36
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
37 # Set containing the groups already added. Updated by addGroup()
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
38 self.groups = set()
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
39
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
40 # TODO: Modify according to the files passed in parameter
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
41 # ---- Templates ----
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
42 # Template trackDb
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
43 mylookup = TemplateLookup(directories=[os.path.join(tool_directory, 'templates/trackDb')],
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
44 output_encoding='utf-8', encoding_errors='replace')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
45 self.trackDbTemplate = mylookup.get_template("layout.txt")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
46
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
47 # Template groups
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
48 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/groupsTxt')],
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
49 output_encoding='utf-8', encoding_errors='replace')
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
50 self.groupsTemplate = mylookup.get_template("layout.txt")
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
51
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
52 # ---- End Templates ----
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
53
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
54 self.extra_files_path = extra_files_path
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
55 self.outputFile = outputFile
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
56
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
57 # Create the structure of the Assembly Hub
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
58 # TODO: Merge the following processing into a function as it is also used in twoBitCreator
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
59 self.twoBitName = None
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
60 self.two_bit_final_path = None
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
61 self.chromSizesFile = None
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
62
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
63 self.default_pos = None
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
64
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
65 # Set all the missing variables of this class, and create physically the folders/files
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
66 self.rootAssemblyHub = self.__createAssemblyHub__(extra_files_path=extra_files_path)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
67
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
68 # Init the Datatype
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
69 Datatype.pre_init(self.reference_genome, self.two_bit_final_path, self.chromSizesFile,
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
70 self.extra_files_path, self.tool_directory,
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
71 self.mySpecieFolderPath, self.myTracksFolderPath)
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
72 '''
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
73 def createZip(self):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
74 for root, dirs, files in os.walk(self.rootAssemblyHub):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
75 # Get all files and construct the dir at the same time
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
76 for file in files:
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
77 self.outputZip.write(os.path.join(root, file))
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
78
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
79 self.outputZip.close()
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
80 '''
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
81 def addTrack(self, trackDbObject=None):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
82 # Create the trackDb.txt file in the specie folder, if not exists
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
83 # Else append the new track
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
84 # TODO: Get this out of the function
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
85 trackDbTxtFilePath = os.path.join(self.mySpecieFolderPath, 'trackDb.txt')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
86 # Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
87 with open(trackDbTxtFilePath, 'a+') as trackDbFile:
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
88 group_name = trackDbObject["group"]
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
89 trackDbObject["group"] = santitizer.sanitize_group_name(trackDbObject["group"])
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
90 trackDbs = [trackDbObject]
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
91 # TODO: The addGroup does not belong here. Move it when the group becomes more than just a label
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
92 # Add the group as well, if exists in trackDbObject
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
93 self.addGroup(group_name)
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
94
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
95 htmlMakoRendered = self.trackDbTemplate.render(
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
96 trackDbs=trackDbs
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
97 )
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
98 trackDbFile.write(htmlMakoRendered)
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
99
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
100 #logging.debug("We just added track {0} (in group {1})".format(trackDbObject.trackName,
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
101 # trackDbObject.group_name.lower().replace(' ', '_')))
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
102 logging.debug("We just added track {0} (in group {1})".format(trackDbObject.get("track"),
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
103 trackDbObject.get("group").lower().replace(' ', '_')))
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
104 def addGroup(self, group_name="Default"):
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
105 # If not already present in self.groups, add to groups.txt
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
106 # Create the trackDb.txt file in the specie folder, if not exists
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
107 # Else append the new track
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
108 # TODO: Get this out of the function
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
109 groupsTxtFilePath = os.path.join(self.mySpecieFolderPath, 'groups.txt')
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
110
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
111 # If the group is already present, we don't need to add it
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
112 if group_name in self.groups:
18
d786bca6a75d planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3007f4ce1d6e8ac8324970d355f028b9394e2a5f
rmarenco
parents: 17
diff changeset
113 logging.debug("We DON'T add in {0} the group {1}".format(groupsTxtFilePath,
d786bca6a75d planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3007f4ce1d6e8ac8324970d355f028b9394e2a5f
rmarenco
parents: 17
diff changeset
114 group_name))
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
115 return
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
116
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
117 # Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
118 with open(groupsTxtFilePath, 'a+') as groupFile:
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
119 # Add the group as well, if exists in trackDbObject
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
120
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
121 htmlMakoRendered = self.groupsTemplate.render(
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
122 label=group_name
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
123 )
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
124 groupFile.write(htmlMakoRendered)
18
d786bca6a75d planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3007f4ce1d6e8ac8324970d355f028b9394e2a5f
rmarenco
parents: 17
diff changeset
125 logging.debug("We just added in {0} the group {1}".format(groupsTxtFilePath,
d786bca6a75d planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3007f4ce1d6e8ac8324970d355f028b9394e2a5f
rmarenco
parents: 17
diff changeset
126 group_name))
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
127 self.groups.add(group_name)
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
128
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
129 def terminate(self):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
130 # Just a test to output a simple HTML
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
131 # TODO: Create a class to handle the file object
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
132 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates')],
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
133 output_encoding='utf-8', encoding_errors='replace')
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
134
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
135 mytemplate = mylookup.get_template('display.txt')
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
136 with open(self.outputFile, 'w') as htmlOutput:
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
137 # TODO: We are basically looping two times: One time with os.walk, Second time
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
138 # with the template. We could improve that if the number of files begins to be really important
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
139 list_relative_file_path = [ ]
16
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
140
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
141 # TODO: Create classes Tree to manage this => Better readibility and maintenability
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
142 def create_tree(array_path, tree, relative_array_file_path, level=0):
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
143 cur_relative_file_path = '/'.join(relative_array_file_path[:level+1])
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
144 if array_path[0] in tree.keys():
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
145 create_tree(array_path[1:], tree[array_path[0]][0],
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
146 relative_array_file_path, level+1)
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
147 else:
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
148 tree[array_path[0]] = ({}, cur_relative_file_path)
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
149 # TODO: Manage also the links of the directories => No link?
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
150 # => Managed in display.txt, but could also be managed there
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
151 # If we are don't have any sub-vertices
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
152 if len(array_path) == 1:
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
153 # We create the path to it
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
154 return
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
155 else:
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
156 create_tree(array_path[1:], tree[array_path[0]][0],
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
157 relative_array_file_path, level + 1)
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
158
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
159 walkable_tree = {}
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
160 for root, dirs, files in os.walk(self.extra_files_path):
16
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
161 # Prepare the tree from to perform a Depth First Search
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
162 for file in files:
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
163 relative_directory = os.path.relpath(root, self.extra_files_path)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
164 relative_file_path = os.path.join(relative_directory, file)
16
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
165 array_path = relative_file_path.split('/')
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
166 create_tree(array_path, walkable_tree, array_path, 0)
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
167
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
168 htmlMakoRendered = mytemplate.render(
16
3233451a3bd6 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
rmarenco
parents: 11
diff changeset
169 walkable_tree=walkable_tree
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
170 )
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
171 htmlOutput.write(htmlMakoRendered)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
172
29
7e8a8b732db3 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents: 18
diff changeset
173
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
174 def __createAssemblyHub__(self, extra_files_path):
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
175 # Get all necessaries infos first
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
176 # 2bit file creation from input fasta
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
177
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
178 # baseNameFasta = os.path.basename(fasta_file_name)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
179 # suffixTwoBit, extensionTwoBit = os.path.splitext(baseNameFasta)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
180 # nameTwoBit = suffixTwoBit + '.2bit'
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
181 twoBitFile = tempfile.NamedTemporaryFile(bufsize=0)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
182 subtools.faToTwoBit(self.reference_genome.false_path, twoBitFile.name)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
183
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
184 # Generate the twoBitInfo
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
185 twoBitInfoFile = tempfile.NamedTemporaryFile(bufsize=0)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
186 subtools.twoBitInfo(twoBitFile.name, twoBitInfoFile.name)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
187
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
188 # Then we get the output to generate the chromSizes
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
189 self.chromSizesFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".chrom.sizes")
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
190 subtools.sortChromSizes(twoBitInfoFile.name, self.chromSizesFile.name)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
191
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
192 # We can get the biggest scaffold here, with chromSizesFile
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
193 with open(self.chromSizesFile.name, 'r') as chrom_sizes:
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
194 # TODO: Check if exists
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
195 self.default_pos = chrom_sizes.readline().split()[0]
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
196
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
197 # TODO: Manage to put every fill Function in a file dedicated for reading reasons
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
198 # Create the root directory
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
199 myHubPath = os.path.join(extra_files_path, "myHub")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
200 if not os.path.exists(myHubPath):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
201 os.makedirs(myHubPath)
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
202
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
203 # Create the specie folder
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
204 # TODO: Generate the name depending on the specie
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
205 mySpecieFolderPath = os.path.join(myHubPath, self.genome_name)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
206 if not os.path.exists(mySpecieFolderPath):
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
207 os.makedirs(mySpecieFolderPath)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
208 self.mySpecieFolderPath = mySpecieFolderPath
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
209
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
210 # We create the 2bit file while we just created the specie folder
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
211 self.twoBitName = self.genome_name + ".2bit"
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
212 self.two_bit_final_path = os.path.join(self.mySpecieFolderPath, self.twoBitName)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
213 shutil.copyfile(twoBitFile.name, self.two_bit_final_path)
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
214
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
215 # Add the genomes.txt file
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
216 genomesTxtFilePath = os.path.join(myHubPath, 'genomes.txt')
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
217 self.__fillGenomesTxt__(genomesTxtFilePath)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
218
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
219 # Add the hub.txt file
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
220 hubTxtFilePath = os.path.join(myHubPath, 'hub.txt')
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
221 self.__fillHubTxt__(hubTxtFilePath)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
222
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
223 # Add the hub.html file
11
d05236b15f81 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3760d0c8353b924ecf994131a5c2eb381aa81fb2
rmarenco
parents: 10
diff changeset
224 hubHtmlFilePath = os.path.join(myHubPath, self.specie_html)
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
225 self.__fillHubHtmlFile__(hubHtmlFilePath)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
226
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
227
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
228 # Create the description html file in the specie folder
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
229 descriptionHtmlFilePath = os.path.join(mySpecieFolderPath, 'description.html')
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
230 self.__fillDescriptionHtmlFile__(descriptionHtmlFilePath)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
231
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
232 # Create the file groups.txt
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
233 # TODO: If not inputs for this, do no create the file
17
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
234 # groupsTxtFilePath = os.path.join(mySpecieFolderPath, 'groups.txt')
c02720d1afee planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1adbf397de1fc7af4d91e026093d7fff983e21cf
rmarenco
parents: 16
diff changeset
235 # self.__fillGroupsTxtFile__(groupsTxtFilePath)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
236
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
237 # Create the folder tracks into the specie folder
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
238 tracksFolderPath = os.path.join(mySpecieFolderPath, "tracks")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
239 if not os.path.exists(tracksFolderPath):
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
240 os.makedirs(tracksFolderPath)
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
241 self.myTracksFolderPath = tracksFolderPath
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
242
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
243 return myHubPath
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
244
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
245 def __fillGenomesTxt__(self, genomesTxtFilePath):
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
246 # TODO: Think about the inputs and outputs
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
247 # TODO: Manage the template of this file
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
248 # renderer = pystache.Renderer(search_dirs="templates/genomesAssembly")
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
249 pathTemplate = os.path.join(self.tool_directory, 'templates/genomesAssembly')
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
250 mylookup = TemplateLookup(directories=[pathTemplate], output_encoding='utf-8', encoding_errors='replace')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
251 mytemplate = mylookup.get_template("layout.txt")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
252 with open(genomesTxtFilePath, 'w') as genomesTxtFile:
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
253 # Write the content of the file genomes.txt
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
254 twoBitPath = os.path.join(self.genome_name, self.twoBitName)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
255 htmlMakoRendered = mytemplate.render(
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
256 genomeName=self.genome_name,
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
257 trackDbPath=os.path.join(self.genome_name, "trackDb.txt"),
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
258 groupsPath=os.path.join(self.genome_name, "groups.txt"),
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
259 genomeDescription=self.genome_name,
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
260 twoBitPath=twoBitPath,
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
261 organismName=self.genome_name,
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
262 defaultPosition=self.default_pos,
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
263 orderKey="4500",
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
264 scientificName=self.genome_name,
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
265 pathAssemblyHtmlDescription=os.path.join(self.genome_name, "description.html")
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
266 )
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
267 genomesTxtFile.write(htmlMakoRendered)
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
268
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
269 def __fillHubTxt__(self, hubTxtFilePath):
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
270 # TODO: Think about the inputs and outputs
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
271 # TODO: Manage the template of this file
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
272 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/hubTxt')],
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
273 output_encoding='utf-8', encoding_errors='replace')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
274 mytemplate = mylookup.get_template('layout.txt')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
275 with open(hubTxtFilePath, 'w') as genomesTxtFile:
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
276 # Write the content of the file genomes.txt
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
277 htmlMakoRendered = mytemplate.render(
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
278 hubName=(''.join(['gonramp', self.genome_name.title()])),
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
279 shortLabel=self.genome_name,
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
280 longLabel=self.genome_name,
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
281 genomesFile='genomes.txt',
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
282 email=self.user_email,
11
d05236b15f81 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3760d0c8353b924ecf994131a5c2eb381aa81fb2
rmarenco
parents: 10
diff changeset
283 descriptionUrl=self.specie_html
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
284 )
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
285 genomesTxtFile.write(htmlMakoRendered)
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
286
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
287 def __fillHubHtmlFile__(self, hubHtmlFilePath):
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
288 # TODO: Think about the inputs and outputs
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
289 # TODO: Manage the template of this file
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
290 # renderer = pystache.Renderer(search_dirs="templates/hubDescription")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
291 # t = Template(templates.hubDescription.layout.html)
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
292 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/hubDescription')],
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
293 output_encoding='utf-8', encoding_errors='replace')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
294 mytemplate = mylookup.get_template("layout.txt")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
295 with open(hubHtmlFilePath, 'w') as hubHtmlFile:
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
296 htmlMakoRendered = mytemplate.render(
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
297 specie='Dbia',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
298 toolUsed='Augustus',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
299 ncbiSpecieUrl='http://www.ncbi.nlm.nih.gov/genome/3499',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
300 genomeID='3499',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
301 specieFullName='Drosophila biarmipes'
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
302 )
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
303 #hubHtmlFile.write(htmlMakoRendered)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
304
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
305 def __fillDescriptionHtmlFile__(self, descriptionHtmlFilePath):
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
306 # TODO: Think about the inputs and outputs
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
307 # TODO: Manage the template of this file
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
308 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/specieDescription')],
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
309 output_encoding='utf-8', encoding_errors='replace')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
310 mytemplate = mylookup.get_template("layout.txt")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
311 with open(descriptionHtmlFilePath, 'w') as descriptionHtmlFile:
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
312 # Write the content of the file genomes.txt
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
313 htmlMakoRendered = mytemplate.render(
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
314 specieDescription='This is the description of the dbia',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
315 )
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
316 #descriptionHtmlFile.write(htmlMakoRendered)
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
317
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
318 def __fillGroupsTxtFile__(self, groupsTxtFilePath):
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
319 # TODO: Reenable this function at some point
10
acc233161f50 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1b1063f90004764bcf504f4340738eca5c4b1f9d
rmarenco
parents: 9
diff changeset
320 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/groupsTxt')],
1
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
321 output_encoding='utf-8', encoding_errors='replace')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
322 mytemplate = mylookup.get_template("layout.txt")
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
323 with open(groupsTxtFilePath, 'w') as groupsTxtFile:
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
324 # Write the content of groups.txt
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
325 # groupsTxtFile.write('name map')
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
326 htmlMakoRendered = mytemplate.render(
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
327 mapName='map',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
328 labelMapping='Mapping',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
329 prioriy='2',
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
330 isClosed='0'
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
331 )
fb5e60d4d18a planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
rmarenco
parents:
diff changeset
332 # groupsTxtFile.write(htmlMakoRendered)