-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from AllanSSX/master
Adding a script to fuse upstream and downstream profiles
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 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
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) |