Created
October 17, 2016 15:56
-
-
Save suqingdong/78cefb304983308722a0890fc942b6e4 to your computer and use it in GitHub Desktop.
generate sample_list according to info.txt and list.txt
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
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
def get_sample_list(infofile, listfile): | |
sampledict = {} | |
with open(infofile) as f: | |
for line in f: | |
sampleid,novoid = line.strip().split('\t')[2:4] | |
sampledict[novoid] = sampleid | |
with open('sample_list', 'w') as out: | |
out.write('Ori_lane\tPatientID\tSampleID\tLibID\tNovoID\tIndex\tPath\n') | |
with open(listfile) as f: | |
for line in f: | |
linelist = line.strip().split('\t') | |
lane = linelist[0] | |
libid = linelist[9] | |
novoid = linelist[4] | |
index = linelist[10] | |
path = linelist[18] | |
patientid = sampleid = sampledict[novoid] | |
out.write('{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format(lane, patientid, sampleid, libid, novoid, index, path)) | |
if __name__ == '__main__': | |
import sys | |
if len(sys.argv) < 3: | |
print "Usage python %s <info.txt> <list.txt>" % sys.argv[0] | |
exit(1) | |
get_sample_list(sys.argv[1], sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment