Last active
August 29, 2015 14:13
-
-
Save slowkow/63f9c7dc369b5fa02830 to your computer and use it in GitHub Desktop.
Transform Biosample XML to TSV.
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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output omit-xml-declaration="yes" /> | |
<!-- | |
Transform biosample XML to TSV. | |
Usage: xsltproc biosample2tsv.xsl input.xml > output.tsv | |
--> | |
<xsl:template match="/">GEO<xsl:text>	</xsl:text>Title<xsl:text>	</xsl:text>CellLine<xsl:text>	</xsl:text>CellType<xsl:text>	</xsl:text>CdnaMethod<xsl:text> </xsl:text> | |
<xsl:for-each select="//BioSample"> | |
<!-- GEO Id --> | |
<xsl:value-of select="//Id[@db='GEO']" /> | |
<xsl:text>	</xsl:text> | |
<!-- Title --> | |
<xsl:if test="//Description/Title"> | |
<xsl:value-of select="//Description/Title" /> | |
</xsl:if> | |
<xsl:text>	</xsl:text> | |
<!-- Tab character | |
<xsl:text>	</xsl:text> | |
--> | |
<!-- Cell Line --> | |
<xsl:choose> | |
<xsl:when test="//Attribute[@attribute_name='cell line']"> | |
<xsl:value-of select="//Attribute[@attribute_name='cell line']" /> | |
</xsl:when> | |
<xsl:otherwise>NA</xsl:otherwise> | |
</xsl:choose> | |
<xsl:text>	</xsl:text> | |
<!-- Cell Type --> | |
<xsl:choose> | |
<xsl:when test="//Attribute[@attribute_name='cell type']"> | |
<xsl:value-of select="//Attribute[@attribute_name='cell type']" /> | |
</xsl:when> | |
<xsl:otherwise>NA</xsl:otherwise> | |
</xsl:choose> | |
<xsl:text>	</xsl:text> | |
<!-- CDNA Method --> | |
<xsl:choose> | |
<xsl:when test="//Attribute[@attribute_name='cdna synthesis method']"> | |
<xsl:value-of select="//Attribute[@attribute_name='cdna synthesis method']" /> | |
</xsl:when> | |
<xsl:otherwise>NA</xsl:otherwise> | |
</xsl:choose> | |
<!-- New line --> | |
<xsl:text> </xsl:text> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment