-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 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,28 @@ | ||
import os | ||
import sys | ||
|
||
def main(): | ||
infiles = sys.argv[1].split(' ') | ||
alleles = {} | ||
for mhc in infiles: | ||
fh_in = open(mhc, 'r') | ||
# skip header | ||
for line in fh_in: | ||
cols = line.rstrip().split('\t') | ||
source = cols[0] | ||
mhc = cols[1] | ||
|
||
if mhc not in alleles: | ||
alleles[mhc] = source | ||
else: | ||
alleles[mhc] += ',' + source | ||
fh_in.close() | ||
|
||
outfile = sys.argv[2] | ||
fh_out = open(outfile, 'w') | ||
for allele in alleles: | ||
fh_out.write(f'{alleles[allele]}\t{allele}\n') | ||
fh_out.close() | ||
|
||
|
||
main() |
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,32 @@ | ||
import os | ||
import sys | ||
import re | ||
from pathlib import Path | ||
|
||
def main(): | ||
files = sys.argv[1] | ||
alleles = {} | ||
for file in files.rstrip().split(' '): | ||
filestem = Path(file).stem | ||
se = re.search(r'^(.+)_(RNA|DNA)_(SE|PE)', filestem) | ||
group = se.group(1) | ||
|
||
fh = open(file, 'r') | ||
for line in fh: | ||
al = line.rstrip() | ||
if al not in alleles: | ||
alleles[al] = [] | ||
|
||
alleles[al].append(group) | ||
|
||
|
||
out = open(sys.argv[2], 'w') | ||
for al in dict(sorted(alleles.items())): | ||
for i,v in enumerate(alleles[al]): | ||
if i == 0: | ||
out.write(v) | ||
else: | ||
out.write(f',{v}') | ||
out.write(f'\t{al}\n') | ||
|
||
main() |