-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannlightenment.py
More file actions
67 lines (57 loc) · 2.81 KB
/
Copy pathannlightenment.py
File metadata and controls
67 lines (57 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import argparse
import pywikibot
from annlightenmentlib.bacterialannotationbot import BacterialAnnotationBot
from annlightenmentlib.delete_items import DeleteItems
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--version", "-v", default=False, action="store_true",
help="show version")
subparsers = parser.add_subparsers(help="commands")
upload_parser = subparsers.add_parser("upload", help="subcommand to upload "
"genes, products (proteins, rRNAs, "
"tRNAs, sRNAs), transcripts and sRNA "
"interactions")
upload_parser.add_argument("ANNOgesic_merge_gff", help="the path to the "
"ANNOgesic ...merge_features.gff file")
upload_parser.add_argument("ANNOgesic_merge_csv", help="the path to "
"the ANNOgesic ..._merge.csv file that "
"contains the sRNA interactions")
upload_parser.add_argument("strain_id", help="the ID (Q-number) of the "
"item that describes the strain you are working "
"with")
upload_parser.add_argument("--databank", default = "TillsWiki", help = ""
"the databank you want to use. Chose from Tills"
"Wiki or Wikidata. Default is TillsWiki")
upload_parser.set_defaults(func=upload_items)
delete_parser = subparsers.add_parser("delete", help="subcommand to delete "
"items")
delete_parser.add_argument("path_to_logfile", help="the path to the log "
"file that contains the IDs of the items which "
"should be deleted")
delete_parser.set_defaults(func=delete_items)
args = parser.parse_args()
if args.version is True:
print("ANNlightenment version 0")
elif "func" in dir(args):
args.func(args)
else:
parser.print_help()
def upload_items(args):
site = _return_database_site(args)
BAB = BacterialAnnotationBot(
site, args.ANNOgesic_merge_gff, args.ANNOgesic_merge_csv,
args.strain_id, args.databank)
BAB.all_features()
def _return_database_site(args):
if args.databank == "Wikidata":
print("working with Wikidata")
site = pywikibot.Site("wikidata", "wikidata")
elif args.databank == "TillsWiki":
print("working with TillsWiki")
site = pywikibot.Site("en", "TillsWiki")
return(site)
def delete_items(args):
deletion = DeleteItems(args.path_to_logfile)
id_list_for_deletion = deletion._return_ID_list_for_deletion()
deletion._delete(id_list_for_deletion)
main()