Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/profilesDB/tests/completeProfilesDBFromAFileWithProfilesList_script.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:b0e8584489e6 | 18:94ab73e8a190 |
---|---|
1 #!/usr/bin/env python | |
2 ''' | |
3 Created on 19 mai 2009 | |
4 | |
5 @author: choede | |
6 ''' | |
7 | |
8 import commons.pyRepetUnit.profilesDB.CompleteAProfilesDBFromAFileWithProfilesNamesOrAccNumber | |
9 import user, os, sys, getopt, exceptions | |
10 from pyRepet.util.file.FileUtils import * | |
11 | |
12 #------------------------------------------------------------------------------ | |
13 | |
14 def help(): | |
15 | |
16 """ | |
17 Give the command-line parameters. | |
18 """ | |
19 | |
20 print "" | |
21 print "usage: ",sys.argv[0],"[ options ]" | |
22 print "options:" | |
23 print " -h: this help" | |
24 print " -d: name of profiles databank (format='pfam')" | |
25 print " -l: name of the profiles list file (name or accession number, default=profiles name)" | |
26 print " -o: name of the output file (default=profiles list file+'.getz')" | |
27 print " -v: verbose (default=0/1/2)" | |
28 print " -n: pfam accession number (default=Not set)" | |
29 print "" | |
30 | |
31 #------------------------------------------------------------------------------ | |
32 | |
33 def main(): | |
34 | |
35 DBFileName = "" | |
36 outFileName = "" | |
37 verbose = 0 | |
38 listFileName = "" | |
39 accNumber = False | |
40 | |
41 try: | |
42 opts,args=getopt.getopt(sys.argv[1:],"hd:l:o:v:n") | |
43 except getopt.GetoptError, err: | |
44 print str(err) | |
45 help() | |
46 sys.exit(1) | |
47 for o,a in opts: | |
48 if o == "-h": | |
49 help() | |
50 sys.exit(0) | |
51 elif o == "-d": | |
52 DBFileName = a | |
53 elif o == "-l": | |
54 listFileName = a | |
55 elif o == "-o": | |
56 outFileName = a | |
57 elif o == "-v": | |
58 verbose = int(a) | |
59 elif o == "-n": | |
60 accNumber = True | |
61 | |
62 | |
63 if DBFileName == "" or listFileName == "": | |
64 print "*** Error: missing compulsory options" | |
65 help() | |
66 sys.exit(1) | |
67 | |
68 if verbose > 0: | |
69 print "beginning of %s" % (sys.argv[0].split("/")[-1]) | |
70 sys.stdout.flush() | |
71 | |
72 if outFileName == "": | |
73 outFileName = "%s.getz" % ( listFileName ) | |
74 | |
75 CompleteProfilesDB = commons.pyRepetUnit.profilesDB.CompleteAProfilesDBFromAFileWithProfilesNamesOrAccNumber.CompleteAProfilesDBFromAFileWithProfilesNamesOrAccNumber() | |
76 CompleteProfilesDB.setProfilesDBFile ( DBFileName ) | |
77 CompleteProfilesDB.setProfilesToAdd ( listFileName ) | |
78 if accNumber == True: | |
79 CompleteProfilesDB.setPfamAccNumberKeys () | |
80 if verbose > 0: | |
81 print "The profiles list is in Accession number" | |
82 sys.stdout.flush() | |
83 getzCmd = CompleteProfilesDB.CmdToCompleteProfileDB() | |
84 f = open( outFileName , 'w') | |
85 f.write ( getzCmd ) | |
86 f.close() | |
87 | |
88 if verbose > 0: | |
89 fileUtils = FileUtils( ) | |
90 if fileUtils.isRessourceExists( outFileName ) and not(fileUtils.isFileEmpty( outFileName )): | |
91 print "%s finished successfully" % (sys.argv[0].split("/")[-1]) | |
92 sys.stdout.flush() | |
93 else: | |
94 print "warning %s execution failed" % (sys.argv[0].split("/")[-1]) | |
95 sys.stdout.flush() | |
96 | |
97 return 0 | |
98 | |
99 #------------------------------------------------------------------------------ | |
100 | |
101 if __name__ == '__main__': | |
102 main() |