Skip to content

Commit

Permalink
fix tab issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Palmer committed May 4, 2018
1 parent 2f60f64 commit 8abc5c2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
30 changes: 15 additions & 15 deletions bin/amptk-process_illumina_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def processSEreads(input):
#if require primer is on make finding primer in amplicon required if amplicon is larger than read length
#if less than read length, can't enforce primer because could have been trimmed via staggered trim in fastq_mergepairs
if len(foralign['locations']) > 1:
multiHits += 1
continue
multiHits += 1
continue
if args.primer == 'on':
if foralign["editDistance"] < 0:
NoPrimer += 1
Expand Down Expand Up @@ -145,18 +145,18 @@ def processPEreads(input):
'''
for_reads, rev_reads = input
if '_' in os.path.basename(for_reads):
name = os.path.basename(for_reads).split("_")[0]
name = os.path.basename(for_reads).split("_")[0]
else:
name = os.path.basename(for_reads)
name = os.path.basename(for_reads)
amptklib.log.debug('{:}: {:} {:}'.format(name, for_reads, rev_reads))
#for_reads = os.path.join(args.input, forwardRead)
#rev_reads = os.path.join(args.input, reverseRead)
StatsOut = os.path.join(args.out, name+'.stats')
#if read length explicity passed use it otherwise measure it
if args.read_length:
read_length = args.read_length
read_length = args.read_length
else:
read_length = amptklib.GuessRL(for_reads)
read_length = amptklib.GuessRL(for_reads)
trimR1 = os.path.join(args.out, name+'_R1.fq')
trimR2 = os.path.join(args.out, name+'_R2.fq')
mergedReads = os.path.join(args.out, name+'.merged.fq')
Expand Down Expand Up @@ -282,7 +282,7 @@ def safe_run2(*args, **kwargs):
sampleDict[rename] = 'unknown'
shutil.copyfile(os.path.join(args.input, x), os.path.join(args.out, rename+'.fq'))
fastq_for.append(os.path.join(args.out, rename+'.fq'))
args.reads = 'forward'
args.reads = 'forward'
else:
if len(filenames) % 2 != 0:
print("Check your input files, they do not seem to be properly paired")
Expand Down Expand Up @@ -327,22 +327,22 @@ def safe_run2(*args, **kwargs):
sampleDict[column[0]] = i5

if args.full_length and args.primer == 'off':
amptklib.log.info('--full_length is not compatible with --require_primer off, turning --full_length off')
args.full_length = False
amptklib.log.info('--full_length is not compatible with --require_primer off, turning --full_length off')
args.full_length = False

#tell user about number of cores using
amptklib.log.info('Demuxing data using {:} cpus'.format(cpus))
amptklib.log.info('Dropping reads less than {:} bp and setting lossless trimming to {:} bp.'.format(args.min_len, args.trim_len))

#zip read lists into a single list of tuples
if args.reads == 'paired':
amptklib.log.info("Strip Primers and Merge PE reads. FwdPrimer: {:} RevPrimer: {:}".format(FwdPrimer, RevPrimer))
readList = list(zip(fastq_for, fastq_rev))
amptklib.runMultiProgress(safe_run, readList, cpus)
amptklib.log.info("Strip Primers and Merge PE reads. FwdPrimer: {:} RevPrimer: {:}".format(FwdPrimer, RevPrimer))
readList = list(zip(fastq_for, fastq_rev))
amptklib.runMultiProgress(safe_run, readList, cpus)
else:
amptklib.log.info("Strip Primers. FwdPrimer: {:} RevPrimer: {:}".format(FwdPrimer, RevPrimer))
amptklib.runMultiProgress(safe_run2, fastq_for, cpus)
amptklib.log.info("Strip Primers. FwdPrimer: {:} RevPrimer: {:}".format(FwdPrimer, RevPrimer))
amptklib.runMultiProgress(safe_run2, fastq_for, cpus)
#cleanup to save space
if gzip_list:
for file in gzip_list:
Expand Down
60 changes: 30 additions & 30 deletions lib/amptklib.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,23 +604,23 @@ def PEandIndexCheck(R1, R2, R3):
return False

def mapIndex(seq, mapDict, bcmismatch):
besthit = []
for index_name,index in mapDict.items():
align = edlib.align(index, seq, mode="SHW", k=bcmismatch, additionalEqualities=degenNuc)
if align["editDistance"] < 0:
continue
elif align["editDistance"] == 0:
return (index_name, 0)
else:
if len(besthit) < 3:
besthit = [index, index_name, align["editDistance"]]
else:
if align["editDistance"] < int(besthit[2]):
besthit = [index, index_name, align["editDistance"]]
if len(besthit) == 3:
return (besthit[1], besthit[2])
else:
return (None,None)
besthit = []
for index_name,index in mapDict.items():
align = edlib.align(index, seq, mode="SHW", k=bcmismatch, additionalEqualities=degenNuc)
if align["editDistance"] < 0:
continue
elif align["editDistance"] == 0:
return (index_name, 0)
else:
if len(besthit) < 3:
besthit = [index, index_name, align["editDistance"]]
else:
if align["editDistance"] < int(besthit[2]):
besthit = [index, index_name, align["editDistance"]]
if len(besthit) == 3:
return (besthit[1], besthit[2])
else:
return (None,None)


def DemuxIllumina(R1, R2, I1, mapDict, mismatch, fwdprimer, revprimer, primer_mismatch, outR1, outR2):
Expand Down Expand Up @@ -824,12 +824,12 @@ def demuxIlluminaPE(R1, R2, fwdprimer, revprimer, samples, forbarcodes, revbarco
NoPrimer += 1
continue
if len(revbarcodes) > 0:
#look for valid revbarcodes
if len(revbarcodes) > 0:
revBC, revBCLabel = AlignBarcode(read2[1], revbarcodes, barcode_mismatch)
if revBC == '':
NoRevBarcode += 1
continue
#look for valid revbarcodes
if len(revbarcodes) > 0:
revBC, revBCLabel = AlignBarcode(read2[1], revbarcodes, barcode_mismatch)
if revBC == '':
NoRevBarcode += 1
continue
#look for reverse primer in reverse read
revalign = edlib.align(revprimer, read2[1], mode="HW", k=primer_mismatch, additionalEqualities=degenNuc)
if revalign['editDistance'] < 0: #not found
Expand Down Expand Up @@ -903,12 +903,12 @@ def demuxIlluminaPE2(R1, R2, fwdprimer, revprimer, samples, forbarcodes, revbarc
if R2ForTrim == 0:
continue
if len(revbarcodes) > 0:
#look for reverse barcode
R2BCTrim = R2ForTrim - len(revprimer)
revBC, revBCLabel = AlignBarcode2(read2[1][:R2BCTrim], revbarcodes, barcode_mismatch)
if revBC == '':
NoRevBarcode += 1
continue
#look for reverse barcode
R2BCTrim = R2ForTrim - len(revprimer)
revBC, revBCLabel = AlignBarcode2(read2[1][:R2BCTrim], revbarcodes, barcode_mismatch)
if revBC == '':
NoRevBarcode += 1
continue
#okay, found both primers and barcodes, now 1 more cleanup step trip revcomped primers
R1RevTrim = trimRevPrimer(revprimer, read1[1], primer_mismatch)
R2RevTrim = trimRevPrimer(fwdprimer, read2[1], primer_mismatch)
Expand Down Expand Up @@ -1910,7 +1910,7 @@ def parseMappingFileNEW(input):
log.error('Mapping file incorrectly formatted, headers should be (RevBarcodeSequence is optional):\n{:}'.format(exampleMapFile))
sys.exit(1)
if not RBCx:
log.debug('Mapping file missing header: "RevBarcodeSequence", skipping reverse barcodes')
log.debug('Mapping file missing header: "RevBarcodeSequence", skipping reverse barcodes')
with open(input, 'rU') as inputfile:
for line in inputfile:
line = line.rstrip()
Expand Down

0 comments on commit 8abc5c2

Please sign in to comment.