Skip to content

Commit

Permalink
Add timestamp and fix -f arg
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Oct 20, 2023
1 parent 09658e5 commit ca4b8ae
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions bfabric/scripts/bfabric_feeder_mascot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
2012-10-10 Christian Panse <[email protected]>
2012-10-11 Christian Panse <[email protected]>
2021-01-06 Christian Panse <[email protected]> - replace multiprocess by caching strategy
2023-10-20 Christian Panse <[email protected]> - add timestamp
# Usage
Expand All @@ -31,6 +32,7 @@
import hashlib
import getopt
from suds.client import Client
from datetime import datetime
import json
import itertools
import http.client
Expand All @@ -48,7 +50,11 @@

try:
DB = json.load(open(DBfilename))
print("Read {len} data items from {name} using {size:.1f} GBytes.".format(len=len(DB),
name=DBfilename,
size=sum(map(lambda x: int(x['resource']['size']), DB.values())) / (1024 * 1024 * 1024)))
except:
print("loading '{}' failed".format(DBfilename))
pass


Expand All @@ -69,7 +75,7 @@ def query_mascot_result(f):
regex2 = re.compile(".*.+/(data/.+\.dat)$")
regex2Result = regex2.match(f)
if True:
print("input>")
print("{} input>".format(datetime.now()))
print("\t{}".format(f))
if f in DB:
print("\thit")
Expand Down Expand Up @@ -110,7 +116,7 @@ def query_mascot_result(f):
print("Exception {}".format(ValueError))
raise

print("output>")
print("{} output>".format(datetime.now()))
if 'errorreport' in rv:
print("\tfound errorreport '{}'.".format(rv['errorreport']))

Expand Down Expand Up @@ -180,7 +186,10 @@ def query_mascot_result(f):


def parse_mascot_result_file(f):
print("DEBUG parse_mascot_result_file")

# Getting the current date and time
print("{} DEBUG parse_mascot_result_file".format(datetime.now()))

regex0 = re.compile("^title=.*(p([0-9]+).+Proteomics.*(raw|RAW|wiff)).*")
regex3 = re.compile("^(FILE|COM|release|USERNAME|USERID|TOL|TOLU|ITOL|ITOLU|MODS|IT_MODS|CHARGE|INSTRUMENT|QUANTITATION|DECOY)=(.+)$")

Expand Down Expand Up @@ -239,7 +248,8 @@ def parse_mascot_result_file(f):
)
)
#TODO
print("DEBUG")

print("{}".format(datetime.now()))
print(rv)
print("DEBUG END")

Expand All @@ -255,17 +265,17 @@ def printFrequency(S):
count[x] = 1

for key in sorted(count.keys(), key=lambda key: int(key)):
print(key, count[key])
print("p{}\t{}".format(key, count[key]))


def statistics():
print(len(DB))
print("Statistics ...")
print("len(DB)\t=\t{}".format(len(DB)))
printFrequency(map(lambda x: x['containerid'], DB.values()))
print("{} GBytes".format(sum(map(lambda x: int(x['resource']['size']), DB.values())) / (1024 * 1024 * 1024)))
print("file size\t=\t{} GBytes".format(sum(map(lambda x: int(x['resource']['size']), DB.values())) / (1024 * 1024 * 1024)))

# printFrequency(map(lambda x: x['description'].split(";"), DB.values()))

print(json.dumps(list(DB.values())[100], indent=4))
# print(json.dumps(list(DB.values())[100], indent=4))


if __name__ == "__main__":
Expand All @@ -281,10 +291,10 @@ def statistics():
print("reading file names from stdin ...")
for f in sys.stdin.readlines():
query_mascot_result(f.strip())
elif o == "--file" or o == 'f':
elif o == "--file" or o == '-f':
print("processesing", value, "...")
query_mascot_result(value)
elif o == "--statistics" or o == 's':
elif o == "--statistics" or o == '-s':
statistics()
sys.exit(0)

Expand Down

0 comments on commit ca4b8ae

Please sign in to comment.