-
Notifications
You must be signed in to change notification settings - Fork 34
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
Showing
106 changed files
with
14,800 additions
and
46 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
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
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
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
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
46 changes: 46 additions & 0 deletions
46
biodata-formats/src/main/java/org/opencb/biodata/formats/pubmed/PubMedParser.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,46 @@ | ||
package org.opencb.biodata.formats.pubmed; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.JAXBException; | ||
import javax.xml.bind.Marshaller; | ||
import javax.xml.bind.Unmarshaller; | ||
import java.io.*; | ||
import java.util.zip.GZIPInputStream; | ||
|
||
public class PubMedParser { | ||
|
||
|
||
public final static String PUBMED_CONTEXT = "org.opencb.biodata.formats.pubmed.v233jaxb"; | ||
|
||
public static void saveXMLInfo(Object obj, String filename) throws FileNotFoundException, JAXBException { | ||
JAXBContext jaxbContext; | ||
jaxbContext = JAXBContext.newInstance(PUBMED_CONTEXT); | ||
Marshaller marshaller = jaxbContext.createMarshaller(); | ||
marshaller.marshal(obj, new FileOutputStream(filename)); | ||
} | ||
|
||
/** | ||
* Checks if XML info path exists and loads it | ||
* | ||
* @throws javax.xml.bind.JAXBException | ||
* @throws java.io.IOException | ||
*/ | ||
public static Object loadXMLInfo(String filename) throws JAXBException, IOException { | ||
System.setProperty("javax.xml.accessExternalDTD", "all"); | ||
|
||
Object obj = null; | ||
JAXBContext jaxbContext = JAXBContext.newInstance(PUBMED_CONTEXT); | ||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); | ||
|
||
if (filename.endsWith("gz")) { | ||
FileInputStream fis = new FileInputStream(filename); | ||
GZIPInputStream gis = new GZIPInputStream(fis); | ||
obj = unmarshaller.unmarshal(gis); | ||
} else { | ||
obj = unmarshaller.unmarshal(new File(filename)); | ||
} | ||
|
||
|
||
return obj; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
biodata-formats/src/main/java/org/opencb/biodata/formats/pubmed/v233jaxb/Abstract.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,102 @@ | ||
// | ||
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0.1 | ||
// See <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a> | ||
// Any modifications to this file will be lost upon recompilation of the source schema. | ||
// Generated on: 2022.05.23 at 12:52:46 PM UTC | ||
// | ||
|
||
|
||
package org.opencb.biodata.formats.pubmed.v233jaxb; | ||
|
||
import javax.xml.bind.annotation.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* <p>Java class for anonymous complex type. | ||
* | ||
* <p>The following schema fragment specifies the expected content contained within this class. | ||
* | ||
* <pre> | ||
* <complexType> | ||
* <complexContent> | ||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> | ||
* <sequence> | ||
* <element ref="{}AbstractText" maxOccurs="unbounded"/> | ||
* <element ref="{}CopyrightInformation" minOccurs="0"/> | ||
* </sequence> | ||
* </restriction> | ||
* </complexContent> | ||
* </complexType> | ||
* </pre> | ||
* | ||
* | ||
*/ | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = "", propOrder = { | ||
"abstractText", | ||
"copyrightInformation" | ||
}) | ||
@XmlRootElement(name = "Abstract") | ||
public class Abstract { | ||
|
||
@XmlElement(name = "AbstractText", required = true) | ||
protected List<AbstractText> abstractText; | ||
@XmlElement(name = "CopyrightInformation") | ||
protected String copyrightInformation; | ||
|
||
/** | ||
* Gets the value of the abstractText property. | ||
* | ||
* <p> | ||
* This accessor method returns a reference to the live list, | ||
* not a snapshot. Therefore any modification you make to the | ||
* returned list will be present inside the JAXB object. | ||
* This is why there is not a <CODE>set</CODE> method for the abstractText property. | ||
* | ||
* <p> | ||
* For example, to add a new item, do as follows: | ||
* <pre> | ||
* getAbstractText().add(newItem); | ||
* </pre> | ||
* | ||
* | ||
* <p> | ||
* Objects of the following type(s) are allowed in the list | ||
* {@link AbstractText } | ||
* | ||
* | ||
*/ | ||
public List<AbstractText> getAbstractText() { | ||
if (abstractText == null) { | ||
abstractText = new ArrayList<AbstractText>(); | ||
} | ||
return this.abstractText; | ||
} | ||
|
||
/** | ||
* Gets the value of the copyrightInformation property. | ||
* | ||
* @return | ||
* possible object is | ||
* {@link String } | ||
* | ||
*/ | ||
public String getCopyrightInformation() { | ||
return copyrightInformation; | ||
} | ||
|
||
/** | ||
* Sets the value of the copyrightInformation property. | ||
* | ||
* @param value | ||
* allowed object is | ||
* {@link String } | ||
* | ||
*/ | ||
public void setCopyrightInformation(String value) { | ||
this.copyrightInformation = value; | ||
} | ||
|
||
} |
Oops, something went wrong.