Skip to content

Commit

Permalink
Merge pull request #2 from AllanSSX/master
Browse files Browse the repository at this point in the history
Adding a script to fuse upstream and downstream profiles
  • Loading branch information
rstraver committed Jun 9, 2016
2 parents e80b2d0 + 177dda2 commit 54fbb7e
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions fuseProfiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#================================================================#

import argparse

#================================================================#

def getArgs():
parser = argparse.ArgumentParser(description="",version="1.0.0")
parser.add_argument('-u',dest="up",type=argparse.FileType('r'),required=True,help='upstream csv file')
parser.add_argument('-d',dest="down",type=argparse.FileType('r'),required=True,help='downstream csv file')

args = parser.parse_args()

return args

def splitcsv(csv):
csvdict = {}

for line in csv:
elem = line.split(',')
id = elem[0]
pos = elem[1:-1]
csvdict[id] = pos

return csvdict

def main(args):
up = splitcsv(args.up)
down = splitcsv(args.down)

for sample in sorted(up.keys()):

upPos = up[sample]
upPos.reverse()
downPos = down[sample]
profiles = [sample] + upPos[:-1] + downPos

print ','.join(profiles)

if __name__ == '__main__':
args = getArgs()
main(args)

0 comments on commit 54fbb7e

Please sign in to comment.