Commit e160add2 authored by Rudel Fankep's avatar Rudel Fankep
Browse files

parser delete

parent 186b43e8
......@@ -3,7 +3,6 @@
DOWNLOAD_DIR=$1
cd $DOWNLOAD_DIR
makeblastdb -dbtype prot -in ../dbx/uniprot_sprot.fasta
makeblastdb -dbtype prot -in uniprot_sprot.fasta
tar -czf sp_blast.tar.gz uniprot_sprot.*
rm uniprot_sprot*
cd -
\ No newline at end of file
#!/bin/bash
database=$1
file=$2
cd $file
rm $database*
cd -
\ No newline at end of file
File mode changed from 100644 to 100755
#!/bin/bash
mkdir -p output
\ No newline at end of file
#!/home/theia/conda/bin/python
import argparse
import subprocess
import os
data = {'swissprot': {'prepare': './prepare_swissprot.sh',
'tool': {'blast': './blast_swissprot.sh', 'ghostx': './ghostx_swissprot.sh'},
'filename': 'uniprot_sprot.fasta'
},
'pfam': {'prepare': './prepare_pfam.sh',
'tool': {'hmmer': './hmmer_pfam.sh'},
'filename': 'Pfam-A.hmm'
},
'card': {
}
}
data={'swissprot':{'download':'./download_swissprot.sh','blast':'./blast_swissprot.sh','ghostx':'./ghostx_swissprot.sh'},'pfam':{'download':'./download_pfam.sh'}}
def myparser():
parser=argparse.ArgumentParser(description='Download, convert and share the data to working computer',prog='PSOT_database_maker')
parser = argparse.ArgumentParser(description='Download, convert and share the data to working computer', prog='PSOT_database_maker')
subparsers=parser.add_subparsers(title='Subcommands',description='Authorized Subcommands',help='Additional help')
subparsers = parser.add_subparsers(title='Subcommands', description='Authorized Subcommands', help='Additional help')
prepare_parser=subparsers.add_parser('prepare',help='Databank download from the Website, extraction and transformation for another Programm')
prepare_parser.add_argument('database',help='Database which have to be prepared',type=str)
prepare_parser.add_argument('-t','--tool',help='Programm/Tool for the post analysis',type=str,)
prepare_parser.add_argument('-o','--output',default='./output',help='target directory for the output.Default will be a created("output") folder in the working directory',type=str)
prepare_parser = subparsers.add_parser('prepare', help='Databank download from the Website, extraction and transformation for another Programm')
prepare_parser.add_argument('database', help='Database which have to be prepared', type=str)
prepare_parser.add_argument('tool',help='Programm/Tool for the post analysis',type=str,)
prepare_parser.add_argument('-d', '--directory', dest='dir', help='target directory for the output.Default will be a created("output") folder in the working directory', type=str)
prepare_parser.set_defaults(func=prepare)
upload_parser=subparsers.add_parser('upload',help='Databank copy from the local directory to the web storage')
upload_parser.add_argument('file',help='File to be transfered from the local directory',type=str)
upload_parser.add_argument('-d','--directory',default='s3://db_storage',help='Target directory for the file transfer into "S3". Default will be "s3://db_storage"',type=str)
upload_parser = subparsers.add_parser('upload', help='Databank copy from the local directory to the web storage')
upload_parser.add_argument('file', help='File to be transfered from the local directory', type=str)
upload_parser.add_argument('-d', '--directory', dest='dir', help='Target directory for the file transfer into "S3". Default will be "s3://db_storage"', type=str)
upload_parser.set_defaults(func=upload)
download_parser=subparsers.add_parser('download',help='Datenbank copy from the web storage to the working computer')
download_parser.add_argument('file',help='File to be transfered from "S3"',type=str)
download_parser.add_argument('-d','--directory',default='./output',help='Target directory for the file transfer. Default will be a created folder("output) in the current working directory',type=str)
download_parser = subparsers.add_parser('download', help='Datenbank copy from the web storage to the working computer')
download_parser.add_argument('file', help='File to be transfered from "S3"', type=str)
download_parser.add_argument('-d', '--directory', dest='dir', help='Target directory for the file transfer. Default will be a created folder("output) in the current working directory',type=str)
download_parser.set_defaults(func=download)
delete_parser = subparsers.add_parser('delete', help='delete existing files from local directory or from "S3"')
delete_parser.add_argument('database', help = 'database which have to be delete')
delete_parser.add_argument('place', choices = ['local','S3'], help = 'defined the place where the database have to be delete')
delete_parser.add_argument('-d', '--directory', dest='dir', help='directory where the database have to be delete')
delete_parser.set_defaults(func=delete)
return parser.parse_args()
def prepare(args):
file_down=subprocess.run([data[args.database]['download'],args.output])
if args.tool:
file_tool=subprocess.run([data[args.database][args.tool],args.output])
def upload(args):
def targetdir_maker(args):
databasedir = "./output"
if args.dir:
databasedir = args.output
elif "dbman_dbdir" in os.environ:
databasedir = os.environ["dbman_dbdir"]
return databasedir
# paste the target directory with the filename.(will be important to test if the file is already there. "/" or not)
file_up=subprocess.run(['./upload_db.sh',args.file,args.directory])
def filedir_maker(directory, file):
filedir = ''
if directory[-1] == '/':
filedir = directory+file
else:
filedir = directory+'/'+file
return filedir
def prepare(args):
dbman_dir = targetdir_maker(args)
testfile = filedir_maker(dbman_dir, data[args.database]['filename'])
print(testfile)
if not os.path.isfile(testfile):
subprocess.run([data[args.database]['prepare'], dbman_dir])
subprocess.run([data[args.database]['tool'][args.tool], dbman_dir])
print("The {} file is in: ".format(args.database) + dbman_dir)
else:
print('The {} file already exists in :'.format(args.database) + dbman_dir)
def upload(args):
dbman_dir = targetdir_maker(args)
subprocess.run(['./upload_db.sh', args.file, dbman_dir])
def download(args):
dbman_dir = targetdir_maker(args)
subprocess.run(['./download_db.sh', args.file,dbman_dir])
file_down=subprocess.run(['./download_db.sh',args.file,args.directory])
def delete(args):
if args.place == 'local':
dbman_dir = targetdir_maker(args)
testfile = filedir_maker(dbman_dir, data[args.database]['filename'])
if os.path.isfile(testfile):
subprocess.run(['./delete_db.sh',data[args.database]['filename'],dbman_dir])
print("The {} files were successfully delete in: ".format(args.database) + dbman_dir)
else:
print("The {} files aren't existing in: ".format(args.database) + dbman_dir)
else:
print('Skript für S3 noch nicht fertig')
def main():
if not os.path.isdir('output'):
os.mkdir('output')
subprocess.run(['./make_directory.sh'])
args=myparser()
args.func(args)
......
This diff is collapsed.
......@@ -36,3 +36,54 @@ Beispieldatenbanken:
Evtl. kann auch biomaj für das Problem genutzt werden: https://biomaj.genouest.org/
#####sudo apt-get install ncbi-blast+######
Beispielaufrufe:
upload only name write. ort soll bekannt sein
entpacken beim download (tar xzf)
# Vorher: In dem Datenbankverzeichnis liegt keine swiss-prot Datenbank fuer ghostx
dbman prepare "UniprotKB/swiss-prot" "ghostx"
-> Ergebnis: In dem Datenbankvorbereitungsverzeichnis liegt die ghostx Datenbank. die datenbank kann benutzt werden
# Vorher In dem Datenbankverzeichnis liegt die swiss-prot Datenbank fuer ghostx
dbman upload "UniprotKB/swiss-prot" "ghostx"
-> Ergebnis: Im S3 liegt die komprimierte swiss-prot Datenbank für ghostx
# Vorher: Im S3 liegt die komprimierte swiss-prot Datenbank für ghostx
dbman download "UniprotKB/swiss-prot" "ghostx"
-> Ergebnis: In dem Datenbankvorbereitungsverzeichnis liegt die ghostx Datenbank. datenbank nutzbar
# Vorher: In dem Datenbankvorbereitungsverzeichnis liegt die ghostx Datenbank
dbman location "UniprotKB/swiss-prot" "ghostx"
-> Ergebnis: Pfad der swiss-prot Datenbank fuer ghostx
# Vorher: Egal
dbman list database recipes
-> Ergebnis:
swiss-prot[ghostx]
swiss-prot[blastp]
pfam[hmmer]
# Vorher: Datenbank sind lokal vorhanden
dbman list local databases
->Ergebnis:
swiss-prot[ghostx] version: x.y.z erstellt am: <datum>
swiss-prot[blastp] version: x.y.z erstellt am: <datum>
dbman list remote databases
->Ergebnis:
swiss-prot[ghostx] version: x.y.z erstellt am: <datum>
swiss-prot[blastp] version: x.y.z erstellt am: <datum>
pfam[hmmer] version: x.y.z erstellt am: <datum>
default='s3://db_storage'
ordner mit entsprechende namen!!!!
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