diff --git a/image_ref/config.py b/image_ref/config.py index 2d713c206a388e8020d7b982c73329616c7e152f..4f5fb2143771a191183409392a3769b9a166e32d 100644 --- a/image_ref/config.py +++ b/image_ref/config.py @@ -19,6 +19,7 @@ def load_args_contrastive(): parser.add_argument('--output', type=str, default='output/out_contrastive.csv') parser.add_argument('--save_path', type=str, default='output/best_model_constrastive.pt') parser.add_argument('--pretrain_path', type=str, default=None) + parser.add_argument('--wandb', type=str, default=None) args = parser.parse_args() return args \ No newline at end of file diff --git a/image_ref/main.py b/image_ref/main.py index ba2bb9f9ffa7d99b01731d97a4c1bea71e253e6d..8b261469b2c9d34e5bb29b2d4866c41900c2abca 100644 --- a/image_ref/main.py +++ b/image_ref/main.py @@ -1,3 +1,5 @@ +import os +import wandb as wdb import matplotlib.pyplot as plt import numpy as np @@ -11,7 +13,7 @@ from sklearn.metrics import confusion_matrix import seaborn as sn import pandas as pd -def train_duo(model, data_train, optimizer, loss_function, epoch): +def train_duo(model, data_train, optimizer, loss_function, epoch, wandb): model.train() losses = 0. acc = 0. @@ -36,9 +38,14 @@ def train_duo(model, data_train, optimizer, loss_function, epoch): losses = losses/len(data_train.dataset) acc = acc/len(data_train.dataset) print('Train epoch {}, loss : {:.3f} acc : {:.3f}'.format(epoch,losses,acc)) + + if wandb is not None: + wdb.log({"train loss": losses, 'train epoch': epoch, "train contrastive accuracy": acc }) + + return losses, acc -def test_duo(model, data_test, loss_function, epoch): +def test_duo(model, data_test, loss_function, epoch, wandb): model.eval() losses = 0. acc = 0. @@ -69,9 +76,23 @@ def test_duo(model, data_test, loss_function, epoch): acc = acc/(len(data_test.dataset)) acc_contrastive = acc_contrastive /(label.shape[0]*len(data_test.dataset)) print('Test epoch {}, loss : {:.3f} acc : {:.3f} acc contrastive : {:.3f}'.format(epoch,losses,acc,acc_contrastive)) + + if wandb is not None: + wdb.log({"validation loss": losses, 'validation epoch': epoch, "validation classification accuracy": acc, "validation contrastive accuracy" : acc_contrastive }) + return losses,acc,acc_contrastive def run_duo(args): + + #wandb init + if args.wandb is not None: + os.environ["WANDB_API_KEY"] = 'b4a27ac6b6145e1a5d0ee7f9e2e8c20bd101dccd' + + os.environ["WANDB_MODE"] = "offline" + os.environ["WANDB_DIR"] = os.path.abspath("./wandb_run") + + wdb.init(project="Intensity prediction", dir='./wandb_run', name=args.wandb) + #load data data_train, data_test_batch = load_data_duo(base_dir_train=args.dataset_train_dir, base_dir_test=args.dataset_val_dir, batch_size=args.batch_size, ref_dir=args.dataset_ref_dir, positive_prop=args.positive_prop, sampler=args.sampler) @@ -100,11 +121,11 @@ def run_duo(args): optimizer = optim.SGD(model.parameters(), lr=0.001, momentum=0.9) #train model for e in range(args.epoches): - loss, acc = train_duo(model,data_train,optimizer,loss_function,e) + loss, acc = train_duo(model,data_train,optimizer,loss_function,e,args.wandb) train_loss.append(loss) train_acc.append(acc) if e%args.eval_inter==0 : - loss, acc, acc_contrastive = test_duo(model,data_test_batch,loss_function,e) + loss, acc, acc_contrastive = test_duo(model,data_test_batch,loss_function,e,args.wandb) val_loss.append(loss) val_acc.append(acc) val_cont_acc.append(acc_contrastive) @@ -112,36 +133,40 @@ def run_duo(args): save_model(model,args.save_path) best_loss = loss # plot and save training figs - plt.clf() - plt.subplot(2, 1, 1) - plt.plot(train_acc, label='train cont acc') - plt.plot(val_cont_acc, label='val cont acc') - plt.plot(val_acc, label='val classification acc') - plt.title('Train and validation accuracy') - plt.xlabel('epoch') - plt.ylabel('accuracy') - plt.legend(loc="upper left") - plt.ylim(0, 1.05) - plt.tight_layout() - - plt.subplot(2, 1, 2) - plt.plot(train_loss, label='train') - plt.plot(val_loss, label='val') - plt.title('Train and validation loss') - plt.xlabel('epoch') - plt.ylabel('loss') - plt.legend(loc="upper left") - plt.tight_layout() - - - plt.show() - plt.savefig('output/training_plot_contrastive_{}.png'.format(args.positive_prop)) + if args.wandb is None: + + plt.clf() + plt.subplot(2, 1, 1) + plt.plot(train_acc, label='train cont acc') + plt.plot(val_cont_acc, label='val cont acc') + plt.plot(val_acc, label='val classification acc') + plt.title('Train and validation accuracy') + plt.xlabel('epoch') + plt.ylabel('accuracy') + plt.legend(loc="upper left") + plt.ylim(0, 1.05) + plt.tight_layout() + + plt.subplot(2, 1, 2) + plt.plot(train_loss, label='train') + plt.plot(val_loss, label='val') + plt.title('Train and validation loss') + plt.xlabel('epoch') + plt.ylabel('loss') + plt.legend(loc="upper left") + plt.tight_layout() + + plt.show() + plt.savefig('output/training_plot_contrastive_{}.png'.format(args.positive_prop)) #load and evaluate best model load_model(model, args.save_path) make_prediction_duo(model,data_test_batch, 'output/confusion_matrix_contractive_{}_bis.png'.format(args.positive_prop), 'output/confidence_matrix_contractive_{}_bis.png'.format(args.positive_prop)) + if args.wandb is not None: + wdb.finish() + def make_prediction_duo(model, data, f_name, f_name2): for imaer, imana, img_ref, label in data: diff --git a/pyRawMSDataReader/.gitignore b/pyRawMSDataReader/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4751247be226f4eb6fd1403a2e446768f31a0be2 --- /dev/null +++ b/pyRawMSDataReader/.gitignore @@ -0,0 +1,17 @@ +*.db +*.opendb +*.pyd +*.zip +*.c +*.nogit +*.mgf +*.speclib.txt + +**/cython/**/*.c +**/cython/test/* +**/__pycache__/* +**/build/* +**/dist/* +**/*.egg-info/* +**/.DS_Store +.vscode/* diff --git a/pyRawMSDataReader/DLLs/Clearcore.Licensing.dll b/pyRawMSDataReader/DLLs/Clearcore.Licensing.dll new file mode 100644 index 0000000000000000000000000000000000000000..294e35cf24e2eba3c0f390b36394e7f94e6d867c Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore.Licensing.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Compression.dll b/pyRawMSDataReader/DLLs/Clearcore2.Compression.dll new file mode 100644 index 0000000000000000000000000000000000000000..ed063c02e420f5dbfdad0b07487fbace1a7f5ba6 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Compression.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Acquisition.Client.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Acquisition.Client.dll new file mode 100644 index 0000000000000000000000000000000000000000..5e04040cc5faa4c94b49d0b73c2dda86c3ce0548 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Acquisition.Client.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Acquisition.Contracts.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Acquisition.Contracts.dll new file mode 100644 index 0000000000000000000000000000000000000000..79f3ebbbb4cb28a2d92cb10ab5b3e7ac424e846c Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Acquisition.Contracts.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.AnalystDataProvider.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.AnalystDataProvider.dll new file mode 100644 index 0000000000000000000000000000000000000000..3627f8a4300ac43fc016cfe23f7aa84092612736 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.AnalystDataProvider.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Client.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Client.dll new file mode 100644 index 0000000000000000000000000000000000000000..8c56397faab1c2f1152d58ddeb1eefc69f735857 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Client.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Common.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Common.dll new file mode 100644 index 0000000000000000000000000000000000000000..ee5bdca578517ae3caa5b91632031663f0cc063f Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Common.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.CommonInterfaces.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.CommonInterfaces.dll new file mode 100644 index 0000000000000000000000000000000000000000..aa75a664d3d0e91c1819eb5f774c9690ac7c83c1 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.CommonInterfaces.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Contracts.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Contracts.dll new file mode 100644 index 0000000000000000000000000000000000000000..15c886272ca49f2d66b5c1eb5fcb48604d8c8312 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Contracts.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Core.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Core.dll new file mode 100644 index 0000000000000000000000000000000000000000..734bee3b637b7e617c5c7c0028ce891863acb4bd Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Core.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.Wiff2.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.Wiff2.dll new file mode 100644 index 0000000000000000000000000000000000000000..eaa5a8c8d38d2ccdf30697ca6159aa1ac29e6666 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.Wiff2.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.WiffReader.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.WiffReader.dll new file mode 100644 index 0000000000000000000000000000000000000000..61494f3612d9d80b933519a1ed716e537e0b2108 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.WiffReader.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Data.dll b/pyRawMSDataReader/DLLs/Clearcore2.Data.dll new file mode 100644 index 0000000000000000000000000000000000000000..6597c0668618fa6c1d51ac5bd646fa2c591534f5 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Data.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.DataService.dll b/pyRawMSDataReader/DLLs/Clearcore2.DataService.dll new file mode 100644 index 0000000000000000000000000000000000000000..5d3a6bc3febd821e1c3d17a163a3208fc8c8d83b Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.DataService.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Devices.Types.dll b/pyRawMSDataReader/DLLs/Clearcore2.Devices.Types.dll new file mode 100644 index 0000000000000000000000000000000000000000..e1168202e1742b57390ac49c0bd4f6280f9c43da Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Devices.Types.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Domain.Acquisition.Methods.MassSpec.dll b/pyRawMSDataReader/DLLs/Clearcore2.Domain.Acquisition.Methods.MassSpec.dll new file mode 100644 index 0000000000000000000000000000000000000000..74f7ae97ceb4c38071d3fe36c35af6ec86ffd66e Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Domain.Acquisition.Methods.MassSpec.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Domain.Acquisition.dll b/pyRawMSDataReader/DLLs/Clearcore2.Domain.Acquisition.dll new file mode 100644 index 0000000000000000000000000000000000000000..75aa569371117caf9ef8c93b6cc093d9182ac365 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Domain.Acquisition.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Infrastructure.dll b/pyRawMSDataReader/DLLs/Clearcore2.Infrastructure.dll new file mode 100644 index 0000000000000000000000000000000000000000..bf2af6df0db8d09ef1bb9f5b52579a2e9010749b Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Infrastructure.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.InternalRawXYProcessing.dll b/pyRawMSDataReader/DLLs/Clearcore2.InternalRawXYProcessing.dll new file mode 100644 index 0000000000000000000000000000000000000000..37a99ade2c4a16f73a6bc0d0e861a57159886a8f Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.InternalRawXYProcessing.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Muni.dll b/pyRawMSDataReader/DLLs/Clearcore2.Muni.dll new file mode 100644 index 0000000000000000000000000000000000000000..4fbc2eb1d67a3de762a4028d4bc1b0e7988cdc88 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Muni.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Processing.dll b/pyRawMSDataReader/DLLs/Clearcore2.Processing.dll new file mode 100644 index 0000000000000000000000000000000000000000..8edd9775f2441686fa05342142a2e80899ee0a36 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Processing.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.ProjectUtilities.dll b/pyRawMSDataReader/DLLs/Clearcore2.ProjectUtilities.dll new file mode 100644 index 0000000000000000000000000000000000000000..29ca616de384b3199c92ed649f7d8bde8e4f9f67 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.ProjectUtilities.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.RawXYProcessing.dll b/pyRawMSDataReader/DLLs/Clearcore2.RawXYProcessing.dll new file mode 100644 index 0000000000000000000000000000000000000000..ab0362880b661c607529a9c3e61a59365b10efb8 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.RawXYProcessing.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.StructuredStorage.dll b/pyRawMSDataReader/DLLs/Clearcore2.StructuredStorage.dll new file mode 100644 index 0000000000000000000000000000000000000000..afc2549e159f5cb1096a639dfc47b638d8511ea4 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.StructuredStorage.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.UserLog.Types.dll b/pyRawMSDataReader/DLLs/Clearcore2.UserLog.Types.dll new file mode 100644 index 0000000000000000000000000000000000000000..a83e1a578f3908f848a7d284274c2f77a6131ec6 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.UserLog.Types.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.Utility.dll b/pyRawMSDataReader/DLLs/Clearcore2.Utility.dll new file mode 100644 index 0000000000000000000000000000000000000000..36980d9bb780e9aed2a76e1c894d96858db1404e Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.Utility.dll differ diff --git a/pyRawMSDataReader/DLLs/Clearcore2.XmlHelpers.dll b/pyRawMSDataReader/DLLs/Clearcore2.XmlHelpers.dll new file mode 100644 index 0000000000000000000000000000000000000000..2e506cd2c8f03c967a94243b8b368876535562fe Binary files /dev/null and b/pyRawMSDataReader/DLLs/Clearcore2.XmlHelpers.dll differ diff --git a/pyRawMSDataReader/DLLs/Sciex.Clearcore.FMan.dll b/pyRawMSDataReader/DLLs/Sciex.Clearcore.FMan.dll new file mode 100644 index 0000000000000000000000000000000000000000..17f1eb64e2747d8ae85bfcca32e295749b55983f Binary files /dev/null and b/pyRawMSDataReader/DLLs/Sciex.Clearcore.FMan.dll differ diff --git a/pyRawMSDataReader/DLLs/Sciex.Data.Processing.dll b/pyRawMSDataReader/DLLs/Sciex.Data.Processing.dll new file mode 100644 index 0000000000000000000000000000000000000000..78f8a2da8e1dba3580406f38cba6969d256e360e Binary files /dev/null and b/pyRawMSDataReader/DLLs/Sciex.Data.Processing.dll differ diff --git a/pyRawMSDataReader/DLLs/Sciex.Data.SimpleTypes.dll b/pyRawMSDataReader/DLLs/Sciex.Data.SimpleTypes.dll new file mode 100644 index 0000000000000000000000000000000000000000..7b88a67edc8dec3bab8dc9f84a08e4582112501c Binary files /dev/null and b/pyRawMSDataReader/DLLs/Sciex.Data.SimpleTypes.dll differ diff --git a/pyRawMSDataReader/DLLs/Sciex.Data.XYData.dll b/pyRawMSDataReader/DLLs/Sciex.Data.XYData.dll new file mode 100644 index 0000000000000000000000000000000000000000..f73f54c7f5e2df5ed80a72484ce8c7be36092cf9 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Sciex.Data.XYData.dll differ diff --git a/pyRawMSDataReader/DLLs/Sciex.FMan.dll b/pyRawMSDataReader/DLLs/Sciex.FMan.dll new file mode 100644 index 0000000000000000000000000000000000000000..4143672cbe79fed3ef71ca736c2139ece616055a Binary files /dev/null and b/pyRawMSDataReader/DLLs/Sciex.FMan.dll differ diff --git a/pyRawMSDataReader/DLLs/Sciex.Wiff.dll b/pyRawMSDataReader/DLLs/Sciex.Wiff.dll new file mode 100644 index 0000000000000000000000000000000000000000..f92d2c6e1bb281cf912e24f9447e3436d7ad7d47 Binary files /dev/null and b/pyRawMSDataReader/DLLs/Sciex.Wiff.dll differ diff --git a/pyRawMSDataReader/DLLs/SciexToolKit.dll b/pyRawMSDataReader/DLLs/SciexToolKit.dll new file mode 100644 index 0000000000000000000000000000000000000000..9390f21a207ae36f4e03bc314d0a5671cf001b11 Binary files /dev/null and b/pyRawMSDataReader/DLLs/SciexToolKit.dll differ diff --git a/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.Data.dll b/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.Data.dll new file mode 100644 index 0000000000000000000000000000000000000000..d7991178a7cc620a827f3fae020bb2e566480040 Binary files /dev/null and b/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.Data.dll differ diff --git a/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.RawFileReader.dll b/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.RawFileReader.dll new file mode 100644 index 0000000000000000000000000000000000000000..f89a35f620ceae72585c6ef6cbad0610f2301da1 Binary files /dev/null and b/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.RawFileReader.dll differ diff --git a/pyRawMSDataReader/DLLs/WiffFileReader.dll b/pyRawMSDataReader/DLLs/WiffFileReader.dll new file mode 100644 index 0000000000000000000000000000000000000000..3309daec44b0c57796924ef75f08e99ba04b1271 Binary files /dev/null and b/pyRawMSDataReader/DLLs/WiffFileReader.dll differ diff --git a/pyRawMSDataReader/DLLs/libtimsdata.so b/pyRawMSDataReader/DLLs/libtimsdata.so new file mode 100644 index 0000000000000000000000000000000000000000..24920f7b85a3d679c518dcaed758d45ef72382b1 Binary files /dev/null and b/pyRawMSDataReader/DLLs/libtimsdata.so differ diff --git a/pyRawMSDataReader/DLLs/timsdata.dll b/pyRawMSDataReader/DLLs/timsdata.dll new file mode 100644 index 0000000000000000000000000000000000000000..7e41f78cd811947b2e2ecd2f0b92ebbcc7968cc4 Binary files /dev/null and b/pyRawMSDataReader/DLLs/timsdata.dll differ diff --git a/pyRawMSDataReader/LICENSE b/pyRawMSDataReader/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..afd40a17798e88353abcd8f5eb7cc462c86c0e7f --- /dev/null +++ b/pyRawMSDataReader/LICENSE @@ -0,0 +1,265 @@ +pyRawDataReader License: +Copyright 2019 Wen-Feng Zeng (jalew.zwf@qq.com) + +Licensed under the Apache License, Version 2.0. + + +#################################################################################### + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +#################################################################################### + +Thermo License + SOFTWARE LICENSE AGREEMENT (“Licenseâ€) FOR RawFileReader + +These License terms are an agreement between you and Thermo Finnigan LLC ("Licensor"). They apply to Licensor’s MSFileReader software program (“Softwareâ€), which includes documentation and any media on which you received it. These terms also apply to any updates or supplements for this Software, unless other terms accompany those items, in which case those terms apply. If you use this Software, you accept this License. If you do not accept this License, you are prohibited from using this software. If you comply with these License terms, you have the rights set forth below. + +1. Rights Granted: + +1.1. You may install and use this Software on any of your computing devices. + +1.2. You may distribute this Software to others, but only in combination with other software components and/or programs that you provide and subject to the distribution requirements and restrictions below. + +2. Use Restrictions: + +2.1. You may not decompile, disassemble, reverse engineer, use reflection or modify this Software. + +3. Distribution Requirements: + +If you distribute this Software to others, you agree to: + +3.1. Indemnify, defend and hold harmless the Licensor from any claims, including attorneys’ fees, related to the distribution or use of this Software; + +3.2. Display the following text in your software’s “About†box: “RawFileReader reading tool. Copyright © 2016 by Thermo Fisher Scientific, Inc. All rights reserved.â€; + +3.3. Require your end users to agree to a license agreement that prohibits them from redistributing this Software to others. + +4. Distribution Restrictions: + +4.1. You may not use the Licensor’s trademarks in a way that suggests your software components and/or programs are provided by or are endorsed by the Licensor; and + +4.2. You may not commercially exploit this Software or products that incorporate this Software without the prior written consent of Licensor. Commercial exploitation includes, but is not limited to, charging a purchase price, license fee, maintenance fee, or subscription fee; or licensing, transferring or redistributing the Software in exchange for consideration of any kind. + +4.3. Your rights to this Software do not include any license, right, power or authority to subject this Software in whole or in part to any of the terms of an Excluded License. "Excluded License" means any license that requires as a condition of use, modification and/or distribution of software subject to the Excluded License, that such software or other software combined and/or distributed with such software be (a) disclosed or distributed in source code form; or (b) licensed for the purpose of making derivative works. Without limiting the foregoing obligation, you are specifically prohibited from distributing this Software with any software that is subject to the General Public License (GPL) or similar license in a manner that would create a combined work. + +5. Additional Terms Applicable to Software: + +5.1. This Software is licensed, not sold. This License only gives you some rights to use this Software; the Licensor reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use this Software only as expressly permitted in this License. + +5.2. Licensor has no obligation to fix, update, supplement or support this Software. + +5.3. This Software is not designed, manufactured or intended for any use requiring fail-safe performance in which the failure of this Software could lead to death, serious personal injury or severe physical and environmental damage (“High Risk Activitiesâ€), such as the operation of aircraft, medical or nuclear facilities. You agree not to use, or license the use of, this Software in connection with any High Risk Activities. + +5.4. Your rights under this License terminate automatically if you breach this License in any way. Termination of this License will not affect any of your obligations or liabilities arising prior to termination. The following sections of this License shall survive termination: 2.1, 3.1, 3.2, 3.3, 4.1, 4.2, 4.3, 5.1, 5.2, 5.3, 5.5, 5.6, 5.7, 5.8, and 5.9. + +5.5. This Software is subject to United States export laws and regulations. You agree to comply with all domestic and international export laws and regulations that apply to this Software. These laws include restrictions on destinations, end users and end use. + +5.6. This License shall be construed and controlled by the laws of the State of California, U.S.A., without regard to conflicts of law. You consent to the jurisdiction of the state and federal courts situated in the State of California in any action arising under this License. The application of the U.N. Convention on Contracts for the International Sale of Goods to this License is hereby expressly excluded. If any provision of this License shall be deemed unenforceable or contrary to law, the rest of this License shall remain in full effect and interpreted in an enforceable manner that most nearly captures the intent of the original language. + +5.7. THIS SOFTWARE IS LICENSED "AS IS". YOU BEAR ALL RISKS OF USING IT. LICENSOR GIVES NO AND DISCLAIMS ALL EXPRESS AND IMPLIED WARRANTIES, REPRESENTATIONS OR GUARANTEES. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS LICENSE CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, LICENSOR EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + +5.8. LICENSOR’S TOTAL LIABILITY TO YOU FOR DIRECT DAMAGES ARISING UNDER THIS LICENSE IS LIMITED TO U.S. $1.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES, EVEN IF LICENSOR IS EXPRESSLY MADE AWARE OF THE POSSIBILITY THEREOF OR IS NEGLIGENT. THIS LIMITATION APPLIES TO ANYTHING RELATED TO THIS SOFTWARE, SERVICES, CONTENT (INCLUDING CODE) ON THIRD PARTY INTERNET SITES, OR THIRD PARTY PROGRAMS, AND CLAIMS FOR BREACH OF CONTRACT, BREACH OF WARRANTY, GUARANTEE OR CONDITION, STRICT LIABILITY, NEGLIGENCE, OR OTHER TORT TO THE EXTENT PERMITTED BY APPLICABLE LAW. + +5.9. Use, duplication or disclosure of this Software by the U.S. Government is subject to the restricted rights applicable to commercial computer software (under FAR 52.227019 and DFARS 252.227-7013 or parallel regulations). The manufacturer for this purpose is Thermo Finnigan LLC, 355 River Oaks Parkway, San Jose, California 95134, U.S.A. \ No newline at end of file diff --git a/pyRawMSDataReader/THERMO_LICENSE.txt b/pyRawMSDataReader/THERMO_LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..de6e75630eb42bcde21bd7ef647d3c2ee5a2508f --- /dev/null +++ b/pyRawMSDataReader/THERMO_LICENSE.txt @@ -0,0 +1,51 @@ +SOFTWARE LICENSE AGREEMENT (“Licenseâ€) FOR RawFileReader + +These License terms are an agreement between you and Thermo Finnigan LLC ("Licensor"). They apply to Licensor’s MSFileReader software program (“Softwareâ€), which includes documentation and any media on which you received it. These terms also apply to any updates or supplements for this Software, unless other terms accompany those items, in which case those terms apply. If you use this Software, you accept this License. If you do not accept this License, you are prohibited from using this software. If you comply with these License terms, you have the rights set forth below. + +1. Rights Granted: + +1.1. You may install and use this Software on any of your computing devices. + +1.2. You may distribute this Software to others, but only in combination with other software components and/or programs that you provide and subject to the distribution requirements and restrictions below. + +2. Use Restrictions: + +2.1. You may not decompile, disassemble, reverse engineer, use reflection or modify this Software. + +3. Distribution Requirements: + +If you distribute this Software to others, you agree to: + +3.1. Indemnify, defend and hold harmless the Licensor from any claims, including attorneys’ fees, related to the distribution or use of this Software; + +3.2. Display the following text in your software’s “About†box: “RawFileReader reading tool. Copyright © 2016 by Thermo Fisher Scientific, Inc. All rights reserved.â€; + +3.3. Require your end users to agree to a license agreement that prohibits them from redistributing this Software to others. + +4. Distribution Restrictions: + +4.1. You may not use the Licensor’s trademarks in a way that suggests your software components and/or programs are provided by or are endorsed by the Licensor; and + +4.2. You may not commercially exploit this Software or products that incorporate this Software without the prior written consent of Licensor. Commercial exploitation includes, but is not limited to, charging a purchase price, license fee, maintenance fee, or subscription fee; or licensing, transferring or redistributing the Software in exchange for consideration of any kind. + +4.3. Your rights to this Software do not include any license, right, power or authority to subject this Software in whole or in part to any of the terms of an Excluded License. "Excluded License" means any license that requires as a condition of use, modification and/or distribution of software subject to the Excluded License, that such software or other software combined and/or distributed with such software be (a) disclosed or distributed in source code form; or (b) licensed for the purpose of making derivative works. Without limiting the foregoing obligation, you are specifically prohibited from distributing this Software with any software that is subject to the General Public License (GPL) or similar license in a manner that would create a combined work. + +5. Additional Terms Applicable to Software: + +5.1. This Software is licensed, not sold. This License only gives you some rights to use this Software; the Licensor reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use this Software only as expressly permitted in this License. + +5.2. Licensor has no obligation to fix, update, supplement or support this Software. + +5.3. This Software is not designed, manufactured or intended for any use requiring fail-safe performance in which the failure of this Software could lead to death, serious personal injury or severe physical and environmental damage (“High Risk Activitiesâ€), such as the operation of aircraft, medical or nuclear facilities. You agree not to use, or license the use of, this Software in connection with any High Risk Activities. + +5.4. Your rights under this License terminate automatically if you breach this License in any way. Termination of this License will not affect any of your obligations or liabilities arising prior to termination. The following sections of this License shall survive termination: 2.1, 3.1, 3.2, 3.3, 4.1, 4.2, 4.3, 5.1, 5.2, 5.3, 5.5, 5.6, 5.7, 5.8, and 5.9. + +5.5. This Software is subject to United States export laws and regulations. You agree to comply with all domestic and international export laws and regulations that apply to this Software. These laws include restrictions on destinations, end users and end use. + +5.6. This License shall be construed and controlled by the laws of the State of California, U.S.A., without regard to conflicts of law. You consent to the jurisdiction of the state and federal courts situated in the State of California in any action arising under this License. The application of the U.N. Convention on Contracts for the International Sale of Goods to this License is hereby expressly excluded. If any provision of this License shall be deemed unenforceable or contrary to law, the rest of this License shall remain in full effect and interpreted in an enforceable manner that most nearly captures the intent of the original language. + +5.7. THIS SOFTWARE IS LICENSED "AS IS". YOU BEAR ALL RISKS OF USING IT. LICENSOR GIVES NO AND DISCLAIMS ALL EXPRESS AND IMPLIED WARRANTIES, REPRESENTATIONS OR GUARANTEES. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS LICENSE CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, LICENSOR EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + +5.8. LICENSOR’S TOTAL LIABILITY TO YOU FOR DIRECT DAMAGES ARISING UNDER THIS LICENSE IS LIMITED TO U.S. $1.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES, EVEN IF LICENSOR IS EXPRESSLY MADE AWARE OF THE POSSIBILITY THEREOF OR IS NEGLIGENT. THIS LIMITATION APPLIES TO ANYTHING RELATED TO THIS SOFTWARE, SERVICES, CONTENT (INCLUDING CODE) ON THIRD PARTY INTERNET SITES, OR THIRD PARTY PROGRAMS, AND CLAIMS FOR BREACH OF CONTRACT, BREACH OF WARRANTY, GUARANTEE OR CONDITION, STRICT LIABILITY, NEGLIGENCE, OR OTHER TORT TO THE EXTENT PERMITTED BY APPLICABLE LAW. + +5.9. Use, duplication or disclosure of this Software by the U.S. Government is subject to the restricted rights applicable to commercial computer software (under FAR 52.227019 and DFARS 252.227-7013 or parallel regulations). The manufacturer for this purpose is Thermo Finnigan LLC, 355 River Oaks Parkway, San Jose, California 95134, U.S.A. \ No newline at end of file diff --git a/pyRawMSDataReader/__init__.py b/pyRawMSDataReader/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/pyRawMSDataReader/build_install_test.ps1 b/pyRawMSDataReader/build_install_test.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..04dbf0dbc9ecbc7558b96bb5e6c9f7c1bc5fdfb9 --- /dev/null +++ b/pyRawMSDataReader/build_install_test.ps1 @@ -0,0 +1,15 @@ +# python -m pip install --user --upgrade setuptools wheel +python setup.py sdist bdist_wheel + +# pip install dist/pyRawDataReader_zwf-0.0.1-py3-none-any.whl +pip install dist/pyRawMSDataReader_zwf-0.0.1-py3-none-any.whl --upgrade + +Write-Host "Testing RawFileReader.py" +python tests/test_RawFileReader.py E:\DIAData\PECAN\20mz\20141010_DIA_20x20mz_500to900.raw + +Write-Host "Test WiffFileReader.py" +python tests/test_WiffFileReader.py E:\DIAData\LFQBench\DIA\HYE110_TTOF6600_32fix_lgillet_I160308_001.wiff + +# upload into pypi +# python -m pip install --user --upgrade twine +# python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* \ No newline at end of file diff --git a/pyRawMSDataReader/pyRawMSDataReader/RawFileReader.py b/pyRawMSDataReader/pyRawMSDataReader/RawFileReader.py new file mode 100644 index 0000000000000000000000000000000000000000..d8b671a60217fb771d3ad37a5769e1fd06f92067 --- /dev/null +++ b/pyRawMSDataReader/pyRawMSDataReader/RawFileReader.py @@ -0,0 +1,501 @@ +import os +import sys +import numpy as np + +# require pythonnet, pip install pythonnet +import clr +from System import String +# sys.path.append("DLLs") +clr.AddReference("/home/leo/PycharmProjects/pseudo_image/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.Data") +clr.AddReference("/home/leo/PycharmProjects/pseudo_image/pyRawMSDataReader/DLLs/ThermoFisher.CommonCore.RawFileReader") +import ThermoFisher +from ThermoFisher.CommonCore.Data.Interfaces import IScanEventBase, IScanEvent +''' +rawFile = ThermoFisher.CommonCore.RawFileReader.RawFileReaderAdapter.FileFactory(raw_filename) +var scanStatistics = rawFile.GetScanStatsForScanNumber(1); +var seg = rawFile.GetSegmentedScanFromScanNumber(1, scanStatistics); +var scanEvent = rawFile.GetScanEventForScanNumber(1); +var trailerData = rawFile.GetTrailerExtraInformation(1); +''' + +def DotNetArrayToNPArray(arr, dtype): + return np.array(list(arr), dtype=dtype) + +''' +APIs are similar to pymsfilereader(https://github.com/frallain/pymsfilereader), but some APIs have not be implemented yet." +''' +class RawFileReader(object): + # static class members + sampleType = {0: 'Unknown', + 1: 'Blank', + 2: 'QC', + 3: 'Standard Clear (None)', + 4: 'Standard Update (None)', + 5: 'Standard Bracket (Open)', + 6: 'Standard Bracket Start (multiple brackets)', + 7: 'Standard Bracket End (multiple brackets)'} + + controllerType = {-1: 'No device', + 0: 'MS', + 1: 'Analog', + 2: 'A/D card', + 3: 'PDA', + 4: 'UV', + 'No device': -1, + 'MS': 0, + 'Analog': 1, + 'A/D card': 2, + 'PDA': 3, + 'UV': 4} + + massAnalyzerType = {'ITMS': 0, + 'TQMS': 1, + 'SQMS': 2, + 'TOFMS': 3, + 'FTMS': 4, + 'Sector': 5, + 0: 'ITMS', + 1: 'TQMS', + 2: 'SQMS', + 3: 'TOFMS', + 4: 'FTMS', + 5: 'Sector'} + activationType = {'CID': 0, + 'MPD': 1, + 'ECD': 2, + 'PQD': 3, + 'ETD': 4, + 'HCD': 5, + 'Any activation type': 6, + 'SA': 7, + 'PTR': 8, + 'NETD': 9, + 'NPTR': 10, + 'UVPD': 11, + 'ETHCD': 12, # not Thermo's build-in activation types + 'ETCID': 13, # not Thermo's build-in activation types + 0: 'CID', + 1: 'MPD', + 2: 'ECD', + 3: 'PQD', + 4: 'ETD', + 5: 'HCD', + 6: 'Any activation type', + 7: 'SA', + 8: 'PTR', + 9: 'NETD', + 10: 'NPTR', + 11: 'UVPD', + 12: 'ETHCD', # not Thermo's build-in activation types + 13: 'ETCID', # not Thermo's build-in activation types + } + + detectorType = {'Valid': 0, + 'Any': 1, + 'NotValid': 2, + 0: 'Valid', + 1: 'Any', + 2: 'NotValid', + } + + scanDataType = {'Centroid': 0, + 'Profile': 1, + 'Any': 2, + 0: 'Centroid', + 1: 'Profile', + 2: 'Any', + } + + scanType = {'Full': 0, + 'Zoom': 1, + 'SIM': 2, + 'SRM': 3, + 'CRM': 4, + 'Any': 5, + 'Q1MS': 6, + 'Q3MS': 7, + 0: 'Full', + 1: 'SIM', + 2: 'Zoom', + 3: 'SRM', + 4: 'CRM', + 5: 'Any', + 6: 'Q1MS', + 7: 'Q3MS', + } + + def __init__(self, filename, **kwargs): + self.filename = os.path.abspath(filename) + self.filename = os.path.normpath(self.filename) + + self.source = ThermoFisher.CommonCore.RawFileReader.RawFileReaderAdapter.FileFactory(self.filename) + + if not self.source.IsOpen: + raise IOError( + "RAWfile '{0}' could not be opened, is the file accessible ?".format( + self.filename)) + self.source.SelectInstrument(ThermoFisher.CommonCore.Data.Business.Device.MS, 1) + + self.StartTime = self.GetStartTime() + self.EndTime = self.GetEndTime() + self.FirstSpectrumNumber = self.GetFirstSpectrumNumber() + self.LastSpectrumNumber = self.GetLastSpectrumNumber() + self.LowMass = self.GetLowMass() + self.HighMass = self.GetHighMass() + self.MassResolution = self.GetMassResolution() + self.NumSpectra = self.GetNumSpectra() + + def Close(self): + """Closes a raw file and frees the associated memory.""" + self.source.Dispose() + + def GetFileName(self): + """Returns the fully qualified path name of an open raw file.""" + return self.source.FileName + + def GetCreatorID(self): + """Returns the creator ID. The creator ID is the + logon name of the user when the raw file was acquired.""" + return self.source.CreatorId + + def GetCreationDate(self): + """Returns the file creation date in DATE format.""" + # https://msdn.microsoft.com/en-us/library/82ab7w69.aspx + # The DATE type is implemented using an 8-byte floating-point number + return self.source.CreationDate.ToOADate() + + def IsError(self): + """Returns the error state flag of the raw file. A return value of TRUE indicates that an error has + occurred. For information about the error, call the GetErrorCode or GetErrorMessage + functions.""" + return self.source.IsError + + def IsThereMSData(self): + """This function checks to see if there is MS data in the raw file. A return value of TRUE means + that the raw file contains MS data. You must open the raw file before performing this check.""" + return self.source.HasMsData + + def InAcquisition(self): + """Returns the acquisition state flag of the raw file. A return value of TRUE indicates that the + raw file is being acquired or that all open handles to the file during acquisition have not been + closed.""" + return self.source.InAcquisition + + def RefreshViewOfFile(self): + """Refreshes the view of a file currently being acquired. This function provides a more efficient + mechanism for gaining access to new data in a raw file during acquisition without closing and + reopening the raw file. This function has no effect with files that are not being acquired.""" + return self.source.RefreshViewOfFile + + def GetExpectedRunTime(self): + """Gets the expected acquisition run time for the current controller. The actual acquisition may + be longer or shorter than this value. This value is intended to allow displays to show the + expected run time on chromatograms. To obtain an accurate run time value during or after + acquisition, use the GetEndTime function.""" + return self.source.ExpectedRunTime + + def GetNumTrailerExtra(self): + """Gets the trailer extra entries recorded for the current controller. Trailer extra entries are only + supported for MS device controllers and are used to store instrument specific information for + each scan if used.""" + return self.source.RunHeaderEx.TrailerExtraCount + + def GetMaxIntegratedIntensity(self): + """Gets the highest integrated intensity of all the scans for the current controller. This value is + only relevant to MS device controllers.""" + return self.source.RunHeaderEx.MaxIntegratedIntensity + + def GetMaxIntensity(self): + """Gets the highest base peak of all the scans for the current controller. This value is only relevant + to MS device controllers.""" + return self.source.RunHeaderEx.MaxIntensity + + def GetComment1(self): + """Returns the first comment for the current controller. This value is typically only set for raw + files converted from other file formats.""" + return self.source.RunHeaderEx.Comment1 + + def GetComment2(self): + """Returns the second comment for the current controller. This value is typically only set for raw + files converted from other file formats.""" + return self.source.RunHeaderEx.Comment2 + + def GetFilters(self): + """Returns the list of unique scan filters for the raw file. This function is only supported for MS + device controllers.""" + return list(self.source.GetFilters()) + + # INSTRUMENT BEGIN + def GetInstName(self): + """Returns the instrument name, if available, for the current controller.""" + return String.Join(" -> ", self.source.GetAllInstrumentNamesFromInstrumentMethod()) + # INSTRUMENT END + + def GetScanEventStringForScanNum(self, scanNumber): + """This function returns scan event information as a string for the specified scan number.""" + return self.source.GetScanEventStringForScanNumber(scanNumber) + + def GetNumberOfMassRangesFromScanNum(self, scanNumber): + """This function gets the number of MassRange data items in the scan.""" + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).MassRangeCount + + def GetMassRangeFromScanNum(self, scanNumber, massRangeIndex): + """This function retrieves information about the mass range data of a scan (high and low + masses). You can find the count of mass ranges for the scan by calling + GetNumberOfMassRangesFromScanNum().""" + range = IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).GetMassRange(massRangeIndex) + return range.Low, range.High + + def GetNumberOfSourceFragmentsFromScanNum(self, scanNumber): + """This function gets the number of source fragments (or compensation voltages) in the scan.""" + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).SourceFragmentationInfoCount + + def GetSourceFragmentValueFromScanNum(self, scanNumber, sourceFragmentIndex): + """This function retrieves information about one of the source fragment values of a scan. It is + also the same value as the compensation voltage. You can find the count of source fragments + for the scan by calling GetNumberOfSourceFragmentsFromScanNum ().""" + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).GetSourceFragmentationInfo(sourceFragmentIndex) + + def GetIsolationWidthForScanNum(self, scanNumber, MSOrder = 0): + """This function returns the isolation width for the scan specified by scanNumber and the + transition specified by MSOrder (0 for MS1?) from the scan event structure in the raw file.""" + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).GetIsolationWidth(MSOrder) + + def GetCollisionEnergyForScanNum(self, scanNumber, MSOrder = 0): + """This function returns the collision energy for the scan specified by scanNumber and the + transition specified by MSOrder (0 for MS1?) from the scan event structure in the raw file. """ + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).GetEnergy(MSOrder) + + def GetActivationTypeForScanNum(self, scanNumber, MSOrder = 0): + """This function returns the activation type for the scan specified by scanNumber and the + transition specified by MSOrder from the scan event structure in the RAW file. + The value returned in the pnActivationType variable is one of the following: + CID 0 + MPD 1 + ECD 2 + PQD 3 + ETD 4 + HCD 5 + Any activation type 6 + SA 7 + PTR 8 + NETD 9 + NPTR 10 + UVPD 11""" + return RawFileReader.activationType[IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).GetActivation(MSOrder)] + + def GetMassAnalyzerTypeForScanNum(self, scanNumber): + """This function returns the mass analyzer type for the scan specified by scanNumber from the + scan event structure in the RAW file. The value of scanNumber must be within the range of + scans or readings for the current controller. The range of scans or readings for the current + controller may be obtained by calling GetFirstSpectrumNumber and + GetLastSpectrumNumber. + return RawFileReader.massAnalyzerType[IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).MassAnalyzer]""" + + def GetDetectorTypeForScanNum(self, scanNumber): + """This function returns the detector type for the scan specified by scanNumber from the scan + event structure in the RAW file.""" + return RawFileReader.detectorType[IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).Detector] + + def GetNumberOfMassCalibratorsFromScanNum(self, scanNumber): + """This function gets the number of mass calibrators (each of which is a double) in the scan.""" + return IScanEvent(self.source.GetScanEventForScanNumber(scanNumber)).MassCalibratorCount + + def GetMassCalibrationValueFromScanNum(self, scanNumber, massCalibrationIndex): + """This function retrieves information about one of the mass calibration data values of a scan. + You can find the count of mass calibrations for the scan by calling + GetNumberOfMassCalibratorsFromScanNum().""" + return IScanEvent(self.source.GetScanEventForScanNumber(scanNumber)).GetMassCalibrator(massCalibrationIndex) + + def GetMassResolution(self): + """Gets the mass resolution value recorded for the current controller. The value is returned as one + half of the mass resolution. For example, a unit resolution controller returns a value of 0.5. + This value is only relevant to scanning controllers such as MS.""" + return self.source.RunHeaderEx.MassResolution + + def GetLowMass(self): + """Gets the lowest mass or wavelength recorded for the current controller. This value is only + relevant to scanning devices such as MS or PDA.""" + return self.source.RunHeaderEx.LowMass + + def GetHighMass(self): + """Gets the highest mass or wavelength recorded for the current controller. This value is only + relevant to scanning devices such as MS or PDA.""" + return self.source.RunHeaderEx.HighMass + + def GetStartTime(self): + """Gets the start time of the first scan or reading for the current controller. This value is typically + close to zero unless the device method contains a start delay.""" + return self.source.RunHeaderEx.StartTime + + def GetEndTime(self): + return self.source.RunHeaderEx.EndTime + + def GetNumSpectra(self): + """Gets the number of spectra acquired by the current controller. For non-scanning devices like + UV detectors, the number of readings per channel is returned.""" + return self.source.RunHeaderEx.SpectraCount + + def GetFirstSpectrumNumber(self): + """Gets the first scan or reading number for the current controller. If data has been acquired, this + value is always one.""" + return self.source.RunHeaderEx.FirstSpectrum + + def GetLastSpectrumNumber(self): + """Gets the last scan or reading number for the current controller.""" + return self.source.RunHeaderEx.LastSpectrum + + def ScanNumFromRT(self, RT): + """Returns the closest matching scan number that corresponds to RT for the current controller. + For non-scanning devices, such as UV, the closest reading number is returned. The value of + RT must be within the acquisition run time for the current controller. The acquisition run + time for the current controller may be obtained by calling GetStartTime and GetEndTime.""" + return self.source.ScanNumberFromRetentionTime(RT) + + def ScanNumFromRTInSeconds(self, RTInSeconds): + """Returns the closest matching scan number that corresponds to RT for the current controller. + For non-scanning devices, such as UV, the closest reading number is returned. The value of + RT must be within the acquisition run time for the current controller. The acquisition run + time for the current controller may be obtained by calling GetStartTime and GetEndTime.""" + return self.ScanNumFromRT(RTInSeconds/60) + + def RTFromScanNum(self, scanNumber): + """Returns the closest matching run time or retention time that corresponds to scanNumber for + the current controller. For non-scanning devices, such as UV, the scanNumber is the reading + number.""" + return self.source.RetentionTimeFromScanNumber(scanNumber) + + def RTInSecondsFromScanNum(self, scanNumber): + """Returns the closest matching run time or retention time that corresponds to scanNumber for + the current controller. For non-scanning devices, such as UV, the scanNumber is the reading + number.""" + return self.RTFromScanNum(scanNumber)*60 + + def IsProfileScanForScanNum(self, scanNumber): + """Returns TRUE if the scan specified by scanNumber is a profile scan, FALSE if the scan is a + centroid scan.""" + return not self.source.GetScanStatsForScanNumber(scanNumber).IsCentroidScan + + def IsCentroidScanForScanNum(self, scanNumber): + """Returns TRUE if the scan specified by scanNumber is a centroid scan, FALSE if the scan is a + profile scan.""" + return self.source.GetScanStatsForScanNumber(scanNumber).IsCentroidScan + + def GetMSOrderForScanNum(self, scanNumber): + """This function returns the MS order for the scan specified by scanNumber from the scan + event structure in the raw file. + The value returned in the pnScanType variable is one of the following: + Neutral gain -3 + Neutral loss -2 + Parent scan -1 + Any scan order 0 + MS 1 + MS2 2 + MS3 3 + MS4 4 + MS5 5 + MS6 6 + MS7 7 + MS8 8 + MS9 9 + """ + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).MSOrder + + def GetNumberOfMSOrdersFromScanNum(self, scanNumber): + """This function gets the number of MS reaction data items in the scan event for the scan + specified by scanNumber and the transition specified by MSOrder from the scan event + structure in the raw file.""" + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).MassCount + + def GetPrecursorMassForScanNum(self, scanNumber, MSOrder = 0): + """This function returns the precursor mass for the scan specified by scanNumber and the + transition specified by MSOrder (0 for precursor in MS1?) from the scan event structure in the RAW file.""" + return IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)).GetReaction(MSOrder).PrecursorMass + + def GetPrecursorRangeForScanNum(self, scanNumber, MSOrder = 0): + """This function returns the first and last precursor mass values of the range and whether they are + valid for the scan specified by scanNumber and the transition specified by MSOrder (0 for precursor in MS1?) from the scan event structure in the raw file.""" + scanEvent = IScanEventBase(self.source.GetScanEventForScanNumber(scanNumber)) + firstMass = scanEvent.GetFirstPrecursorMass(MSOrder) + lastMass = scanEvent.GetLastPrecursorMass(MSOrder) + return firstMass, lastMass + + def GetBasePeakForScanNum(self, scanNumber): + """This function returns the base peak mass and intensity of mass spectrum.""" + stat = self.source.GetScanStatsForScanNumber(scanNumber) + return stat.BasePeakMass, stat.BasePeakIntensity + + # "View/Scan header", lower part + def GetTrailerExtraForScanNum(self, scanNumber): + """Returns the recorded trailer extra entry labels and values for the current controller. This + function is only valid for MS controllers. + NOTE : XCALIBUR INTERFACE "View/Scan header", lower part + """ + trailerData = self.source.GetTrailerExtraInformation(scanNumber) + return dict(zip(trailerData.Labels, trailerData.Values)) + + def GetProfileMassListFromScanNum(self, scanNumber): + scanStatistics = self.source.GetScanStatsForScanNumber(scanNumber) + segmentedScan = self.source.GetSegmentedScanFromScanNumber(scanNumber, scanStatistics) + return np.array([DotNetArrayToNPArray(segmentedScan.Positions, float), DotNetArrayToNPArray(segmentedScan.Intensities, float)]) + + def GetCentroidMassListFromScanNum(self, scanNumber): + scan = ThermoFisher.CommonCore.Data.Business.Scan.FromFile(self.source, scanNumber) + scanStatistics = self.source.GetScanStatsForScanNumber(scanNumber) + if scanStatistics.IsCentroidScan: + segmentedScan = self.source.GetSegmentedScanFromScanNumber(scanNumber, scanStatistics) + return np.array([DotNetArrayToNPArray(segmentedScan.Positions, float), DotNetArrayToNPArray(segmentedScan.Intensities, float)]) + elif scan.HasCentroidStream: + stream = self.source.GetCentroidStream(scanNumber, False) + return np.array([DotNetArrayToNPArray(stream.Masses, float), DotNetArrayToNPArray(stream.Intensities, float)]) + else: + print("Profile scan {0} cannot be centroided!".format(scanNumber)) + segmentedScan = self.source.GetSegmentedScanFromScanNumber(scanNumber, scanStatistics) + return np.array([DotNetArrayToNPArray(segmentedScan.Positions, float), DotNetArrayToNPArray(segmentedScan.Intensities, float)]) + +if __name__ == '__main__': + scanNumber = 10000 + rawFile = RawFileReader(sys.argv[1]) + print("GetFileName: ", rawFile.GetFileName()) + print("GetCreatorID: ", rawFile.GetCreatorID()) + print("GetCreationDate: ", rawFile.GetCreationDate()) + print("GetMaxIntensity: ", rawFile.GetMaxIntensity()) + print("GetComment1: ", rawFile.GetComment1()) + print("GetComment2: ", rawFile.GetComment2()) + print("GetInstName: ", rawFile.GetInstName()) + + print("GetMSOrderForScanNum: ", rawFile.GetMSOrderForScanNum(scanNumber)) + print("GetScanEventForScanNum: ", rawFile.GetScanEventStringForScanNum(scanNumber)) + print("GetNumberOfSourceFragmentsFromScanNum: ", rawFile.GetNumberOfSourceFragmentsFromScanNum(scanNumber)) + if rawFile.GetNumberOfSourceFragmentsFromScanNum(scanNumber) > 0: + print("GetSourceFragmentValueFromScanNum: ", rawFile.GetSourceFragmentValueFromScanNum(scanNumber, 0)) + if rawFile.GetMSOrderForScanNum(scanNumber) > 1: + print("GetIsolationWidthForScanNum: ", rawFile.GetIsolationWidthForScanNum(scanNumber)) + print("GetCollisionEnergyForScanNum: ", rawFile.GetCollisionEnergyForScanNum(scanNumber)) + print("GetActivationTypeForScanNum: ", rawFile.GetActivationTypeForScanNum(scanNumber)) + print("GetPrecursorMassForScanNum: ", rawFile.GetPrecursorMassForScanNum(scanNumber)) + print("GetPrecursorRangeForScanNum: ", rawFile.GetPrecursorRangeForScanNum(scanNumber)) + print("GetMassAnalyzerTypeForScanNum: ", rawFile.GetMassAnalyzerTypeForScanNum(scanNumber)) + print("GetNumberOfMassCalibratorsFromScanNum: ", rawFile.GetNumberOfMassCalibratorsFromScanNum(scanNumber)) + print("GetMassCalibrationValueFromScanNum: ", rawFile.GetMassCalibrationValueFromScanNum(scanNumber, 0)) + print("GetMassResolution: ", rawFile.GetMassResolution()) + print("GetLowMass: ", rawFile.GetLowMass()) + print("GetHighMass: ", rawFile.GetHighMass()) + print("GetStartTime: ", rawFile.GetStartTime()) + print("GetEndTime: ", rawFile.GetEndTime()) + print("GetFirstSpectrumNumber: ", rawFile.GetFirstSpectrumNumber()) + print("GetLastSpectrumNumber: ", rawFile.GetLastSpectrumNumber()) + print("IsProfileScanForScanNum: ", rawFile.IsProfileScanForScanNum(scanNumber)) + print("IsCentroidScanForScanNum: ", rawFile.IsCentroidScanForScanNum(scanNumber)) + + print("RTFromScanNum: ", rawFile.RTFromScanNum(scanNumber)) + print("ScanNumFromRT: ", rawFile.ScanNumFromRT(30)) + print("RTInSecondsFromScanNum: ", rawFile.RTInSecondsFromScanNum(scanNumber)) + print("ScanNumFromRTInSeconds: ", rawFile.ScanNumFromRTInSeconds(30)) + + print("GetNumberOfMSOrdersFromScanNum: ", rawFile.GetNumberOfMSOrdersFromScanNum(scanNumber)) + print("GetBasePeakForScanNum: ", rawFile.GetBasePeakForScanNum(scanNumber)) + print("GetTrailerExtraForScanNum: ", rawFile.GetTrailerExtraForScanNum(scanNumber)) + print("GetCentroidMassListFromScanNum: ", rawFile.GetCentroidMassListFromScanNum(scanNumber)) + rawFile.Close() + diff --git a/pyRawMSDataReader/pyRawMSDataReader/WiffFileReader_py.py b/pyRawMSDataReader/pyRawMSDataReader/WiffFileReader_py.py new file mode 100644 index 0000000000000000000000000000000000000000..6fbf8591ee00b545de3b1bf3a80d52406a96e842 --- /dev/null +++ b/pyRawMSDataReader/pyRawMSDataReader/WiffFileReader_py.py @@ -0,0 +1,130 @@ +import os +import sys +import numpy as np +import clr + +clr.AddReference("/home/leo/PycharmProjects/pseudo_image/pyRawMSDataReader/DLLs/WiffFileReader.dll") +from WiffFileReader import WiffFile + +from .RawFileReader import DotNetArrayToNPArray + +class WiffFileReader(object): + def __init__(self, filename, **kwargs): + self.filename = os.path.abspath(filename) + self.filename = os.path.normpath(self.filename) + try: + self.source = WiffFile(self.filename) + except: + raise IOError( + "Wiff file '{0}' could not be opened, is the file accessible ?".format( + self.filename)) + + self.StartTime = self.GetStartTime() + self.EndTime = self.GetEndTime() + self.FirstSpectrumNumber = self.GetFirstSpectrumNumber() + self.LastSpectrumNumber = self.GetLastSpectrumNumber() + self.NumSpectra = self.GetNumSpectra() + + def Close(self): + self.source.Close() + + def GetFileName(self): + return self.source.GetFileName() + + # INSTRUMENT BEGIN + def GetInstName(self): + return self.source.GetInstrumentName() + # INSTRUMENT END + + def GetScanEventStringForScanNum(self, scanNumber): + return self.source.GetDescriptionForScanNum(scanNumber) + + def GetIsolationWidthForScanNum(self, scanNumber): + return self.source.GetIsolationWidth(scanNumber) + + def GetCollisionEnergyForScanNum(self, scanNumber): + return self.source.GetCollisionEnergyForScanNum(scanNumber) + + def GetActivationTypeForScanNum(self, scanNumber): + return self.source.ScanInfos[scanNumber].FragmentationType + + def GetMassAnalyzerTypeForScanNum(self, scanNumber): + return "QTOF" + + def GetDetectorTypeForScanNum(self, scanNumber): + return "QTOF" + + def GetStartTime(self): + return self.source.GetStartTime() + + def GetEndTime(self): + return self.source.GetEndTime() + + def GetNumSpectra(self): + """Gets the number of spectra acquired by the current controller. For non-scanning devices like + UV detectors, the number of readings per channel is returned.""" + return self.source.GetNumSpectra() + + def GetFirstSpectrumNumber(self): + """Gets the first scan or reading number for the current controller. If data has been acquired, this + value is always one.""" + return self.source.GetFirstSpectrumNumber() + + def GetLastSpectrumNumber(self): + """Gets the last scan or reading number for the current controller.""" + return self.source.GetLastSpectrumNumber() + + def ScanNumFromRT(self, RT): + """Returns the closest matching scan number that corresponds to RT for the current controller. + For non-scanning devices, such as UV, the closest reading number is returned. The value of + RT must be within the acquisition run time for the current controller. The acquisition run + time for the current controller may be obtained by calling GetStartTime and GetEndTime.""" + return self.source.GetScanNumFromRetentionTime(RT) + + def ScanNumFromRTInSeconds(self, RTInSeconds): + """Returns the closest matching scan number that corresponds to RT for the current controller. + For non-scanning devices, such as UV, the closest reading number is returned. The value of + RT must be within the acquisition run time for the current controller. The acquisition run + time for the current controller may be obtained by calling GetStartTime and GetEndTime.""" + return self.ScanNumFromRT(RTInSeconds/60) + + def RTFromScanNum(self, scanNumber): + """Returns the closest matching run time or retention time that corresponds to scanNumber for + the current controller. For non-scanning devices, such as UV, the scanNumber is the reading + number.""" + return self.source.GetRetentionTimeFromScanNum(scanNumber) + + def RTInSecondsFromScanNum(self, scanNumber): + """Returns the closest matching run time or retention time that corresponds to scanNumber for + the current controller. For non-scanning devices, such as UV, the scanNumber is the reading + number.""" + return self.RTFromScanNum(scanNumber)*60 + + def IsProfileScanForScanNum(self, scanNumber): + """Returns TRUE if the scan specified by scanNumber is a profile scan, FALSE if the scan is a + centroid scan.""" + return True + + def IsCentroidScanForScanNum(self, scanNumber): + """Returns TRUE if the scan specified by scanNumber is a centroid scan, FALSE if the scan is a + profile scan.""" + return True + + def GetMSOrderForScanNum(self, scanNumber): + return self.source.GetMSLevelForScanNum(scanNumber) + + def GetPrecursorMassForScanNum(self, scanNumber): + return self.source.GetPrecursorMassFromScanNum(scanNumber) + + def GetBasePeakForScanNum(self, scanNumber): + """This function returns the base peak mass and intensity of mass spectrum.""" + base_peak = self.source.GetBasePeakFromScanNum(scanNumber) + return base_peak.Item1, base_peak.Item2 + + def GetProfileMassListFromScanNum(self, scanNumber): + peak_list = self.source.GetProfileFromScanNum(scanNumber) + return np.array([DotNetArrayToNPArray(peak_list.Masses, float), DotNetArrayToNPArray(peak_list.Intensities, float)]) + + def GetCentroidMassListFromScanNum(self, scanNumber): + peak_list = self.source.GetCentroidFromScanNum(scanNumber) + return np.array([DotNetArrayToNPArray(peak_list.Masses, float), DotNetArrayToNPArray(peak_list.Intensities, float)]) \ No newline at end of file diff --git a/pyRawMSDataReader/pyRawMSDataReader/__init__.py b/pyRawMSDataReader/pyRawMSDataReader/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/pyRawMSDataReader/readme.md b/pyRawMSDataReader/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..c8e881af63c4ef6baace3c2c1f10d07a3480de18 --- /dev/null +++ b/pyRawMSDataReader/readme.md @@ -0,0 +1,6 @@ +[](https://zenodo.org/badge/latestdoi/254636916) +# pyRawMSDataReader + +## pyRawFileReader + +## pyWiffFileReader diff --git a/pyRawMSDataReader/setup.py b/pyRawMSDataReader/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..b37bcf678b13c1ea146d86d1a7aa2f6fa3626ab6 --- /dev/null +++ b/pyRawMSDataReader/setup.py @@ -0,0 +1,92 @@ +import setuptools +import distutils.sysconfig +from distutils.command import install, build, build_ext, install_data, install_lib +import os + +# package .dll files into "site-packages", making .dll files visible for python and clr (pythonnet) +# this class and cmdclass is modified from pythonnet setup.py (for Python.Runtime.dll) +class InstallDataPythonnet(install_data.install_data): + def run(self): + install_cmd = self.get_finalized_command("install") + install_platlib = os.path.relpath(install_cmd.install_platlib, self.install_dir) + print(install_platlib) + for i, data_files in enumerate(self.data_files): + if isinstance(data_files, str): + pass + else: + dest = data_files[0].format(install_platlib=install_platlib) + self.data_files[i] = dest, data_files[1] + + return install_data.install_data.run(self) + +cmdclass={ + "install_data": InstallDataPythonnet, + # "install": InstallPythonnet, + # "build_ext": BuildExtPythonnet, + # "install_lib": InstallLibPythonnet, +} + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name="pyRawMSFileReader", + version="0.0.1", + author="Zeng, Wen-Feng", + author_email="jalew.zwf@qq.com", + description="Accessing Raw/Wiff/... mass spectrum raw files using python", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/jalew188/pyRawDataReader", + packages=setuptools.find_packages(), + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache License", + "Operating System :: OS Independent", + ], + python_requires='>=3.5', + install_requires=["pythonnet"], + cmdclass=cmdclass, + data_files=[('{install_platlib}', + [ + # "DLLs/WiffFileReader.dll", + # "DLLs/SciexToolKit.dll", + "DLLs/ThermoFisher.CommonCore.Data.dll", + "DLLs/ThermoFisher.CommonCore.RawFileReader.dll", + # "DLLs/Clearcore2.Domain.Acquisition.Methods.MassSpec.dll", + # "DLLs/Sciex.FMan.dll", + # "DLLs/Clearcore2.Data.dll", + # "DLLs/Clearcore2.RawXYProcessing.dll", + # "DLLs/Sciex.Data.Processing.dll", + # "DLLs/Sciex.Data.SimpleTypes.dll", + # "DLLs/Sciex.Data.XYData.dll", + # "DLLs/Clearcore2.InternalRawXYProcessing.dll", + # "DLLs/Clearcore2.Utility.dll", + # "DLLs/Clearcore2.Data.Acquisition.Client.dll", + # "DLLs/Clearcore2.Data.Client.dll", + # "DLLs/Clearcore2.DataService.dll", + # "DLLs/Clearcore2.Data.Common.dll", + # "DLLs/Clearcore2.Data.AnalystDataProvider.dll", + # "DLLs/Sciex.Clearcore.FMan.dll", + # "DLLs/Clearcore2.Data.WiffReader.dll", + # "DLLs/Clearcore2.Data.Acquisition.Contracts.dll", + # "DLLs/Clearcore2.Data.Core.dll", + # "DLLs/Clearcore2.Data.Contracts.dll", + # "DLLs/Clearcore2.Data.Wiff2.dll", + # "DLLs/Clearcore2.StructuredStorage.dll", + # "DLLs/Sciex.Wiff.dll", + # "DLLs/Clearcore2.Compression.dll", + # "DLLs/Clearcore2.Domain.Acquisition.dll", + # "DLLs/Clearcore2.Data.CommonInterfaces.dll", + # "DLLs/Clearcore2.Infrastructure.dll", + # "DLLs/Clearcore2.UserLog.Types.dll", + # "DLLs/Clearcore2.Muni.dll", + # "DLLs/Clearcore2.Devices.Types.dll", + # "DLLs/Clearcore2.XmlHelpers.dll", + # "DLLs/Clearcore.Licensing.dll", + # "DLLs/Clearcore2.Processing.dll", + # "DLLs/Clearcore2.ProjectUtilities.dll", + # "DLLs/timsdata.dll", + # "DLLs/libtimsdata.so", + ])], +) \ No newline at end of file