Skip to content

Commit

Permalink
remove keep raw option.
Browse files Browse the repository at this point in the history
  • Loading branch information
ypriverol committed Sep 4, 2023
1 parent 975a2a7 commit 29947dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
22 changes: 4 additions & 18 deletions sdrf_pipelines/openms/openms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,16 @@ class FileToColumnEntries:
file2technical_rep = {}


def get_openms_file_name(raw, keep_raw: bool, extension_convert: str = None):
def get_openms_file_name(raw, extension_convert: str = None):
"""
Convert file name for OpenMS, for if keep raw is set the same filename will be returned.
- file.raw -> file.raw (keep_raw=True)
- file.raw -> file.mzML (keep_raw=False)
However, if extension_convert is set, the extension will be converted to the specified format.
Convert file name for OpenMS. If extension_convert is set, the extension will be converted to the specified format.
- file.raw -> file.mzML (extension_convert=raw:mzML)
- file.mzML -> file.mzML (extension_convert=mzML:mzML)
- file.mzML -> file.mzml (extension_convert=mzML:mzml)
- file.mzml -> file.mzML (extension_convert=mzml:mzML)
- file.d -> file.mzML (extension_convert=d:mzML)
- file.d -> file.d (extension_convert=d:d)
:param raw: raw file name
:param keep_raw: keep raw file name
:param extension_convert: convert extension to specified format
:return: converted file name
"""
Expand All @@ -56,9 +52,6 @@ def get_openms_file_name(raw, keep_raw: bool, extension_convert: str = None):
)
out = ext[0] + "." + new_extension
return out
if not keep_raw:
ext = os.path.splitext(raw)
out = ext[0] + ".mzML"
else:
out = raw

Expand Down Expand Up @@ -214,7 +207,6 @@ def openms_ify_mods(self, sdrf_mods):
def openms_convert(
self,
sdrf_file: str = None,
keep_raw: bool = False,
one_table: bool = False,
legacy: bool = False,
verbose: bool = False,
Expand Down Expand Up @@ -429,7 +421,6 @@ def openms_convert(
source_name2n_reps,
f2c.file2combined_factors,
f2c.file2label,
keep_raw,
extension_convert,
f2c.file2fraction,
)
Expand All @@ -441,7 +432,6 @@ def openms_convert(
source_name_list,
source_name2n_reps,
f2c.file2label,
keep_raw,
extension_convert,
f2c.file2fraction,
f2c.file2combined_factors,
Expand All @@ -466,7 +456,6 @@ def openms_convert(
source_name2n_reps,
f2c.file2combined_factors,
f2c.file2label,
keep_raw,
extension_convert,
f2c.file2fraction,
)
Expand All @@ -478,7 +467,6 @@ def openms_convert(
source_name_list,
source_name2n_reps,
f2c.file2label,
keep_raw,
extension_convert,
f2c.file2fraction,
f2c.file2combined_factors,
Expand Down Expand Up @@ -530,7 +518,6 @@ def writeTwoTableExperimentalDesign(
source_name_list,
source_name2n_reps,
file2label,
keep_raw,
extension_convert,
file2fraction,
file2combined_factors,
Expand Down Expand Up @@ -628,7 +615,7 @@ def writeTwoTableExperimentalDesign(
else:
label = str(self.itraq4plex[label[label_index[raw]].lower()])
label_index[raw] = label_index[raw] + 1
out = get_openms_file_name(raw, keep_raw, extension_convert)
out = get_openms_file_name(raw, extension_convert)

f.write(
str(Fraction_group[raw])
Expand Down Expand Up @@ -718,7 +705,6 @@ def writeOneTableExperimentalDesign(
source_name2n_reps,
file2combined_factors,
file2label,
keep_raw,
extension_convert,
file2fraction,
):
Expand Down Expand Up @@ -884,7 +870,7 @@ def writeOneTableExperimentalDesign(
label = str(self.itraq4plex[label[label_index[raw]].lower()])
label_index[raw] = label_index[raw] + 1

out = get_openms_file_name(raw, keep_raw, extension_convert)
out = get_openms_file_name(raw, extension_convert)

if "MSstats_Mixture" in open_ms_experimental_design_header:
if raw not in mixture_raw_tag.keys():
Expand Down
26 changes: 11 additions & 15 deletions sdrf_pipelines/parse_sdrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,21 @@ def cli():

@click.command("convert-openms", short_help="convert sdrf to openms file output")
@click.option("--sdrf", "-s", help="SDRF file")
@click.option("--raw", "-r", help="Keep filenames in experimental design output as raw.", is_flag=True)
@click.option(
"--legacy/--modern", "-l/-m", default=False, help="legacy=Create artificial sample column not needed in OpenMS 2.6."
)
@click.option("--onetable/--twotables", "-t1/-t2", default=False, help="Create one-table or two-tables format.")
@click.option("--verbose/--quiet", "-v/-q", default=False, help="Output debug information.")
@click.option("--conditionsfromcolumns", "-c", help="Create conditions from provided (e.g., factor) columns.")
@click.option(
"--extension_convert",
"-e",
help="convert extensions of files from one type to other 'raw:mzML,mzml:MZML,mzML:mzML,d:d'",
@click.option("--legacy/--modern", "-l/-m", default=False,
help="legacy=Create artificial sample column not needed in OpenMS 2.6.")
@click.option("--onetable/--twotables", "-t1/-t2",
help="Create one-table or two-tables format.", default=False )
@click.option("--verbose/--quiet", "-v/-q",
help="Output debug information.", default=False)
@click.option("--conditionsfromcolumns", "-c",
help="Create conditions from provided (e.g., factor) columns.")
@click.option("--extension_convert","-e",
help="convert extensions of files from one type to other 'raw:mzML,mzml:MZML,mzML:mzML,d:d'",
)
@click.pass_context
def openms_from_sdrf(
ctx,
sdrf: str,
raw: bool,
onetable: bool,
legacy: bool,
verbose: bool,
Expand All @@ -58,10 +56,8 @@ def openms_from_sdrf(
):
if sdrf is None:
help()
if extension_convert is not None and raw:
logging.info("The raw option (keeping file names) is overwritten by the extension_convert option.")
try:
OpenMS().openms_convert(sdrf, raw, onetable, legacy, verbose, conditionsfromcolumns, extension_convert)
OpenMS().openms_convert(sdrf, onetable, legacy, verbose, conditionsfromcolumns, extension_convert)
except Exception as ex:
print("Error: " + str(ex))

Expand Down

0 comments on commit 29947dd

Please sign in to comment.