Mercurial > repos > galaxyp > msconvert_win
annotate msconvert_wrapper.py @ 0:f8cf3be564bb draft default tip
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
author | galaxyp |
---|---|
date | Fri, 08 Apr 2016 16:09:02 -0400 |
parents | |
children |
rev | line source |
---|---|
0
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
1 #!/usr/bin/env python |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
2 import optparse |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
3 import os |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
4 import sys |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
5 import tempfile |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
6 import shutil |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
7 import subprocess |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
8 import re |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
9 import logging |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
10 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
11 assert sys.version_info[:2] >= (2, 6) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
12 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
13 log = logging.getLogger(__name__) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
14 working_directory = os.getcwd() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
15 tmp_stderr_name = tempfile.NamedTemporaryFile(dir=working_directory, suffix='.stderr').name |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
16 tmp_stdout_name = tempfile.NamedTemporaryFile(dir=working_directory, suffix='.stdout').name |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
17 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
18 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
19 def stop_err(msg): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
20 sys.stderr.write("%s\n" % msg) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
21 sys.exit() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
22 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
23 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
24 def read_stderr(): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
25 stderr = '' |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
26 if(os.path.exists(tmp_stderr_name)): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
27 with open(tmp_stderr_name, 'rb') as tmp_stderr: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
28 buffsize = 1048576 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
29 try: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
30 while True: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
31 stderr += tmp_stderr.read(buffsize) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
32 if not stderr or len(stderr) % buffsize != 0: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
33 break |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
34 except OverflowError: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
35 pass |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
36 return stderr |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
37 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
38 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
39 def execute(command, stdin=None): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
40 try: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
41 with open(tmp_stderr_name, 'wb') as tmp_stderr: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
42 with open(tmp_stdout_name, 'wb') as tmp_stdout: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
43 proc = subprocess.Popen(args=command, shell=True, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno(), stdin=stdin, env=os.environ) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
44 returncode = proc.wait() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
45 if returncode != 0: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
46 raise Exception("Program returned with non-zero exit code %d. stderr: %s" % (returncode, read_stderr())) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
47 finally: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
48 print(( open(tmp_stderr_name, "r").read() )) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
49 print(( open(tmp_stdout_name, "r").read() )) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
50 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
51 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
52 def delete_file(path): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
53 if os.path.exists(path): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
54 try: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
55 os.remove(path) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
56 except: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
57 pass |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
58 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
59 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
60 def delete_directory(directory): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
61 if os.path.exists(directory): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
62 try: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
63 shutil.rmtree(directory) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
64 except: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
65 pass |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
66 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
67 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
68 def symlink(source, link_name): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
69 import platform |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
70 if platform.system() == 'Windows': |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
71 try: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
72 import win32file |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
73 win32file.CreateSymbolicLink(source, link_name, 1) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
74 except: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
75 shutil.copy(source, link_name) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
76 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
77 os.symlink(source, link_name) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
78 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
79 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
80 def copy_to_working_directory(data_file, relative_path): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
81 if os.path.abspath(data_file) != os.path.abspath(relative_path): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
82 symlink(data_file, relative_path) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
83 return relative_path |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
84 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
85 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
86 def __main__(): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
87 run_script() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
88 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
89 #ENDTEMPLATE |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
90 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
91 to_extensions = ['mzML', 'mzXML', 'unindexed_mzML', 'unindexed_mzXML', 'mgf', 'mz5', 'txt', 'ms2', 'cms2'] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
92 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
93 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
94 def str_to_bool(v): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
95 """ From http://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python """ |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
96 return v.lower() in ["yes", "true", "t", "1"] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
97 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
98 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
99 def _add_filter(filters_file, contents): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
100 filters_file.write("filter=%s\n" % contents) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
101 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
102 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
103 def _skip_line(options, file_num, line_parts): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
104 file_num_column = options.filter_table_file_column |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
105 if not file_num_column: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
106 return False |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
107 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
108 target_file_num_val = str(file_num).strip() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
109 query_file_num_val = line_parts[int(file_num_column) - 1].strip() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
110 #print "target %s, query %s" % (target_file_num_val, query_file_num_val) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
111 return target_file_num_val != query_file_num_val |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
112 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
113 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
114 def _read_table_numbers(path, options, file_num=None): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
115 unique_numbers = set([]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
116 column_num = options.filter_table_column |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
117 input = open(path, "r") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
118 first_line = True |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
119 for line in input: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
120 if not line: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
121 continue |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
122 line = line.strip() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
123 if line.startswith("#"): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
124 first_line = False |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
125 continue |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
126 if column_num == None: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
127 column = line |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
128 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
129 line_parts = line.split("\t") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
130 if _skip_line(options, file_num, line_parts): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
131 continue |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
132 column = line_parts[int(column_num) - 1] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
133 match = re.match("\d+", column) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
134 if match: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
135 unique_numbers.add(int(match.group())) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
136 first_line = False |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
137 return unique_numbers |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
138 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
139 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
140 def shellquote(s): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
141 return '"' + s.replace('"', '\\"') + '"' |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
142 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
143 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
144 def _add_filter_line_from_file(filter_file, options, file_num=None): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
145 file = options.filter_table |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
146 if not file: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
147 return |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
148 numbers = _read_table_numbers(file, options, file_num) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
149 msconvert_int_set = " ".join([str(number) for number in numbers]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
150 filter_type = options.filter_table_type |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
151 if filter_type == 'number': |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
152 filter_prefix = 'scanNumber' |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
153 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
154 filter_prefix = 'index' |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
155 _add_filter(filter_file, "%s %s" % (filter_prefix, msconvert_int_set)) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
156 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
157 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
158 def _create_filters_file(options, file_num=None, debug=False): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
159 suffix = "" if not file_num else str(file_num) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
160 filters_file_path = "filters%s" % suffix |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
161 filters_file = open(filters_file_path, "w") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
162 if options.filters_file: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
163 filters_file.write(open(options.filters_file, "r").read()) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
164 for filter in options.filter: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
165 _add_filter(filters_file, filter) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
166 _add_filter_line_from_file(filters_file, options, file_num=file_num) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
167 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
168 filters_file.close() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
169 if debug: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
170 print(( open(filters_file_path, "r").read() )) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
171 return filters_file_path |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
172 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
173 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
174 def _build_base_cmd(options,args=None): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
175 to_extension = options.toextension |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
176 if to_extension.startswith("unindexed_"): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
177 to_extension = to_extension[len("unindexed_"):] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
178 to_params = "--noindex" |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
179 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
180 to_params = "" |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
181 cmd = "msconvert --%s %s" % (to_extension, to_params) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
182 if args: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
183 cmd = "%s %s" % (cmd, ' '.join(args)) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
184 if str_to_bool(options.zlib): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
185 cmd = "%s %s" % (cmd, "--zlib") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
186 if options.binaryencoding: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
187 cmd = "%s --%s" % (cmd, options.binaryencoding) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
188 if options.mzencoding: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
189 cmd = "%s --mz%s" % (cmd, options.mzencoding) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
190 if options.intensityencoding: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
191 cmd = "%s --inten%s" % (cmd, options.intensityencoding) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
192 return cmd |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
193 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
194 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
195 def _run(base_cmd, output_dir='output', inputs=[], debug=False): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
196 inputs_as_str = " ".join(['%s' % shellquote(input) for input in inputs]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
197 os.mkdir(output_dir) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
198 cmd = "%s -o %s %s" % (base_cmd, shellquote(output_dir), inputs_as_str) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
199 if debug: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
200 print(cmd) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
201 execute(cmd) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
202 output_files = os.listdir(output_dir) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
203 assert len(output_files) == 1 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
204 output_file = output_files[0] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
205 return os.path.join(output_dir, output_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
206 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
207 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
208 def run_script(): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
209 parser = optparse.OptionParser() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
210 parser.add_option('--input', dest='inputs', action='append', default=[]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
211 parser.add_option('--input_name', dest='input_names', action='append', default=[]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
212 parser.add_option('--implicit', dest='implicits', action='append', default=[], help='input files that should NOT be on the msconvert command line.') |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
213 parser.add_option('--ident', dest='idents', action='append', default=[]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
214 parser.add_option('--ident_name', dest='ident_names', action='append', default=[]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
215 parser.add_option('--output', dest='output') |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
216 parser.add_option('--refinement', dest='refinement') |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
217 parser.add_option('--fromextension', dest='fromextension') |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
218 parser.add_option('--toextension', dest='toextension', default='mzML', choices=to_extensions) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
219 parser.add_option('--binaryencoding', dest='binaryencoding', choices=['32', '64']) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
220 parser.add_option('--mzencoding', dest='mzencoding', choices=['32', '64']) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
221 parser.add_option('--intensityencoding', dest='intensityencoding', choices=['32', '64']) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
222 parser.add_option('--zlib', dest='zlib', default="false") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
223 parser.add_option('--filter', dest='filter', action='append', default=[]) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
224 parser.add_option('--filters_file', dest='filters_file', default=None) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
225 parser.add_option('--filter_table', default=None) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
226 parser.add_option('--filter_table_type', default='index', choices=['index', 'number']) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
227 parser.add_option('--filter_table_column', default=None) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
228 parser.add_option('--filter_table_file_column', default=None) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
229 parser.add_option('--debug', dest='debug', action='store_true', default=False) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
230 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
231 (options, args) = parser.parse_args() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
232 if len(options.inputs) < 1: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
233 stop_err("No input files to msconvert specified") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
234 if len(options.input_names) > 0 and len(options.input_names) != len(options.inputs): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
235 stop_err("Number(s) of supplied input names and input files do not match") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
236 if not options.output: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
237 stop_err("Must specify output location") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
238 input_files = [] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
239 for i, input in enumerate(options.inputs): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
240 input_base = None |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
241 if len(options.input_names) > i: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
242 input_base = options.input_names[i] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
243 input_base = input_base.replace("'", "").replace("\"", "") |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
244 print("1- input_base: %s" % input_base) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
245 if not input_base: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
246 input_base = 'input%s' % i |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
247 print("2- input_base: %s" % input_base) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
248 if not input_base.lower().endswith('.%s' % options.fromextension.lower()) and input not in options.implicits: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
249 input_file = '%s.%s' % (input_base, options.fromextension) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
250 print("3- input_base: %s" % input_base) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
251 print("3- input_file: %s" % input_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
252 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
253 input_file = input_base |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
254 print("4- input_base: %s" % input_base) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
255 print("4- input_file: %s" % input_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
256 input_file = input_file |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
257 copy_to_working_directory(input, input_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
258 if input in options.implicits: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
259 continue |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
260 input_files.append(input_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
261 for i, ident in enumerate(options.idents): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
262 ident_file = options.ident_names[i] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
263 copy_to_working_directory(ident, ident_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
264 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
265 cmd = _build_base_cmd(options,args=args) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
266 file_column = options.filter_table_file_column |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
267 if not file_column: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
268 # Apply same filters to all files, just create a unviersal filter files |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
269 # and run msconvert once. |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
270 filters_file_path = _create_filters_file(options, debug=options.debug) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
271 cmd = "%s -c %s" % (cmd, filters_file_path) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
272 else: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
273 # Dispatching on a column to filter different files differently, need to filter |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
274 # each input once with msconvert and then merge once. |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
275 filtered_files = [] |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
276 for index, input_file in enumerate(input_files): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
277 filters_file_path = _create_filters_file(options, index + 1, debug=options.debug) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
278 filter_cmd = "%s -c %s" % (cmd, filters_file_path) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
279 filtered_output_file = _run(filter_cmd, output_dir='output%d' % index, inputs=[input_file], debug=options.debug) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
280 filtered_files.append(filtered_output_file) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
281 input_files = filtered_files |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
282 if len(input_files) > 1: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
283 cmd = "%s --merge" % cmd |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
284 output_file = _run(cmd, output_dir='output', inputs=input_files, debug=options.debug) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
285 shutil.copy(output_file, options.output) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
286 if options.refinement: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
287 # .mzRefinement.tsv |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
288 files = os.listdir(os.getcwd()) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
289 for fname in files: |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
290 if fname.endswith('.mzRefinement.tsv'): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
291 shutil.copy(fname, options.refinement) |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
292 break |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
293 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
294 def __main__(): |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
295 run_script() |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
296 |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
297 if __name__ == '__main__': |
f8cf3be564bb
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit 4fa5bf9c62e4bba06c4d6e7de962c85959b61579-dirty
galaxyp
parents:
diff
changeset
|
298 __main__() |