def main(argv):
    parser = argparse.ArgumentParser(
        description=
        'add_primer_to_annotations.py version %s\nupdate the primer region on the dbbact annotations'
        % __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--log-level',
                        help='output level (1 verbose, 10 error)',
                        type=int,
                        default=3)
    parser.add_argument(
        '--all',
        help=
        'update all annotations (if not specified, update only annotations with na in primer)',
        action='store_true')

    args = parser.parse_args(argv)
    SetDebugLevel(args.log_level)
    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)
    add_primer_to_annotations(con, cur, update_all=args.all)
예제 #2
0
def main(argv):
    parser = argparse.ArgumentParser(
        description=
        'Add annotation/experiment counts to all dbbact sequences. version ' +
        __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--proc-title',
                        help='name of the process (to view in ps aux)')
    parser.add_argument('--debug-level',
                        help='debug level (1 for debug ... 9 for critical)',
                        default=2,
                        type=int)
    args = parser.parse_args(argv)

    SetDebugLevel(args.debug_level)
    # set the process name for ps aux
    if args.proc_title:
        setproctitle.setproctitle(args.proc_title)

    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)
    add_seq_counts(con, cur)
예제 #3
0
def main(argv):
    parser = argparse.ArgumentParser(
        description='Add the number of sequences per annotation. version ' +
        __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--debug-level',
                        help='debug level (1 for debug ... 9 for critical)',
                        default=2,
                        type=int)
    args = parser.parse_args(argv)

    SetDebugLevel(args.debug_level)

    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)
    add_annotation_seq_count(con, cur)
예제 #4
0
def om_cmd(ctx, database, port, host, user, password, debug_level, log_file, dry_run):
	con, cur = db_access.connect_db(database=database, user=user, password=password, port=port, host=host)
	ctx.obj = {}
	ctx.obj['con'] = con
	ctx.obj['cur'] = cur
	ctx.obj['debug_level'] = debug_level
	ctx.obj['log_file'] = log_file
	ctx.obj['commit'] = not dry_run
	SetDebugLevel(debug_level)
예제 #5
0
def main(argv):
	parser = argparse.ArgumentParser(description='delete_annotations version %s\ndelete sequences not in any annotation' % __version__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
	parser.add_argument('--port', help='postgres port', default=5432, type=int)
	parser.add_argument('--host', help='postgres host', default=None)
	parser.add_argument('--database', help='postgres database', default='dbbact')
	parser.add_argument('--user', help='postgres user', default='dbbact')
	parser.add_argument('--password', help='postgres password', default='magNiv')
	parser.add_argument('--annotationids', help='list of annotation ids to delete (space separated)', nargs='+', type=int)
	parser.add_argument('--expids', help='list of experiment ids to delete (space separated)', nargs='+', type=int)
	parser.add_argument('--delete', help='delete the sequences', action='store_true')
	parser.add_argument('--noseq', help='delete only annotations where all sequences do not start with noseq (i.e. acgt to not delete v4)')
	parser.add_argument('--log-level', help='output level (1 verbose, 10 error)', type=int, default=3)

	args = parser.parse_args(argv)
	SetDebugLevel(args.log_level)
	con, cur = db_access.connect_db(database=args.database, user=args.user, password=args.password, port=args.port, host=args.host)

	annotationids = []
	# fill the annotations from each experiment
	if args.expids:
		for cexpid in args.expids:
			cur.execute("SELECT id from AnnotationsTable WHERE idexp=%s", [cexpid])
			for cres in cur:
				annotationids.append(cres[0])
		debug(3, 'found %d annotations for the experiments' % len(annotationids))
	# and add the annotation ids supplied
	if args.annotationids is not None:
		annotationids.extend(args.annotationids)

	for cannotationid in annotationids:
		# test if all sequences of the annotation don't start with sequence notseq
		if args.noseq is not None:
			cur2 = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
			noseq = args.noseq
			badseqs = 0
			cur.execute("SELECT seqid FROM SequencesAnnotationTable WHERE annotationid=%s", [cannotationid])
			for cres in cur:
				cseqid = cres[0]
				cur2.execute("SELECT sequence FROM SequencesTable WHERE id=%s", [cseqid])
				res = cur2.fetchone()[0]
				if res[:len(noseq)] == noseq:
					badseqs += 1
			if badseqs > 0:
				debug(5, "Annotation %d contains %d sequences starting with the noseq sequenece %s. not deleting" % (cannotationid, badseqs, noseq))
				continue

		# get the user that created the annotation
		cur.execute("SELECT iduser FROM AnnotationsTable WHERE id=%s LIMIT 1", [cannotationid])
		res = cur.fetchone()
		cuserid = res['iduser']
		# and delete
		delete_annotation(con, cur, annotationid=cannotationid, userid=cuserid, delete=args.delete)

	debug(3, 'committing')
	con.commit()
	debug(3, 'done. please run delete_unused_seqs.py to remove unused sequences')
예제 #6
0
def main(argv):
	parser = argparse.ArgumentParser(description='run_bg_jobs version %s.' % __version__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
	parser.add_argument('--port', help='postgres port', default=5432, type=int)
	parser.add_argument('--host', help='postgres host', default=None)
	parser.add_argument('--database', help='postgres database (overrides value from server-type)')
	parser.add_argument('--user', help='postgres user (overrides value from server-type)')
	parser.add_argument('--password', help='postgres password (overrides value from server-type)')
	parser.add_argument('--server-type', help='dbbact rest api server type (main/develop/test)', default='main')
	parser.add_argument('-o', '--output-dir', help='output directory for the log files')
	parser.add_argument('--debug-level', help='debug level (1 for debug ... 9 for critical)', default=2, type=int)
	parser.add_argument('--single-update', help='update once and quit', action='store_true')
	parser.add_argument('-p', '--command-params', help='specific command parameters. command and parameter name separated by : (i.e. update_silva:wholeseq-file:SILVA.fa). can use flag more than once', action='append')
	args = parser.parse_args(argv)

	SetDebugLevel(args.debug_level)
	server_type = args.server_type
	database = args.database
	user = args.user
	password = args.password
	proc_title = 'dbbact run_bg_jobs.py'
	if server_type == 'main':
		proc_title += ' [main]'
		if database is None:
			database = 'dbbact'
		if user is None:
			user = '******'
		if password is None:
			password = '******'
	elif server_type == 'develop':
		proc_title += ' [develop]'
		if database is None:
			database = 'dbbact_develop'
		if user is None:
			user = '******'
		if password is None:
			password = '******'
	elif server_type == 'test':
		proc_title += ' [test]'
		if database is None:
			database = 'dbbact'
		if user is None:
			user = '******'
		if password is None:
			password = '******'
	elif server_type is None:
		pass
	else:
		raise ValueError('unknown server-type. should be one of ("main" / "develop" / "test"')

	setproctitle.setproctitle(proc_title + ' [master]')
	run_bg_jobs(port=args.port, host=args.host, database=database, user=user, password=password, single_update=args.single_update, command_params=args.command_params, debug_level=args.debug_level, output_dir=args.output_dir, proc_title=proc_title)
def main(argv):
	parser = argparse.ArgumentParser(description='Prepare dbBact-calour term pickle files for autocomplete. version ' + __version__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
	parser.add_argument('--port', help='postgres port', default=5432, type=int)
	parser.add_argument('--host', help='postgres host', default=None)
	parser.add_argument('--database', help='postgres database', default='dbbact_develop')
	parser.add_argument('--user', help='postgres user', default='dbbact_develop')
	parser.add_argument('--password', help='postgres password', default='dbbact_develop')
	parser.add_argument('--debug-level', help='debug level (1 for debug ... 9 for critical)', default=4, type=int)
	args = parser.parse_args(argv)

	SetDebugLevel(args.debug_level)

	con, cur = db_access.connect_db(database=args.database, user=args.user, password=args.password, port=args.port, host=args.host)
	prepare_dbbact_calour_term_files(con, cur)
예제 #8
0
def main(argv):
	parser = argparse.ArgumentParser(description='Update the OntologyTreeStructureTable to fix the old na root term (which was undefined as contained many optional NAs). version ' + __version__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
	parser.add_argument('--port', help='postgres port', default=5432, type=int)
	parser.add_argument('--host', help='postgres host', default=None)
	parser.add_argument('--database', help='postgres database', default='dbbact')
	parser.add_argument('--user', help='postgres user', default='dbbact')
	parser.add_argument('--password', help='postgres password', default='magNiv')
	parser.add_argument('--debug-level', help='debug level (1 for debug ... 9 for critical)', default=2, type=int)
	parser.add_argument('--dry-run', help='do not commit', action='store_true')
	args = parser.parse_args(argv)

	SetDebugLevel(args.debug_level)

	con, cur = db_access.connect_db(database=args.database, user=args.user, password=args.password, port=args.port, host=args.host)
	fix_na(con, cur, commit=not args.dry_run)
예제 #9
0
def main(argv):
    parser = argparse.ArgumentParser(
        description=
        'Replace obsoloete ontology terms after running add_ontology. version '
        + __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('-i',
                        '--input',
                        help='ontology file name (.obo) to update with')
    parser.add_argument(
        '--ontology',
        help=
        'ontology database name (i.e. "envo"). if provided, only update terms not appearing in other ontologies',
        default=None)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--proc-title',
                        help='name of the process (to view in ps aux)')
    parser.add_argument('--debug-level',
                        help='debug level (1 for debug ... 9 for critical)',
                        default=2,
                        type=int)
    args = parser.parse_args(argv)

    SetDebugLevel(args.debug_level)
    # set the process name for ps aux
    if args.proc_title:
        setproctitle.setproctitle(args.proc_title)

    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)
    update_obsolete_terms(con,
                          cur,
                          ontofilename=args.input,
                          ontology_name=args.ontology)
예제 #10
0
def main(argv):
    parser = argparse.ArgumentParser(
        description=
        'Update the AnnotationParentsTable after changing ontologies. version '
        + __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--proc-title',
                        help='name of the process (to view in ps aux)')
    parser.add_argument('--debug-level',
                        help='debug level (1 for debug ... 9 for critical)',
                        default=2,
                        type=int)
    parser.add_argument(
        '--ontology',
        help='ontology to update parents for (empty to update all')
    parser.add_argument(
        '--redo-all',
        help='if set, recalculate for all ontologies/terms (slower)',
        action='store_true')
    args = parser.parse_args(argv)

    SetDebugLevel(args.debug_level)
    # set the process name for ps aux
    if args.proc_title:
        setproctitle.setproctitle(args.proc_title)

    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)
    if args.redo_all:
        update_ontology_parents_overwrite(con, cur)
    else:
        update_ontology_parents(con, cur, ontology=args.ontology)
예제 #11
0
def main(argv):
	parser = argparse.ArgumentParser(description='Delete dbbact terms not used in annotations or tree structure. version ' + __version__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
	parser.add_argument('--port', help='postgres port', default=5432, type=int)
	parser.add_argument('--host', help='postgres host', default=None)
	parser.add_argument('--database', help='postgres database', default='dbbact')
	parser.add_argument('--user', help='postgres user', default='dbbact')
	parser.add_argument('--password', help='postgres password', default='magNiv')
	parser.add_argument('--proc-title', help='name of the process (to view in ps aux)')
	parser.add_argument('--delete', help='MUST provide this in order to actually delete', action='store_true')
	parser.add_argument('--debug-level', help='debug level (1 for debug ... 9 for critical)', default=2, type=int)
	args = parser.parse_args(argv)

	SetDebugLevel(args.debug_level)
	# set the process name for ps aux
	if args.proc_title:
		setproctitle.setproctitle(args.proc_title)

	con, cur = db_access.connect_db(database=args.database, user=args.user, password=args.password, port=args.port, host=args.host)
	delete_unused_terms(con, cur, commit=args.delete)
예제 #12
0
def main(argv):
    parser = argparse.ArgumentParser(
        description=
        'update_sequence_primer.py version %s\nupdate the sequence primer (merge if needed)'
        % __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--old-primer',
                        help='the primerid of sequences to update',
                        type=int,
                        default=2)
    parser.add_argument('--new-primer',
                        help='the primerid to update to',
                        type=int,
                        default=1)
    parser.add_argument('--log-level',
                        help='output level (1 verbose, 10 error)',
                        type=int,
                        default=3)
    parser.add_argument('--delete',
                        help='delete the sequences',
                        action='store_true')

    args = parser.parse_args(argv)
    SetDebugLevel(args.log_level)
    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)
    update_old_primer_seqs(con,
                           cur,
                           old_primer=args.old_primer,
                           new_primer=args.new_primer,
                           commit=args.delete)
예제 #13
0
def main(argv):
    parser = argparse.ArgumentParser(
        description='update_seq_hash version %s' % __version__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', help='postgres port', default=5432, type=int)
    parser.add_argument('--host', help='postgres host', default=None)
    parser.add_argument('--database',
                        help='postgres database',
                        default='dbbact')
    parser.add_argument('--user', help='postgres user', default='dbbact')
    parser.add_argument('--password',
                        help='postgres password',
                        default='magNiv')
    parser.add_argument('--proc-title',
                        help='name of the process (to view in ps aux)')
    parser.add_argument('--debug-level',
                        help='debug level (1 for debug ... 9 for critical)',
                        default=2,
                        type=int)

    parser.add_argument('--rdp',
                        help='location of the rdp binary dir',
                        default='rdp_classifier_2.12/')
    args = parser.parse_args(argv)

    SetDebugLevel(args.debug_level)

    # set the process name for ps aux
    if args.proc_title:
        setproctitle.setproctitle(args.proc_title)

    # get the database connection
    con, cur = db_access.connect_db(database=args.database,
                                    user=args.user,
                                    password=args.password,
                                    port=args.port,
                                    host=args.host)

    update_seq_taxonomy(con, cur, rdp=args.rdp)
예제 #14
0
		if password is None:
			password = '******'
	elif server_type == 'develop':
		proc_title += ' [develop]'
		if database is None:
			database = 'dbbact_develop'
		if user is None:
			user = '******'
		if password is None:
			password = '******'
	elif server_type == 'test':
		proc_title += ' [test]'
		if database is None:
			database = 'dbbact'
		if user is None:
			user = '******'
		if password is None:
			password = '******'
	elif server_type is None:
		pass
	else:
		raise ValueError('unknown server-type. should be one of ("main" / "develop" / "test"')

	setproctitle.setproctitle(proc_title + ' [master]')
	run_bg_jobs(port=args.port, host=args.host, database=database, user=user, password=password, single_update=args.single_update, command_params=args.command_params, debug_level=args.debug_level, output_dir=args.output_dir, proc_title=proc_title)


if __name__ == "__main__":
	SetDebugLevel(1)
	main(sys.argv[1:])