Skip to content

Commit

Permalink
fail on pre-aligned sequence input
Browse files Browse the repository at this point in the history
  • Loading branch information
treangen committed Jul 21, 2014
1 parent 3a1b1d2 commit aaea9f7
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Parsnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def usage():
multifasta = True
for seq in refseqs:
fastalen = len(seq.split("\n",1)[-1].replace("\n",""))
ref_seqs[currpos+fastalen] = seqnum#seq.split("\n",1)[0]
ref_seqs[currpos+fastalen] = seqnum
currpos = currpos+fastalen
seqnum+=1

Expand Down Expand Up @@ -909,13 +909,16 @@ def usage():
if ref == "!":
ref = random.choice(fnafiles1)
ref = seqdir+os.sep+ref
else:
if 1:
ff = open(ref,'r')
hdr = ff.readline()
if hdr[0] == ">":

data = ff.read()
data = data.replace("\n","")
if "-" in data:
sys.stderr.write( "ERROR: ref genome sequence %s seems to aligned! remove and restart \n"%(ref))
sys.exit(1)
reflen = len(data)
ff.close()
for file in files:
Expand All @@ -931,6 +934,10 @@ def usage():
for line in ff.xreadlines():
if line[0] != ">":
data.append(line.replace("\n",""))
if "-" in line:
sys.stderr.write( "ERROR: genome sequence %s seems to aligned! remove and restart \n"%(file))
sys.exit(1)

totlen += len(line.replace("\n",""))

if ref in file or file in ref:
Expand Down Expand Up @@ -1018,7 +1025,7 @@ def usage():
processed.append(file)
params = {}
params["jobID"] = len(tasks)
params["ref"] = "%s"%(ref)#+".single")
params["ref"] = "%s"%(ref)
params["query"] = "%s"%(seqdir+os.sep+file+".single")
params["queryfile"] = file
params["prefix"] = "%s"%(file+".mummerout")
Expand All @@ -1029,16 +1036,16 @@ def usage():

fnafiles = processed
fileidx = -1
#print len(seqs)

hit_dict = {}
qry_hit_dict = {}
hdr_dict = {}
length_dict = {}

TOTSEQS=len(fnafiles)+1
seqids_list = []
use_mummer_mumi = False#True#False#False
use_parsnp_mumi = True#False#True
use_mummer_mumi = False
use_parsnp_mumi = True
if not inifile_exists:
if len(fnafiles) < 1 or ref == "":
sys.stderr.write( "Parsnp requires 2 or more genomes to run, exiting\n")
Expand Down Expand Up @@ -1146,8 +1153,10 @@ def usage():

if curated:
for file in fnafiles:
finalfiles.append(file)
allfiles.append(file)
if file not in finalfiles:
finalfiles.append(file)
if file not in allfiles:
allfiles.append(file)

if mumi_only:
mumi_f.close()
Expand Down

0 comments on commit aaea9f7

Please sign in to comment.