Skip to content

Commit

Permalink
Merge pull request #3 from Sage-Bionetworks/develop
Browse files Browse the repository at this point in the history
Add license, setup, some function name/parameter modifications
  • Loading branch information
philerooski authored Nov 19, 2017
2 parents 959ce7a + d5c2e0d commit daf96b5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2017] [Phil Snyder]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Welcome, AnnotatorAdmin!
In [4]: p = annotator.Pipeline(syn, meta="syn7654321")
[####################]100.00% 1/1 Done...
In [5]: # Copy the default annotations (assay, study, etc.) as they appear above to your clipboard
In [6]: cols = annotator.utils.convertClipboardToDict(" - ")
In [6]: cols = annotator.utils.clipboardToDict(" - ")
In [7]: for c in ['specimenID', 'individualID', 'assayTarget', 'cellType']:
cols[c] = None
In [8]: p.createFileView(name="EpiDiff_CHiPSeq", parent="syn0000000", scope="syn1234567", addCols=cols)
Expand Down Expand Up @@ -126,7 +126,7 @@ Remember, we still have to add a file format column and transform the values in
In [12]: p.addFileFormatCol()
In [13]: p.substituteColumnValues('cellType', {'Pos':'NeuN+', 'Neg':'NeuN-'})
```
The `addFileFormatCol` method defaults to a preprogrammed regex and uses column 'name' in the data view. But we can use a more flexible approach by using `annotator.utils.makeColFromRegex` if necessary.
The `addFileFormatCol` method defaults to a preprogrammed regex and uses column 'name' in the data view. But we can use a more flexible approach by using `annotator.utils.colFromRegex` if necessary.

If everything looks good, we can go ahead and push our changes back up to Synapse.

Expand Down
2 changes: 1 addition & 1 deletion annotator/Pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def _parseView(self, view, sortCols, isMeta=False):
if isinstance(view, str):
return utils.synread(self.syn, view, sortCols)
elif isinstance(view, list) and meta:
return utils.combineSynapseTabulars(self.syn, view)
return utils.combineSynapseTabulars(self.syn, view, axis=1)
elif isinstance(view, pd.DataFrame):
if sortCols:
view = view.sort_index(1)
Expand Down
10 changes: 5 additions & 5 deletions annotator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _synread(synId, f, syn_, sortCols):
else:
return d

def convertClipboardToDict(sep):
def clipboardToDict(sep):
""" Parse two-column delimited clipboard contents to a dictionary.
Parameters
Expand Down Expand Up @@ -149,8 +149,8 @@ def makeColumns(obj, asSynapseCols=True):
elif isinstance(obj, dict): return _colsFromDict(obj, asSynapseCols)
elif isinstance(obj, list): return _colsFromList(obj, asSynapseCols)

def combineSynapseTabulars(syn, tabulars):
""" Concatenate tabular files column-wise.
def combineSynapseTabulars(syn, tabulars, axis=0):
""" Concatenate tabular files.
Parameters
----------
Expand All @@ -163,7 +163,7 @@ def combineSynapseTabulars(syn, tabulars):
pandas.DataFrame
"""
tabulars = synread(syn, tabulars)
return pd.concat(tabulars, axis=1, ignore_index=True).sort_index(1)
return pd.concat(tabulars, axis=axis, ignore_index=True).sort_index(1)

def inferValues(df, col, referenceCols):
""" Fill in values for indices which match on `referenceCols`
Expand Down Expand Up @@ -206,7 +206,7 @@ def substituteColumnValues(referenceList, mod):
type(referenceList)))
return referenceList

def makeColFromRegex(referenceList, regex):
def colFromRegex(referenceList, regex):
""" Return a list created by mapping a regular expression to another list.
The regular expression must contain at least one capture group.
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

14 changes: 14 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from setuptools import setup, find_packages

setup(
name='annotator',
version='0.1',
description='A Synapse annotations automation tool.',
url='https://github.com/Sage-Bionetworks/annotator',
author='Phil Snyder',
author_email='phil.snyder@sagebase.org',
license='MIT',
packages=find_packages(),
install_requires=[
'pandas',
'synapseclient'])

0 comments on commit daf96b5

Please sign in to comment.