Skip to content

Commit

Permalink
Added everything Andy asked for. Added version info in MsftbxInfo.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chhh committed Nov 1, 2016
1 parent 6d3d04e commit 9c0772b
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 22 deletions.
6 changes: 3 additions & 3 deletions MSFileToolbox/src/umich/ms/datatypes/lcmsrun/Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* @author Dmitry Avtonomov
*/
public class Hash {
public final String hash;
public final String value;
public final TYPE type;

public Hash(String hash, TYPE type) {
this.hash = hash;
public Hash(String value, TYPE type) {
this.value = value;
this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,10 @@ public List<OriginalFile> getOriginalFiles() {
public String toString() {
return "LCMSRunInfo{" +
"instruments=" + instruments +
", date=" + date +
", defaultInstrumentID='" + defaultInstrumentID + '\'' +
", isCentroided=" + isCentroided +
", isDefaultExplicitlySet=" + isDefaultExplicitlySet +
", date=" + date +
", software=" + software +
", originalFiles=" + originalFiles +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
/*
* Copyright 2016 Dmitry Avtonomov.
*
* 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.
*/
/*
* Copyright 2016 Dmitry Avtonomov.
*
* 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.
*/
package umich.ms.fileio.filetypes.mzxml;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

import umich.ms.datatypes.lcmsrun.Hash;
import umich.ms.datatypes.lcmsrun.LCMSRunInfo;
import umich.ms.datatypes.lcmsrun.MsSoftware;
import umich.ms.datatypes.lcmsrun.OriginalFile;
import umich.ms.datatypes.scan.props.Instrument;
import umich.ms.fileio.exceptions.RunHeaderBoundsNotFound;
import umich.ms.fileio.exceptions.RunHeaderParsingException;
import umich.ms.fileio.filetypes.mzxml.jaxb.MsRun;
import umich.ms.fileio.filetypes.mzxml.jaxb.OntologyEntryType;
import umich.ms.fileio.filetypes.mzxml.jaxb.Software;
import umich.ms.fileio.filetypes.util.AbstractFile;
import umich.ms.fileio.filetypes.xmlbased.OffsetLength;
import umich.ms.logging.LogHelper;
Expand Down Expand Up @@ -64,6 +73,41 @@ public LCMSRunInfo parse() throws RunHeaderParsingException {
MsRun parsedInfo = parseHeaderWithJAXB(MsRun.class, msRunLocation);
LCMSRunInfo runInfo = new LCMSRunInfo();


// original files
List<MsRun.ParentFile> parentFiles = parsedInfo.getParentFile();
for (MsRun.ParentFile parentFile : parentFiles) {
String file = parentFile.getFileName();
file = file.replaceAll("\\\\", "/");
String location = "";
String fileName = file;
try {
Path path = Paths.get(file);
location = path.getParent().toString();
fileName = path.getFileName().toString();
} catch (InvalidPathException e) {
// could not parse path, try URI
try {
URI uri = URI.create(file).normalize();
String uriPath = uri.getPath();
while (uriPath.startsWith("/")) uriPath = uriPath.substring(1);

Path path = Paths.get(uriPath);
location = path.getParent().toString();
fileName = path.getFileName().toString();
} catch (IllegalArgumentException e2) {
// URI also didn't work, forget it
}
}

Hash hash = null;
if (parentFile.getFileSha1() != null && !parentFile.getFileSha1().isEmpty()) {
hash = new Hash(parentFile.getFileSha1(), Hash.TYPE.SHA1);
}
runInfo.getOriginalFiles().add(new OriginalFile(location, fileName, hash));
}


List<MsRun.MsInstrument> msInstruments = parsedInfo.getMsInstrument();
if (msInstruments.size() > 0) {
for (MsRun.MsInstrument i : msInstruments) {
Expand Down Expand Up @@ -113,7 +157,12 @@ public LCMSRunInfo parse() throws RunHeaderParsingException {
for (MsRun.DataProcessing dataProcessing : dataProcessings) {
if (dataProcessing.isCentroided() != null) {
runInfo.setCentroided(dataProcessing.isCentroided());
break;
}

Software software = dataProcessing.getSoftware();
if (software != null) {
MsSoftware msSoftware = new MsSoftware(software.getName(), software.getVersion());
runInfo.getSoftware().add(msSoftware);
}
}

Expand Down
24 changes: 24 additions & 0 deletions MSFileToolbox/src/umich/ms/msfiletoolbox/MsftbxInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2016 Dmitry Avtonomov
*
* 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.
*/

package umich.ms.msfiletoolbox;

/**
* @author Dmitry Avtonomov
*/
public class MsftbxInfo {
public static final String version = "1.1.0";
}

0 comments on commit 9c0772b

Please sign in to comment.