Skip to content

Commit

Permalink
Installable and importable as 'transmart'
Browse files Browse the repository at this point in the history
  • Loading branch information
jochemb committed May 10, 2017
1 parent e0b04a8 commit c54c3ad
Show file tree
Hide file tree
Showing 9 changed files with 779 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
.ipynb_checkpoints
*.pyc
.idea/
*.ipynb
__pycache__/
build/
dist/
transmart.egg-info/
transmart/__pycache__/
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
The tranSMART API Training given on [2015 tranSMART Foundation Annual Meeting in Amsterdam](http://transmartfoundation.org/2015-annual-meeting/)

The Python part of this training is in this branch meant to work with Python 3.x.
The python client created for that project has now been recovered to work with version 2 of the tranSMART API.

This is meant to work with Python 3.x only.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
protobuf

52 changes: 52 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import setuptools
import os
import re


VERSIONFILE=os.path.join('transmart', '__init__.py')
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
version_string = mo.group(1)
else:
raise RuntimeError("Unable to find version string in {}.".format(VERSIONFILE,))

with open("requirements.txt", 'r') as f:
required_packages = f.read().splitlines()

if os.environ.get('READTHEDOCS') == 'True':
for dependency in ['pandas']:
for package in required_packages:
if package.startswith(dependency):
required_packages.remove(package)


setuptools.setup(
name="transmart",
version=version_string,
url="https://www.github.com/thehyve/transmart-api-client-py/",

maintainer="[email protected]",
maintainer_email="[email protected]",

description="An python client for communicating with the transmart rest api.",
long_description=open('README.md').read(),

packages=setuptools.find_packages(exclude=['tests', 'tests.*']),
include_package_data=True,

keywords=['transmart', 'rest', 'api', 'data', 'science'],

download_url='https://github.com/thehyve/transmart-api-client-py/tarball/{}/'.format(version_string),

install_requires=required_packages,

classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
)
8 changes: 8 additions & 0 deletions transmart/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""tmtk - A toolkit for ETL curation for the tranSMART data warehouse."""

from .transmart_api import TransmartApi
from . import utils

__version__ = "0.1.0"
__author__ = 'The Hyve'
__all__ = []
71 changes: 71 additions & 0 deletions transmart/highdim.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright 2014 Janssen Research & Development, LLC.
//
// This file is part of REST API: transMART's plugin exposing tranSMART's
// data via an HTTP-accessible RESTful API.
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version, along with the following terms:
//
// 1. You may convey a work based on this program in accordance with
// section 5, provided that you retain the above notices.
// 2. You may convey verbatim copies of this program code as you receive
// it, in any medium, provided that you retain the above notices.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>.


package highdim;

option java_package = "org.transmartproject.rest.protobuf";
option java_outer_classname = "HighDimProtos";

//command to compile this file, from the transmart-rest-api base folder:
//protoc --java_out=src/java src/protobuf/highdim/highdim.proto
message HighDimHeader {

repeated Assay assay = 1;
repeated ColumnSpec columnSpec = 2;
}

message ColumnSpec {
enum ColumnType { DOUBLE = 1; STRING = 2; }

required string name = 1;
required ColumnType type = 2;
}

message Assay {
required int64 assayId = 1;
required string patientId = 2;
optional string sampleTypeName = 3;
optional string timepointName = 4;
optional string tissueTypeName = 5;
optional string platform = 6;
optional string sampleCode = 7;
}

// One Row per bioMarker/label
message Row {
required string label = 1;
optional string bioMarker = 2;
// A ColumnValue per column (as given by the used projection).
// For single-column projections such as zscore/default_real/etc this has only one entry.
// Each ColumnValue has a corresponding ColumnSpec entry in the header.
repeated ColumnValue value = 3;
}

message ColumnValue {
// Only ONE of these should be set!
// The type that is set must correspond to that indicated in the corresponding ColumnType for this column in the header.
// Every value corresponds to one assay (matching the order in the header), there are as many values as there are assays
repeated double doubleValue = 1 [packed=true];
repeated string stringValue = 2;
}
Loading

0 comments on commit c54c3ad

Please sign in to comment.