-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2350db8
commit f69eaf3
Showing
4 changed files
with
122 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...pse/chemclipse/msd/converter/supplier/mzxml/converter/ChromatogramMagicNumberMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016, 2021 Lablicate GmbH. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Dr. Philip Wenig - initial API and implementation | ||
* Matthias Mailänder - auto detection for chromatography files | ||
*******************************************************************************/ | ||
package org.eclipse.chemclipse.msd.converter.supplier.mzxml.converter; | ||
|
||
import java.io.File; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.Unmarshaller; | ||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
|
||
import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher; | ||
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.IConstants; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.IFormat; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.SpecificationValidator; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.MsRun; | ||
import org.w3c.dom.Document; | ||
import org.w3c.dom.NodeList; | ||
|
||
public class ChromatogramMagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher { | ||
|
||
@Override | ||
public boolean checkFileFormat(File file) { | ||
|
||
boolean isValidFormat = false; | ||
try { | ||
file = SpecificationValidator.validateSpecification(file); | ||
if(!file.exists()) { | ||
return isValidFormat; | ||
} | ||
if(!checkFileExtension(file, ".mzXML")) { | ||
return isValidFormat; | ||
} | ||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); | ||
Document document = documentBuilder.parse(file); | ||
NodeList nodeList = document.getElementsByTagName(IConstants.NODE_MS_RUN); | ||
// | ||
JAXBContext jaxbContext = JAXBContext.newInstance(IFormat.CONTEXT_PATH_V_320); | ||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); | ||
MsRun msRun = (MsRun)unmarshaller.unmarshal(nodeList.item(0)); | ||
if(msRun.getScan().size() > 1) | ||
isValidFormat = true; | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return isValidFormat; | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
...src/org/eclipse/chemclipse/msd/converter/supplier/mzxml/converter/MagicNumberMatcher.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
...pse/chemclipse/msd/converter/supplier/mzxml/converter/MassSpectrumMagicNumberMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016, 2021 Lablicate GmbH. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Dr. Philip Wenig - initial API and implementation | ||
* Matthias Mailänder - auto detection for MALDI files | ||
*******************************************************************************/ | ||
package org.eclipse.chemclipse.msd.converter.supplier.mzxml.converter; | ||
|
||
import java.io.File; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.Unmarshaller; | ||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
|
||
import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher; | ||
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.IConstants; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.IFormat; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.SpecificationValidator; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.MsRun; | ||
import org.w3c.dom.Document; | ||
import org.w3c.dom.NodeList; | ||
|
||
public class MassSpectrumMagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher { | ||
|
||
@Override | ||
public boolean checkFileFormat(File file) { | ||
|
||
boolean isValidFormat = false; | ||
try { | ||
file = SpecificationValidator.validateSpecification(file); | ||
if(!file.exists()) { | ||
return isValidFormat; | ||
} | ||
if(!checkFileExtension(file, ".mzXML")) { | ||
return isValidFormat; | ||
} | ||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); | ||
Document document = documentBuilder.parse(file); | ||
NodeList nodeList = document.getElementsByTagName(IConstants.NODE_MS_RUN); | ||
// | ||
JAXBContext jaxbContext = JAXBContext.newInstance(IFormat.CONTEXT_PATH_V_320); | ||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); | ||
MsRun msRun = (MsRun)unmarshaller.unmarshal(nodeList.item(0)); | ||
if(msRun.getScan().size() == 1) | ||
isValidFormat = true; | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return isValidFormat; | ||
} | ||
} |