comparison amplicon_analysis_pipeline.py @ 3:3ab198df8f3f draft

planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit 15390f18b91d838880d952eb2714f689bbd8a042
author pjbriggs
date Thu, 18 Oct 2018 09:18:04 -0400
parents 1c1902e12caf
children 86a12d75ebe4
comparison
equal deleted inserted replaced
2:43d6f81bc667 3:3ab198df8f3f
58 for line in message.split('\n'): 58 for line in message.split('\n'):
59 sys.stderr.write("* %s%s *\n" % (line,' '*(width-len(line)-4))) 59 sys.stderr.write("* %s%s *\n" % (line,' '*(width-len(line)-4)))
60 sys.stderr.write("%s\n\n" % ('*'*width)) 60 sys.stderr.write("%s\n\n" % ('*'*width))
61 61
62 def clean_up_name(sample): 62 def clean_up_name(sample):
63 # Remove trailing "_L[0-9]+_001" from Fastq 63 # Remove extensions and trailing "_L[0-9]+_001" from
64 # pair names 64 # Fastq pair names
65 split_name = sample.split('_') 65 sample_name = '.'.join(sample.split('.')[:1])
66 split_name = sample_name.split('_')
66 if split_name[-1] == "001": 67 if split_name[-1] == "001":
67 split_name = split_name[:-1] 68 split_name = split_name[:-1]
68 if split_name[-1].startswith('L'): 69 if split_name[-1].startswith('L'):
69 try: 70 try:
70 int(split_name[-1][1:]) 71 int(split_name[-1][1:])
137 os.symlink(categories_file,"Categories.txt") 138 os.symlink(categories_file,"Categories.txt")
138 print "-- made symlink to Categories.txt" 139 print "-- made symlink to Categories.txt"
139 140
140 # Link to FASTQs and construct Final_name.txt file 141 # Link to FASTQs and construct Final_name.txt file
141 sample_names = [] 142 sample_names = []
143 print "-- making Final_name.txt"
142 with open("Final_name.txt",'w') as final_name: 144 with open("Final_name.txt",'w') as final_name:
143 fastqs = iter(args.fastq_pairs) 145 fastqs = iter(args.fastq_pairs)
144 for sample_name,fqr1,fqr2 in zip(fastqs,fastqs,fastqs): 146 for sample_name,fqr1,fqr2 in zip(fastqs,fastqs,fastqs):
145 sample_name = clean_up_name(sample_name) 147 sample_name = clean_up_name(sample_name)
148 print " %s" % sample_name
146 r1 = "%s_R1_.fastq" % sample_name 149 r1 = "%s_R1_.fastq" % sample_name
147 r2 = "%s_R2_.fastq" % sample_name 150 r2 = "%s_R2_.fastq" % sample_name
148 os.symlink(fqr1,r1) 151 os.symlink(fqr1,r1)
149 os.symlink(fqr2,r2) 152 os.symlink(fqr2,r2)
150 final_name.write("%s\n" % '\t'.join((r1,sample_name))) 153 final_name.write("%s\n" % '\t'.join((r1,sample_name)))