Commit 9187ebd5 authored by Eric  DEVEAUD's avatar Eric DEVEAUD

clean

parent d62f53c6
#! /local/gensoft2/adm/bin/python
# import re
from __future__ import print_function
import os
import pykwalify
import sys
import yaml
# set verbosity level for check
pykwalify.init_logging(1)
from pykwalify.core import Core
from pprint import pprint
# ---- error handlers -------------------------------------------
FATAL = 1
WARN = 0
VERBOSE = 0
LOGFH = sys.stdout
ERRFH = sys.stderr
def err(exit_val, *msg):
head = ['Warning', 'Error']
print("%s: %s" % (head[exit_val], " - ".join(map(str, msg))), file=ERRFH)
if exit_val:
sys.exit(exit_val)
return None
def log(*msg):
if VERBOSE:
print("%s" % (' '.join(map(str, msg))), file=LOGFH)
def yamlloader(fh):
#---- get yaml informations
try:
return yaml.load(fh)
except yaml.YAMLError as msg:
err(FATAL, msg)
def _biodocs_check_syntax(biodocsFile, kind):
log(kind, biodocsFile)
schemas = {'package': PACK_SCHEMA
, 'packageVersion': PACKVERSION_SCHEMA
}
c = Core(source_file=biodocsFile, schema_files=[schemas[kind]])
try:
c.validate(raise_exception=True)
except pykwalify.errors.SchemaError as msg:
log ('invalid syntax')
return False
log('syntax OK')
return True
def unlazy(packinfo):
"""
Biodocs maitainer choose to be lazy.
perform inplace conversion the values he wanted to be abble to glob and copy//paste easyly
perform inplace conversion of boolean values
:param packinfo:
:return: None
"""
lazy = {'topics' : None # Package BIODOCS
, 'operations' : None
, 'authors' : ','
, 'languages' : None
, 'depends' : None # PackageVersion BIODOCS
, 'yum' : None
, 'pydeps' : None
, 'perdeps' : None
, 'rubydeps' : None
, 'packages' : None
, 'depend' : None
}
for key, sep in lazy.items():
if key not in packinfo:
continue
packinfo[key] = packinfo[key].split(sep) if packinfo[key] is not None else []
def get_packversion(biodocsfile, disable_syntax_chek=True):
"""
package version specific definition entries parser
returns a dictionary with information from pack version and parent package
:param biodocsfile: file to parse
:param disable_syntax_chek: boolean, allow to disable syntaxic check or the biodocs files
:return: dict
"""
# ---- check for tree files, infer package biodocs file from packversion's one
# ---- and check syntax
pack_file = os.path.join(os.path.dirname(os.path.dirname(biodocsfile)), 'BIODOCS.yaml')
for f in [biodocsfile, pack_file]:
if not os.path.exists(f):
err(FATAL, f, 'No such file or directory')
# ---- syntaxic check, may be ignored
if not disable_syntax_chek:
for f in [biodocsfile, pack_file]:
if not _biodocs_check_syntax(f):
err(FATAL, f, 'invalid syntax')
# ---- load infos
with open(biodocsfile, 'r') as fh:
pack_version = yamlloader(fh)
with open(pack_file, 'r') as fh:
pack = yamlloader(fh)
pack_version.update(pack)
# ---- convert lazy maintainer editing
unlazy(pack_version)
return pack_version
if __name__ == '__main__':
for biodocs in sys.argv[1:]:
print(biodocs)
pprint(get_packversion(biodocs))
import pymongo
import sys
import ssl
HOST='bioweb-pro.web.pasteur.fr'
PORT=27017
FATAL= 1
WARN= 0
VERBOSE= 1
LOGFH= sys.stdout
ERRFH= sys.stderr
JOURNALING=True # implies w=1
WRITECONCERN=1
DB_DEF='bioweb'
#client.max_message_size # size in bytes of max message
BULKSIZE = 10000
def error(exit_val, *msg):
head=['Warning', 'Error']
print >> ERRFH, "%s: %s" % (head[exit_val], " - ".join(map(str, msg)))
if exit_val:
sys.exit(exit_val)
return None
def log(*msg):
if VERBOSE:
print >> LOGFH, "%s" %(' '.join(map(str, msg)))
def get_DB(host, port, db_name=DB_DEF, j=JOURNALING, w=WRITECONCERN, ssl=True, ssl_cert_reqs=ssl.CERT_NONE ):
log('connect to', host, 'on port:', port)
try:
client = pymongo.MongoClient(host, port, ssl=True, ssl_cert_reqs=ssl.CERT_NONE) #, j=JOURNALING)
except pymongo.errors.ConnectionFailure as err:
error(FATAL, "mongodb %s/%s" %(host, port), err)
print ">>>>>>>>>>>>>>>", client
return client[db_name]
def undot(key_name):
return key_name.replace('.', '@')
def redot(key_name):
return key_name.replace('.', '@')
if __name__ == '__main__':
db = get_DB(HOST, PORT)
col = db['catalog']
# file generated by edam_mapper.py
EDAM-0000288 operation_0288
EDAM-0000289 operation_0289
EDAM-0000425 operation_0425
EDAM-0000219 topic_0219
EDAM-0000164 topic_0164
EDAM-0001813 operation_1813
EDAM-0000283 operation_0283
EDAM-0000284 operation_0284
EDAM-0000285 operation_0285
EDAM-0000286 operation_0286
EDAM-0000287 operation_0287
EDAM-0000569 operation_0569
EDAM-0003023 operation_3023
EDAM-0000659 topic_0659
EDAM-0000415 operation_0415
EDAM-0002428 operation_2428
EDAM-0000416 operation_0416
EDAM-0000419 operation_0419
EDAM-0000418 operation_0418
EDAM-0000563 operation_0563
EDAM-0000562 operation_0562
EDAM-0002422 operation_2422
EDAM-0000564 operation_0564
EDAM-0002420 operation_2420
EDAM-0002421 operation_2421
EDAM-0002277 topic_2277
EDAM-0002275 topic_2275
EDAM-0000203 topic_0203
EDAM-0000369 operation_0369
EDAM-0000499 operation_0499
EDAM-0000491 operation_0491
EDAM-0000490 operation_0490
EDAM-0000365 operation_0365
EDAM-0000492 operation_0492
EDAM-0000495 operation_0495
EDAM-0000362 operation_0362
EDAM-0000361 operation_0361
EDAM-0000496 operation_0496
EDAM-0000798 topic_0798
EDAM-0002506 operation_2506
EDAM-0000426 operation_0426
EDAM-0000128 topic_0128
EDAM-0003088 operation_3088
EDAM-0000797 topic_0797
EDAM-0000622 topic_0622
EDAM-0000301 operation_0301
EDAM-0000298 operation_0298
EDAM-0000623 topic_0623
EDAM-0000110 topic_0110
EDAM-0000247 operation_0247
EDAM-0000291 operation_0291
EDAM-0000290 operation_0290
EDAM-0000114 topic_0114
EDAM-0000296 operation_0296
EDAM-0000160 topic_0160
EDAM-0003087 operation_3087
EDAM-0002438 operation_2438
EDAM-0002476 operation_2476
EDAM-0003081 operation_3081
EDAM-0000545 operation_0545
EDAM-0000554 operation_0554
EDAM-0002437 operation_2437
EDAM-0000555 operation_0555
EDAM-0000323 operation_0323
EDAM-0002241 operation_2241
EDAM-0000194 topic_0194
EDAM-0000461 operation_0461
EDAM-0000196 topic_0196
EDAM-0000515 operation_0515
EDAM-0000516 operation_0516
EDAM-0000092 topic_0092
EDAM-0000356 operation_0356
EDAM-0003096 operation_3096
EDAM-0000354 operation_0354
EDAM-0000624 topic_0624
EDAM-0002089 operation_2089
EDAM-0000199 topic_0199
EDAM-0003056 topic_3056
EDAM-0000255 operation_0255
EDAM-0000108 topic_0108
EDAM-0000350 operation_0350
EDAM-0000102 topic_0102
EDAM-0000567 operation_0567
EDAM-0002429 operation_2429
EDAM-0000107 topic_0107
EDAM-0000511 operation_0511
EDAM-0002501 operation_2501
EDAM-0000100 topic_0100
EDAM-0000226 operation_0226
EDAM-0000227 operation_0227
EDAM-0000483 operation_0483
EDAM-0000220 topic_0220
EDAM-0000477 operation_0477
EDAM-0000182 topic_0182
EDAM-0000347 operation_0347
EDAM-0002520 operation_2520
EDAM-0002448 operation_2448
EDAM-0000340 operation_0340
EDAM-0000258 operation_0258
EDAM-0000470 operation_0470
EDAM-0000565 operation_0565
EDAM-0000188 topic_0188
EDAM-0002423 operation_2423
EDAM-0002412 operation_2412
EDAM-0003074 topic_3074
EDAM-0000552 operation_0552
EDAM-0000566 operation_0566
EDAM-0002439 operation_2439
EDAM-0003041 topic_3041
EDAM-0000655 topic_0655
EDAM-0000432 operation_0432
EDAM-0000137 topic_0137
EDAM-0000325 operation_0325
EDAM-0002515 operation_2515
EDAM-0001812 operation_1812
EDAM-0000238 operation_0238
EDAM-0000526 operation_0526
EDAM-0002466 operation_2466
EDAM-0000231 operation_0231
EDAM-0000230 operation_0230
EDAM-0000233 operation_0233
EDAM-0000232 operation_0232
EDAM-0000767 topic_0767
EDAM-0000237 operation_0237
EDAM-0000236 operation_0236
EDAM-0000330 operation_0330
EDAM-0000239 operation_0239
EDAM-0000539 operation_0539
EDAM-0000334 operation_0334
EDAM-0000335 operation_0335
EDAM-0000336 operation_0336
EDAM-0000337 operation_0337
EDAM-0000338 operation_0338
EDAM-0000533 operation_0533
EDAM-0000448 operation_0448
EDAM-0000368 operation_0368
EDAM-0002452 operation_2452
EDAM-0002451 operation_2451
EDAM-0000367 operation_0367
EDAM-0002120 operation_2120
EDAM-0002269 topic_2269
EDAM-0002575 operation_2575
EDAM-0000121 topic_0121
EDAM-0000123 topic_0123
EDAM-0000364 operation_0364
EDAM-0002489 operation_2489
EDAM-0000363 operation_0363
EDAM-0000478 operation_0478
EDAM-0003062 topic_3062
EDAM-0000637 topic_0637
EDAM-0002508 operation_2508
EDAM-0002238 operation_2238
EDAM-0000242 operation_0242
EDAM-0000004 operation_0004
EDAM-0000455 operation_0455
EDAM-0002502 operation_2502
EDAM-0000451 operation_0451
EDAM-0000450 operation_0450
EDAM-0002507 operation_2507
EDAM-0000452 operation_0452
EDAM-0000525 operation_0525
EDAM-0000524 operation_0524
EDAM-0000527 operation_0527
EDAM-0003053 topic_3053
EDAM-0000249 operation_0249
EDAM-0000523 operation_0523
EDAM-0000324 operation_0324
EDAM-0000082 topic_0082
EDAM-0000245 operation_0245
EDAM-0000080 topic_0080
EDAM-0000081 topic_0081
EDAM-0000240 operation_0240
EDAM-0000084 topic_0084
EDAM-0000085 topic_0085
EDAM-0000099 topic_0099
EDAM-0002426 operation_2426
EDAM-0002816 topic_2816
EDAM-0000694 topic_0694
EDAM-0002946 operation_2946
EDAM-0002443 operation_2443
EDAM-0000282 operation_0282
EDAM-0002814 topic_2814
EDAM-0000259 operation_0259
EDAM-0000313 operation_0313
EDAM-0003316 topic_3316
EDAM-0000398 operation_0398
EDAM-0000154 topic_0154
EDAM-0000740 topic_0740
EDAM-0000157 topic_0157
EDAM-0000747 topic_0747
EDAM-0000319 operation_0319
EDAM-0000749 topic_0749
EDAM-0000748 topic_0748
EDAM-0000422 operation_0422
EDAM-0000315 operation_0315
EDAM-0000158 topic_0158
EDAM-0000159 topic_0159
EDAM-0000310 operation_0310
EDAM-0000311 operation_0311
EDAM-0000550 operation_0550
EDAM-0000094 topic_0094
EDAM-0000097 topic_0097
EDAM-0000621 topic_0621
EDAM-0000091 topic_0091
EDAM-0000090 topic_0090
EDAM-0002121 operation_2121
EDAM-0000625 topic_0625
EDAM-0000558 operation_0558
EDAM-0000256 operation_0256
EDAM-0002284 operation_2284
EDAM-0000253 operation_0253
EDAM-0002478 operation_2478
EDAM-0000250 operation_0250
EDAM-0000447 operation_0447
EDAM-0000551 operation_0551
EDAM-0003024 operation_3024
EDAM-0000820 topic_0820
EDAM-0000821 topic_0821
EDAM-0002488 operation_2488
EDAM-0000380 operation_0380
EDAM-0002454 operation_2454
EDAM-0000235 operation_0235
EDAM-0003055 topic_3055
EDAM-0000475 operation_0475
EDAM-0002480 operation_2480
EDAM-0000370 operation_0370
EDAM-0000417 operation_0417
EDAM-0000278 operation_0278
EDAM-0000309 operation_0309
EDAM-0000308 operation_0308
EDAM-0000438 operation_0438
EDAM-0000140 topic_0140
EDAM-0000433 operation_0433
EDAM-0000300 operation_0300
EDAM-0000431 operation_0431
EDAM-0000430 operation_0430
EDAM-0003072 topic_3072
EDAM-0000436 operation_0436
EDAM-0000326 operation_0326
EDAM-0000632 topic_0632
EDAM-0000741 topic_0741
EDAM-0000736 topic_0736
EDAM-0002403 operation_2403
EDAM-0000547 operation_0547
EDAM-0000546 operation_0546
EDAM-0000557 operation_0557
EDAM-0000544 operation_0544
EDAM-0000262 operation_0262
EDAM-0002409 operation_2409
EDAM-0000260 operation_0260
EDAM-0002928 operation_2928
EDAM-0000266 operation_0266
EDAM-0000267 operation_0267
EDAM-0003073 topic_3073
EDAM-0000270 operation_0270
EDAM-0000292 operation_0292
EDAM-0002416 operation_2416
EDAM-0000179 topic_0179
EDAM-0002419 operation_2419
EDAM-0002499 operation_2499
EDAM-0002233 operation_2233
EDAM-0000077 topic_0077
EDAM-0000268 operation_0268
EDAM-0002495 operation_2495
EDAM-0000172 topic_0172
EDAM-0000346 operation_0346
EDAM-0000269 operation_0269
EDAM-0000176 topic_0176
EDAM-0000403 operation_0403
EDAM-0000578 operation_0578
EDAM-0000401 operation_0401
EDAM-0000640 topic_0640
EDAM-0000561 operation_0561
EDAM-0000770 topic_0770
EDAM-0000575 operation_0575
EDAM-0000573 operation_0573
EDAM-0000541 operation_0541
EDAM-0000428 operation_0428
EDAM-0000379 operation_0379
EDAM-0000488 operation_0488
EDAM-0000489 operation_0489
EDAM-0000487 operation_0487
EDAM-0000484 operation_0484
EDAM-0000279 operation_0279
EDAM-0000371 operation_0371
EDAM-0000372 operation_0372
EDAM-0002998 operation_2998
EDAM-0000540 operation_0540
align_reorder/20111202
bambe/4.01
bigorf_extract/1.0
bionj/None
blast/2.2.21
blast/2.2.26
blast2seqids/1.4
blast2taxonomy/2.1
blastTaxoAnalysis/1.0
BMGE/1.0
boxshade/3.3.1
cap3/04-15-05
CBS/None
cif/0.2.2
Clustal-Omega/1.1.0
ClustalW/2.0.12
CodonW/1.4.4
comalign/None
combat/1.0
concatfasta/1.00
CONJscan-T4SSscan/None
consensus/2004-04-14
cosa/None
dca/1.1
dialign/2.2.1
dssp/2000
ELP/2.0
EMBOSS/6.3.1
extend_align/1.0
fasta/3.6
fastaRename/1.0
fastDNAml/1.2.2
fetchSequences/1.0
forest2consense/None
gblocks/0.91b
genscan/1.0
golden/1.1a
growthpred/v1.07
gruppi/1.0
hmmer/3.0
html4blast/1.7a
imogene/1.0-253
ktreedist/1.0
mafft/6.849
melting/4.2g
mfold/3.6
morePhyML/1.14
mreps/2.5
msa/2.1
msaprobs/0.9.4
mspcrunch/2.5
muscle/3.8.31
mview/1.49
newick-utils/1.6
njplot/20051109
nw_cat/GNU 7.4
pdb-lib/1.0
penncnv/2009.08.27
pftools/2.3
phylip/3.67
phyml/20130219.patch
pima/1.40
pratt/2.1
predator/2.1.2
primo/None
prose/0.02a
psort/981201
puzzle/5.2
quicktree/1.1
rbvotree/1.00
repeatoire/1.0
repeats/1.1
saps/07-01-1995
saxs_merge/r17125
scan_for_matches/97
seq-gen/1.3.2
sig/1.0
smile/1.47
squizz/0.99b
T3SSscan-FLAGscan/None
tacg/4.1.0
taxoptimizer/1.1
tipdate/1.2
toppred/1.10
treealign/None
trnascan/1.23
ViennaRNA/1.8.4
weighbor/1.2.1
wise2/2.2.0
xpound/None
xxr/3.03
pack_info = [ 'align_reorder/20111202'
, 'bambe/4.01'
, 'bigorf_extract/1.0'
, 'bionj/NA'
# , 'blast/2.2.21'
, 'blast/2.2.26'
, 'blast2seqids/1.4'
, 'blast2taxonomy/2.1'
, 'blastTaxoAnalysis/1.0'
, 'BMGE/1.12'
, 'boxshade/3.3.1'
, 'cap3/04-15-05'
, 'tmhmm/NA'
, 'cif/0.2.2'
, 'Clustal-Omega/1.1.0'
, 'ClustalW/2.0.12'
, 'CodonW/1.4.4'
, 'comalign/NA'
, 'combat/1.0'
, 'concatfasta/1.00'
, 'consensus/2004-04-14'
, 'cosa/NA'
, 'dca/1.1'
, 'dialign/2.2.1'
, 'dssp/2000'
, 'ELP/2.0'
, 'EMBOSS/6.3.1'
, 'extend_align/1.0'
, 'fasta/3.6'
, 'fastaRename/1.0'
, 'fastDNAml/1.2.2'
, 'fetchSequences/1.0'
, 'forest2consense/NA'
, 'gblocks/0.91b'
, 'genscan/1.0'
, 'golden/1.1a'
, 'growthpred/v1.07'
, 'gruppi/1.0'
, 'hmmer/3.0'
, 'html4blast/1.7a'
, 'imogene/1.0-253'
, 'ktreedist/1.0'
, 'mafft/6.849'
, 'melting/4.2g'
, 'mfold/3.6'
, 'morePhyML/1.14'
, 'mreps/2.5'
, 'msa/2.1'
, 'msaprobs/0.9.4'
, 'mspcrunch/2.5'
, 'muscle/3.8.31'
, 'mview/1.49'
, 'newick-utils/1.6'
, 'njplot/20051109'
, 'nw_cat/GNU 7.4'
, 'pdb-lib/1.0'
, 'penncnv/2009.08.27'
, 'pftools/2.3'
, 'phylip/3.67'
, 'phyml/20130219.patch'
, 'pima/1.40'
, 'pratt/2.1'
, 'predator/2.1.2'
, 'primo/NA'
, 'prose/0.02a'
, 'psort/981201'
, 'puzzle/5.2'
, 'quicktree/1.1'
, 'rbvotree/1.00'
, 'repeatoire/1.0'
, 'repeats/1.1'
, 'saps/07-01-1995'
, 'IMP/r17125' # saxmerge
, 'scan_for_matches/97'
, 'scousin-tools/0.1'
, 'seq-gen/1.3.2'
, 'sig/1.0'
, 'smile/1.47'
, 'squizz/0.99b'
, 'tacg/4.1.0'
, 'taxoptimizer/1.1'
, 'tipdate/1.2'
, 'toppred/1.10'
, 'treealign/NA'
, 'trnascan/1.23'
, 'ViennaRNA/1.8.4'
, 'weighbor/1.2.1'
, 'wise2/2.2.0'
, 'xpound/NA'
, 'xxr/3.03'
]
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment