From c44ea033649ef5027f3b0ea727c0462468cde25e Mon Sep 17 00:00:00 2001 From: Celine Noirot <celine.noirot@inra.fr> Date: Mon, 27 Feb 2017 17:45:12 +0000 Subject: [PATCH] Get species from swissprot definition Force creation of symbolic link in addinstance. --- workflows/addinstance/__init__.py | 2 +- workflows/rnaseqdenovo/bin/blast2annot.py | 24 ++++++++--------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/workflows/addinstance/__init__.py b/workflows/addinstance/__init__.py index 609c7b8b..803b018e 100644 --- a/workflows/addinstance/__init__.py +++ b/workflows/addinstance/__init__.py @@ -86,7 +86,7 @@ class AddInstance (Workflow): subprocess.check_call( self.get_exec_path("sed") + " -i -e 's,^session\.connection.*,session.connection = jdbc:mysql://{host}:{port}/biomart_sessions?user={user}\&password={passwd},' {propfile}".format( propfile = os.path.join( NGSPIPELINES_DIST, 'biomart.properties'), **ngs_reader.get_database_info() ), shell = True) #create link data - subprocess.check_call( self.get_exec_path("ln") + ' -s ' + os.path.join( instance_directory , 'data') + ' ' + os.path.join( NGSPIPELINES_DIST_PLUGIN, 'ngspipelines', 'public','ngspipelines' ) , shell = True) + subprocess.check_call( self.get_exec_path("ln") + ' -f -s ' + os.path.join( instance_directory , 'data') + ' ' + os.path.join( NGSPIPELINES_DIST_PLUGIN, 'ngspipelines', 'public','ngspipelines' ) , shell = True) if self.instance_url : url = re.sub(r':\d+$', '', re.sub( r'\/$', '', str(self.instance_url))) + ':' + str(self.instance_port) if not url.startswith("http") : diff --git a/workflows/rnaseqdenovo/bin/blast2annot.py b/workflows/rnaseqdenovo/bin/blast2annot.py index 2ea418d9..f61f8351 100755 --- a/workflows/rnaseqdenovo/bin/blast2annot.py +++ b/workflows/rnaseqdenovo/bin/blast2annot.py @@ -62,15 +62,7 @@ def spFromHit( alignment ): @param alignment : [Bio::blast::Record::Alignment] the alignment. """ species = None - # GI - if re.match("gi\|\d+\|[^\|]+\|.+", alignment.hit_id) is not None: - try: - matches = re.search('\[([^\]]+)\]', alignment.hit_def) - species = matches.group(1) - except: # swissprot - pass - # GNL - elif re.match('gnl\|\w+\|\d+', alignment.hit_id) is not None: + if re.match(".*OS=.*", alignment.hit_def) is not None: try: matches = re.search("OS=([^=]+)", alignment.hit_def) if matches is not None: @@ -79,13 +71,13 @@ def spFromHit( alignment ): clean_matches = re.search("(.+) [A-Z][A-Z]$", species) if clean_matches is not None: species = clean_matches.group(1) - else: - matches = re.search('^gi\|\d+\|', alignment.hit_def) - if matches is not None: - cross_references = re.split("gi\|\d+\|", alignment.hit_def ) - matches = re.search( '\[([^\]]+)\][^\[]*$', cross_references[1] ) - species = matches.group(1) - except: # ensembl + except: + pass + else : + try: + matches = re.search('\[([^\]]+)\]', alignment.hit_def) + species = matches.group(1) + except: species = None pass # Others databases are not implemented -- GitLab