Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/profilesDB/ProfilesDB2Map.py @ 31:0ab839023fe4
Uploaded
author | m-zytnicki |
---|---|
date | Tue, 30 Apr 2013 14:33:21 -0400 |
parents | 94ab73e8a190 |
children |
comparison
equal
deleted
inserted
replaced
30:5677346472b5 | 31:0ab839023fe4 |
---|---|
1 from commons.pyRepetUnit.profilesDB.ProfilesDatabankUtils import ProfilesDatabankUtils | |
2 | |
3 | |
4 class ProfilesDB2Map ( object ): | |
5 """ | |
6 write a file in map format from a ProfilDatabank object | |
7 You have to set an input File and an Output File names | |
8 """ | |
9 | |
10 def __init__(self): | |
11 self.profilesDBUtils = ProfilesDatabankUtils() | |
12 self._inputFile = "" | |
13 self._outputFile = "" | |
14 | |
15 def setInputFile(self, input): | |
16 self._inputFile = input | |
17 | |
18 def setOutputFile(self, output): | |
19 self._outputFile = output | |
20 | |
21 def _readProfilesDB( self ): | |
22 pfamDB = self.profilesDBUtils.read( self._inputFile ) | |
23 return pfamDB | |
24 | |
25 def _writeMapFile( self, pfamDBList ): | |
26 """ | |
27 write a file in map format from a ProfilDatabank object | |
28 """ | |
29 if pfamDBList.getList() != []: | |
30 f = open( self._outputFile , "w") | |
31 for ProfilInstance in pfamDBList.getList(): | |
32 f.write(ProfilInstance.name + "\t" + ProfilInstance.desc + "\t1\t" + str(ProfilInstance.length) + "\n") | |
33 f.close() | |
34 | |
35 def run( self ): | |
36 """ | |
37 read a profiles DB file, parse it and, write the corresponding .map file | |
38 """ | |
39 pfamDBList = self._readProfilesDB() | |
40 self._writeMapFile(pfamDBList) |